Esempio n. 1
0
    private void Update()
    {
        switch (currentGameState)
        {
        case GameState.StartOfTurn:
            iconHandler.UpdatePlayerIcons();
            //Check if win
            if (currentLord.GetLandCount() <= 0 && currentLord.GetArmies() <= 0 && currentLord.GetWealth() <= 0)
            {
                //go to next lord, this lord is out
                JumpToNextLord();
            }
            else if (currentLord.GetLandCount() >= 5)
            {
                //WIN
                Debug.Log(currentLord.lordName + " won the round!");
                currentGameState = GameState.RoundOver;
            }
            else
            {
                currentGameState = GameState.PlayerIncome;
            }

            break;

        case GameState.PlayerIncome:
            soundsSource.PlayOneShot(coinSound);
            currentLord.ReceiveIncome();
            currentLord.SpendToMaintainArmies();
            currentGameState = GameState.PlayerChoosingAction;
            break;

        case GameState.PlayerChoosingAction:

            if (currentLord is AILord)
            {
                //do random AI thing
                ((AILord)currentLord).TakeRandomAction();
            }
            //Otherwise, do nothing as it is handled by the UI
            break;

        case GameState.PlayerDecidingTrades:
            //Do nothing, this is handled by the UI
            break;

        case GameState.PlayerSpecifyingTrade:

            break;

        case GameState.EndOfTurn:
            //print current lord
            currentLord.PrintLord();

            JumpToNextLord();

            currentGameState = GameState.StartOfTurn;
            break;

        case GameState.RoundOver:
            //check winner -> currentPlayer
            currentLord.IncreaseKingPoints();

            //Make sure old king does not persist
            foreach (Player player in players)
            {
                if (player != currentLord && player.IsKing())
                {
                    player.RemoveKingStatus();
                }
            }

            //check if current player has won the game
            if (currentLord.GetKingPoints() > kingPointsToWin)
            {
                //Win the game
                mainOptionScreen.SetActive(false);
                gameVictoryScreen.SetActive(true);
                currentGameState = GameState.GameOver;

                //Set text
                gameVictoryMessage.text = currentLord.lordName + " has become legend!";
            }
            else
            {
                //Round Won
                mainOptionScreen.SetActive(false);
                roundVictoryScreen.SetActive(true);
                currentGameState = GameState.EndOfTurn;

                //set text
                roundVictoryMessage.text = currentLord.lordName + " has become king!";
            }

            break;

        case GameState.GameOver:

            Debug.Log(currentLord.lordName + " has won the game!");
            break;
        }
    }