Пример #1
0
    public bool BattleStep()
    {
        //check for win
        if (defender.GetArmies() <= 0)
        {
            WinBattle(true);
            winner = attacker;
            return(true);
        }
        else if (attacker.GetArmies() <= 0)
        {
            WinBattle(false);
            winner = defender;
            return(true);
        }

        //battle logic
        int coinFlip = Random.Range(0, 2);

        if (coinFlip == 0)
        {
            attacker.ArmyLosesBattle();
        }
        else
        {
            defender.ArmyLosesBattle();
        }

        return(false);
    }
Пример #2
0
    public void ResetCounter()
    {
        count    = 0;
        maxCount = 0;

        //set up buttons
        upButton.onClick.RemoveAllListeners();
        downButton.onClick.RemoveAllListeners();
        acceptButton.onClick.RemoveAllListeners();


        upButton.onClick.AddListener(IncreaseCount);
        downButton.onClick.AddListener(DecreaseCount);
        acceptButton.onClick.AddListener(AcceptDeal);

        //get max
        if (pm == null)
        {
            pm = PlayerManager.instance;
        }
        Lord currentLord = pm.currentLord;

        maxCount = currentLord.GetMaxExpand();

        landsGained.text       = 0.ToString();
        armiesAfterExpand.text = currentLord.GetArmies().ToString();
        wealthAfterExpand.text = currentLord.GetWealth().ToString();
    }
Пример #3
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);
    }
Пример #4
0
    public Battle(Lord attacker, Lord defender)
    {
        this.attacker = attacker;
        this.defender = defender;

        if (attacker.GetArmies() <= 0)
        {
            Debug.Log("Attacker with less than 0 Armies Attacking");
        }

        //should make sure attacker has more than 0 armies when attacking
        if (defender.GetArmies() <= 0)
        {
            WinBattle(true);
        }
    }
Пример #5
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);
    }
Пример #6
0
    public void ResetCounter()
    {
        count    = 0;
        maxCount = 0;

        //set up buttons
        upButton.onClick.RemoveAllListeners();
        downButton.onClick.RemoveAllListeners();
        acceptButton.onClick.RemoveAllListeners();


        upButton.onClick.AddListener(IncreaseCount);
        downButton.onClick.AddListener(DecreaseCount);
        acceptButton.onClick.AddListener(AcceptDeal);

        //get max
        if (pm == null)
        {
            pm = PlayerManager.instance;
        }
        Lord currentLord = pm.currentLord;

        switch (counterType)
        {
        case UICounterType.Recruit:
            maxCount = currentLord.GetMaxRecruit();
            break;

        case UICounterType.Expand:
            maxCount = currentLord.GetMaxExpand();
            break;

        case UICounterType.Attack:
            maxCount = currentLord.GetArmies();
            break;
        }
        playerResourceText.text = 0.ToString();

        Debug.Log("Max Count1: " + maxCount);
    }
Пример #7
0
    //STILL NEED TO SET NEXT GAME STATE IN HERE
    private void AcceptDeal()
    {
        Lord currentLord = pm.currentLord;

        switch (counterType)
        {
        case UICounterType.Recruit:
            currentLord.Recruit(count);
            break;

        case UICounterType.Expand:
            currentLord.Expand(count);
            break;

        case UICounterType.Attack:
            maxCount = currentLord.GetArmies();
            break;
        }

        //Go to next step
        //pm.currentGameState = PlayerManager.GameState.EndOfTurn;
    }
Пример #8
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;
        }
    }
Пример #9
0
 private void ResetDefenderMessages()
 {
     defenderName.text    = currentLordSelected.lordName;
     defenderArmies.text  = "Armies:\n" + currentLordSelected.GetArmies();
     defenderMessage.text = "Would Lose:\n" + currentLordSelected.GetLandCount() / 2 + " Land";
 }