Esempio n. 1
0
 public boolean attack(Ball ball) {
   int angle = this.calculateAngle(this.getX(), this.getY(), ball.getX(), ball.getY());
   GameInfo.currentMap[this.getY() / Config.slotHeight][this.getX() / Config.slotWidth] =
       this.getMapID() + angle;
   GameManager gameManager = GameManager.getInstance();
   int id = BallCache.generateBallID();
   gameManager.addBall(this.getBulletName(), this.getX(), this.getY(), ball, id);
   SendWrapper.sendBallAction(this, "TOWERATTACK");
   return true;
 }
Esempio n. 2
0
  public void run() {
    int count = SendWrapper.checkSeqNum();
    while (count < Config.numPerRound) {
      job();
      try {
        Thread.sleep(Config.ballThreadWait);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      count = SendWrapper.checkSeqNum();
    }
    LogHelper.debug("arrive the limit, notifing others. ");

    this.stop();
    try {
      barrier.await();
    } catch (InterruptedException | BrokenBarrierException e) {
      e.printStackTrace();
    }
    Thread.currentThread().interrupt();
  }