Exemplo n.º 1
0
  /**
   * ユニットを任意の方向に動かす
   *
   * @param vecX x軸方向にどのように動かすか -1,0,1
   * @param vecY y方向にどのように動かすか -1,0,1
   * @param index 動かすユニット番号 0-3
   * @return trure 成功 false 失敗
   */
  public boolean move(int vecX, int vecY, int index) {
    int id = this.whoIsPlay();

    unitLocation[id][index].x += vecX;
    unitLocation[id][index].y += vecY;

    this.lastIndex = index;
    this.lastX = unitLocation[id][index].x;
    this.lastY = unitLocation[id][index].y;
    this.lastId = this.whoIsPlay();

    nextPhase();

    return true;
  }
Exemplo n.º 2
0
  /**
   * ユニットを任意の場所に動かす
   *
   * <p>2015/08/31追加 失敗する条件は次の通り ・現在の座標と移動先の座標が同じ場合 ・座標が範囲外を参照した場合 ・移動距離が1マス以上を超えた場合
   *
   * @param x 動かした先の座標
   * @param y 動かした先の座標
   * @param index 動かすユニット番号 0-3
   * @return trure 成功 false 失敗
   */
  public boolean movePos(int x, int y, int index) {
    int id = this.whoIsPlay();

    //  範囲外参照チェック
    if (!GameBoard.availableArea(x, y)) {
      return false;
    }

    //  距離が0もしくは2以上の移動は無効
    if (GameBoard.distance(unitLocation[id][index], new Point(x, y)) != 1) {
      return false;
    }

    unitLocation[id][index].x = x;
    unitLocation[id][index].y = y;

    this.lastIndex = index;
    this.lastX = x;
    this.lastY = y;
    this.lastId = this.whoIsPlay();

    nextPhase();
    return true;
  }