private void Awake() { squares = new GameObject[8, 8]; pieces = new GameObject[8, 8]; highlights = new GameObject[8, 8]; boardOProps = boardO.GetComponent <BoardSquareProperties>(); instantiateBoard(); }
// 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(); }
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); } } }
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; } } } }