private void StartGame() { lock (StartGameLock) { if (Started) { throw new ApplicationException("The game is already started."); } switch (NumberOfPlayers) { case 1: case 2: case 3: GridSize = 1; break; case 4: case 5: case 6: GridSize = 2; break; default: throw new IndexOutOfRangeException($"The games does not support {NumberOfPlayers} playeres."); } NextTurn = new Turn(GridSize); NextTurn.Mode = TurnMode.PlanMoves; NextTurn.IncreaseTurnNumber(); for (int i = 0; i < NumberOfPlayers; i++) { Player player = Players[i]; AddStartingUnitsToTheBoard(player, i, Settings.NumberOfStartingUnits, NumberOfPlayers); player.Ready = false; } } }
public GameState(string currentPlayerColor, Turn currentTurn, Game gameInstance) { CurrentPlayerColor = currentPlayerColor; CurrentTurn = currentTurn; GameInstance = gameInstance; }
public void ResetGame() { PreviousTurn = null; Players = new List<Player>(); GridSize = 1; // Necessary to avoid an error in CanvasSettings.initialize(). NextTurn = new Turn(GridSize); // Necessary to avoid a null reference exception. NextTurn.Mode = TurnMode.StartGame; }