private void OpenMovePlayer() { currentGameState = GameState.Transitioning; var currentRow = currentPlayer.GetRow(); var currentCol = currentPlayer.GetCol(); AddTileToMovingPath(PlayingAreaController.GetTile(currentRow, currentCol)); //add first tile to moving path ShowNextPossibleMoves(currentRow, currentCol); currentGameState = GameState.MovePlayer; }
private void ShowNextPossibleMoves(int currentRow, int currentCol) { var currentTile = PlayingAreaController.GetTile(currentRow, currentCol); if (!currentTile.leftWall.activeInHierarchy && currentTile.GetCol() != 0) { leftNeighbour = PlayingAreaController.CheckNeighbourConnection(currentRow, currentCol - 1, Direction.Left); if (!CheckIfTileInPath(PlayingAreaController.GetTile(currentRow, currentCol - 1))) { ChangeTileMaterial(leftNeighbour, connectedNeighbourMaterial); } else { if (leftNeighbour != movingPathTiles[movingPathTiles.Count - 2]) { leftNeighbour = null; } } } if (!currentTile.rightWall.activeInHierarchy && currentTile.GetCol() != playingAreaSize - 1) { rightNeighbour = PlayingAreaController.CheckNeighbourConnection(currentRow, currentCol + 1, Direction.Right); if (!CheckIfTileInPath(PlayingAreaController.GetTile(currentRow, currentCol + 1))) { ChangeTileMaterial(rightNeighbour, connectedNeighbourMaterial); } else { if (rightNeighbour != movingPathTiles[movingPathTiles.Count - 2]) { rightNeighbour = null; } } } if (!currentTile.topWall.activeInHierarchy && currentTile.GetRow() != playingAreaSize - 1) { topNeighbour = PlayingAreaController.CheckNeighbourConnection(currentRow + 1, currentCol, Direction.Up); if (!CheckIfTileInPath(PlayingAreaController.GetTile(currentRow + 1, currentCol))) { ChangeTileMaterial(topNeighbour, connectedNeighbourMaterial); } else { if (topNeighbour != movingPathTiles[movingPathTiles.Count - 2]) { topNeighbour = null; } } } if (!currentTile.bottomWall.activeInHierarchy && currentTile.GetRow() != 0) { bottomNeighbour = PlayingAreaController.CheckNeighbourConnection(currentRow - 1, currentCol, Direction.Down); if (!CheckIfTileInPath(PlayingAreaController.GetTile(currentRow - 1, currentCol))) { ChangeTileMaterial(bottomNeighbour, connectedNeighbourMaterial); } else { if (bottomNeighbour != movingPathTiles[movingPathTiles.Count - 2]) { bottomNeighbour = null; } } } CheckIfEnoughCoins(); }