private void init(bool isFirst) { //TODO 繰り返しが多い MakeSquares(isFirst); MakePieces(isFirst); selectedSquareIDs = new List <int>(); state = State.GAME; turn = Util.PIECE_COLOR.WHITE; textYouBlack.text = "You"; textYouWhite.text = "You"; switchTurnUI(); }
private bool IsExistMovable(Util.PIECE_COLOR turn) { for (int i = 0; i < 5; i++) { // 意図的に色を変えてる int index = (turn == Util.PIECE_COLOR.WHITE) ? i * 2 : i * 2 + 1; if (pieces[index].getMovable()) { return(true); } } return(false); }
public void OnSquareClick(GameObject square) { Piece p = selectedPiece.GetComponent <Piece>(); Square s = square.GetComponent <Square>(); //移動元のSquareの場所の高さを1つ下げる squares[p.id].downHeight(); p.MoveToID(s.id, s.height); squares[s.id].upHeight(); // 動けなくなるPieceの確認 foreach (Piece piece in pieces) { bool movable = (piece.height == squares[piece.id].height - 1); piece.setMovable(movable); } // 選択済のPieceを選択解除 DeselectPiece(); // 前回の隣接していたマスを選択不可能にする foreach (int id in selectedSquareIDs) { squares[id].ToUnselectable(); } // idが勝利マスだったら終了,または動ける駒をなくす // 勝者は現在のturn変数の中身 Util.PIECE_COLOR tmp = (Util.PIECE_COLOR)((int)turn * -1); if (s.id == 25 || s.id == 26 || !IsExistMovable(tmp)) { GotoGameFinish(); return; } // 効果音を鳴らす SoundManager.GetInstance().PlaySE(Sound.ID.PUTTING_PIECE); turn = (Util.PIECE_COLOR)((int)turn * -1); switchTurnUI(); }
public void Create(Util.PIECE_COLOR color, int id) { this.color = color; this.id = id; setOwnMaterial(); }