public void SetCurrentPlayerTurn(Board.CurrentPlayer currentPlayerTurn) { if (!_isSelected) { _currentPlayerTurn = currentPlayerTurn; } }
private bool HasMatch(int initialRow, int initialColumn, int rowIncrement, int columnIncrement) { Board.CurrentPlayer expectedMatch = _board[initialRow][initialColumn].currentPlayer; if (expectedMatch != Board.CurrentPlayer.PLAYER_INVALID) { int itemsFound = 1; int currentColumn = initialColumn + columnIncrement; int currentRow = initialRow + rowIncrement; while (IsValidPosition(currentColumn) && IsValidPosition(currentRow)) { if (_board[currentRow][currentColumn].currentPlayer != expectedMatch) { return(false); } currentColumn += columnIncrement; currentRow += rowIncrement; ++itemsFound; } if (itemsFound >= BoardSize) { return(true); } } return(false); }
public void OnItemSelected(int instanceId) { UpdateBoard(instanceId); if (HasWinner()) { Debug.Log("Match 3 found!"); } else { _currentTurn = (int)Board.CurrentPlayer.PLAYER_CROSS - _currentTurn; NotifyCurrentTurn(); } }
public BoardPosition(long instanceId) { currentPlayer = Board.CurrentPlayer.PLAYER_INVALID; gameObjectInstanceId = instanceId; }