private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
Ejemplo n.º 2
0
    public void CmdEndTurn()
    {
        // Update turn index
        GameManager.Instance.turnIndex = GameManager.Instance.GetNextTurnIndex();
        GameManager.Instance.turnCount++;

        // Set next player's state to rolling
        Player nextPlayer = null;

        if (GameManager.Instance.GetTurnCycle() == 2)
        {
            nextPlayer = GameManager.Instance.GetGame().GetPlayerAtIndex(GameManager.Instance.GetGame().players.Count - 1 - GameManager.Instance.turnIndex);
        }
        else
        {
            nextPlayer = GameManager.Instance.GetGame().GetPlayerAtIndex(GameManager.Instance.turnIndex);
        }
        nextPlayer.state = PlayerState.ROLLING;

        // Check if the next player has won the game.
        VictoryPointManager victoryPointManager = VictoryPointManager.Instance;

        if (victoryPointManager.GetVictoryPointsForPlayerId(nextPlayer.GetId()) >= victoryPointManager.victoryPointWinRequirement)
        {
            Debug.Log("A player has won!");
            victoryPointManager.hasSomeoneWon = true;
            victoryPointManager.winnerId      = nextPlayer.GetId();
        }

        // If still within the first two turn cycles, give a free settlement and road to the next player
        if (GameManager.Instance.GetTurnCycle() <= 2)
        {
            nextPlayer.freeRoads++;
            nextPlayer.freeSettlements++;
            nextPlayer.state = PlayerState.SETUP;
        }

        GameManager.Instance.SetDirtyBit(0b11111111);
    }