Esempio n. 1
0
    private void WinBattle(bool attackerWon)
    {
        if (attackerWon)
        {
            int landTaken = (defender.GetLandCount()) / 2;

            attacker.SetLand(attacker.GetLandCount() + landTaken);
            defender.SetLand(defender.GetLandCount() - landTaken);
        }
        else
        {
            int landTaken = (attacker.GetLandCount()) / 2;

            attacker.SetLand(attacker.GetLandCount() - landTaken);
            defender.SetLand(defender.GetLandCount() + landTaken);
        }
    }
Esempio n. 2
0
    public void AcceptTradeOffer()
    {
        Debug.Log(offerResourceDropdown.captionText.text);

        //trade the goods
        Lord offerLord = pm.currentLord;

        //handles offer exchange
        if (offerResourceDropdown.captionText.text == "Wealth")
        {
            offerLord.SetWealth(offerLord.GetWealth() - offerAmountDropdown.value + 1);
            lordToOfferTrade.SetWealth(lordToOfferTrade.GetWealth() + offerAmountDropdown.value - 1);
        }
        else if (offerResourceDropdown.captionText.text == "Land")
        {
            offerLord.SetLand(offerLord.GetLandCount() - offerAmountDropdown.value + 1);
            lordToOfferTrade.SetLand(lordToOfferTrade.GetLandCount() + offerAmountDropdown.value - 1);
        }
        else if (offerResourceDropdown.captionText.text == "Armies")
        {
            offerLord.SetArmies(offerLord.GetArmies() - offerAmountDropdown.value + 1);
            lordToOfferTrade.SetArmies(lordToOfferTrade.GetArmies() + offerAmountDropdown.value - 1);
        }

        //handles receive exchange
        if (receiveResourceDropdown.captionText.text == "Wealth")
        {
            lordToOfferTrade.SetWealth(lordToOfferTrade.GetWealth() - receiveAmountDropdown.value + 1);
            offerLord.SetWealth(offerLord.GetWealth() + receiveAmountDropdown.value - 1);
        }
        else if (receiveResourceDropdown.captionText.text == "Land")
        {
            lordToOfferTrade.SetLand(lordToOfferTrade.GetLandCount() - receiveAmountDropdown.value + 1);
            offerLord.SetLand(offerLord.GetLandCount() + receiveAmountDropdown.value - 1);
        }
        else if (receiveResourceDropdown.captionText.text == "Armies")
        {
            lordToOfferTrade.SetArmies(lordToOfferTrade.GetArmies() - receiveAmountDropdown.value + 1);
            offerLord.SetArmies(offerLord.GetArmies() + receiveAmountDropdown.value - 1);
        }

        acceptTradeOfferScreen.SetActive(false);
    }
Esempio n. 3
0
    private void FillResourcesDropdown(Lord lord, TMP_Dropdown resourceDropdown)
    {
        List <string> resources = new List <string>();

        if (lord.GetArmies() > 0)
        {
            resources.Add("Armies");
        }
        if (lord.GetLandCount() > 0)
        {
            resources.Add("Land");
        }
        if (lord.GetWealth() > 0)
        {
            resources.Add("Wealth");
        }
        resourceDropdown.ClearOptions();
        resourceDropdown.AddOptions(resources);
    }
Esempio n. 4
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;
        }
    }
Esempio n. 5
0
 private void ResetDefenderMessages()
 {
     defenderName.text    = currentLordSelected.lordName;
     defenderArmies.text  = "Armies:\n" + currentLordSelected.GetArmies();
     defenderMessage.text = "Would Lose:\n" + currentLordSelected.GetLandCount() / 2 + " Land";
 }