Example #1
0
 /// <summary>
 /// Checks for amount of moves and a call to Solutions passing in the gridMap.
 /// if draw, CurrentPlayer set to -1 for UIElement to call the Draw message
 /// </summary>
 /// <returns></returns>
 public bool CheckIfGameEnded()
 {
     if (_movesRecord.movesRecorder.Count > 4 && _solutions.CheckIfGameWon(_gridMap)) // one of the players won.
     {
         _gameEvent.FireEvent("EndGame");
         InitMovesRecorder();
         return(true);
     }
     if (_movesRecord.movesRecorder.Count == _gridMapInit.Length) // draw.
     {
         Players.CurrentPlayer = -1;
         _gameEvent.FireEvent("EndGame");
         InitMovesRecorder();
         return(true);
     }
     return(false);
 }
Example #2
0
    public bool CheckIfGameEnded(MovesRecorder movesRecord, Solutions solutions, Grid[,] gridMap, Grid[] gridMapInit, GameEvent gameEvent)
    {
        var currTurn = Players.CurrentPlayer;

        if (movesRecord.movesRecorder.Count > 4 && solutions.CheckIfGameWon(gridMap)) // one of the players won.
        {
            gameEvent.FireEvent("EndGame");
            Debug.Log("game has ended!, the winner is player" + (currTurn));
            return(true);
        }
        if (movesRecord.movesRecorder.Count == gridMapInit.Length) // draw.
        {
            gameEvent.FireEvent("EndGame");
            Debug.Log("game has ended with a draw!");
            return(true);
        }
        return(false);
    }