Exemplo n.º 1
0
 WorldController(Game game, UIProvider ui) {
   this.game = game;
   this.ui = ui;
   world = new World();
   world.setBroomLocation(0, CurlingConstants.TEE_TO_CENTER);
   ui.setWorld(world);
 }
Exemplo n.º 2
0
 private void updateSweep() {
   if (currentStone == null) {
     return;
   }
   double sweep = ui.getSelectedSweep();
   if (sweep != currentStone.getSweep()) {
     currentStone.setSweep(sweep);
     game.sendAllStones(world.getStones());
   }
 }
Exemplo n.º 3
0
 public void throwStone() {
   double speed = ui.getSpeed();
   speed = Math.pow(speed, 1.5);
   double v = (1.0 - speed) * 2.3 + 3.0 * speed;
   Vect2d broom = new Vect2d(world.getBroomX(), world.getBroomY());
   Vect2d dir = broom.minus(CurlingConstants.STONE_START).normalized();
   Vect2d vel = dir.times(v);
   double da = 1.0;
   if (!ui.isHandRight()) {
     da = -da;
   }
   currentStone =
       new Stone(CurlingConstants.STONE_START, vel, 0, da, game.getMatchCtrl().getCurrentTeam());
   double sweep = ui.getSelectedSweep();
   currentStone.setSweep(sweep);
   logger.info("New stone: " + currentStone);
   world.addStone(currentStone);
   game.sendNewStone(currentStone);
   ui.endTurn();
 }
Exemplo n.º 4
0
 public void handChanged(boolean right) {
   ui.setHand(right);
   game.sendHand(right);
 }
Exemplo n.º 5
0
 public void speedChanged(double speed) {
   ui.setSpeed(speed);
   game.sendSpeed(speed);
 }