示例#1
0
 private void Awake()
 {
     squares     = new GameObject[8, 8];
     pieces      = new GameObject[8, 8];
     highlights  = new GameObject[8, 8];
     boardOProps = boardO.GetComponent <BoardSquareProperties>();
     instantiateBoard();
 }
示例#2
0
 // Start is called before the first frame update
 void Start()
 {
     playerBlack  = createPlayer(PlayerEnum.black, GameProperties.playerBlackIsHuman);
     playerWhite  = createPlayer(PlayerEnum.white, GameProperties.playerWhiteIsHuman);
     gameO        = new Game(playerBlack, playerWhite);
     boardUpdateO = GameObject.FindObjectOfType <BoardUpdate>();
     boardUpdateO.setBoard(gameO.gameBoard);
     boardUpdateO.game      = this.gameO;
     boardSquarePropertiesO = GameObject.FindObjectOfType <BoardSquareProperties>();
     gameO.initGame();
 }
示例#3
0
 public void getValidMovesListHandler()
 {
     foreach (var XYDirection in game.validMovesAndDirsForThisTurn)
     {
         boardOProps = squares[XYDirection[1], XYDirection[0]].GetComponent <BoardSquareProperties>();
         if (!highlights[XYDirection[1], XYDirection[0]])
         {
             //Debug.Log("VALID MOVE X and Y: " + XYDirection[0] + " , " + XYDirection[1]);
             highlights[XYDirection[1], XYDirection[0]] = (GameObject)Instantiate(boardOProps.Highlight, boardOProps.transform.position, boardOProps.PieceOWhite.transform.rotation);
         }
     }
 }
示例#4
0
    public void boardUpdateHandler()
    {
        for (int y = 0; y < 8; y++)
        {
            for (int x = 0; x < 8; x++)
            {
                boardOProps = squares[y, x].GetComponent <BoardSquareProperties>();


                // clear highlights
                if (highlights[y, x])
                {
                    //Debug.Log("----------------------------------REMOVE highlight at X and Y: " + x + ", " + y);
                    DestroyImmediate(highlights[y, x], true);
                }


                if (board.board[y, x].belongsToPlayer != boardOProps.pieceColor)
                {
                    //Update Piece - Destroy old
                    if (boardOProps.pieceColor == PlayerEnum.white && pieces[y, x])
                    {
                        //Debug.Log("------------------DELETE Black");
                        Destroy(pieces[y, x]);
                    }
                    else if (boardOProps.pieceColor == PlayerEnum.black && pieces[y, x])
                    {
                        //Debug.Log("------------------DELETE Black");
                        Destroy(pieces[y, x]);
                    }

                    //Update Piece - Create New
                    if (board.board[y, x].belongsToPlayer == PlayerEnum.white)
                    {
                        pieces[y, x] = (GameObject)Instantiate(boardOProps.PieceOWhite, boardOProps.transform.position, boardOProps.PieceOWhite.transform.rotation);
                        //Debug.Log("------------------Create New WHITE \n" + pieces[y, x]);
                    }
                    else if (board.board[y, x].belongsToPlayer == PlayerEnum.black)
                    {
                        pieces[y, x] = (GameObject)Instantiate(boardOProps.PieceOBlack, boardOProps.transform.position, boardOProps.PieceOBlack.transform.rotation);
                        //Debug.Log(" ------------------Create New BLACK \n" + pieces[y, x]);
                    }

                    //change to correct value
                    boardOProps.pieceColor = board.board[y, x].belongsToPlayer;
                }
            }
        }
    }