Exemplo n.º 1
0
    public void onClick(string k)
    {
        GameManager.Kingdom kingdom = (GameManager.Kingdom)Enum.Parse(typeof(GameManager.Kingdom), k);

        spoils.SetActive(true);
        raidObject.SetActive(false);
        actionMenu.setTask(true);
        actionMenu.openObjects.Remove(raidObject);
        actionMenu.openObjects.Add(spoils);

        int wood      = UnityEngine.Random.Range(40, 70);
        int stone     = UnityEngine.Random.Range(30, 50);
        int leather   = UnityEngine.Random.Range(10, 20);
        int gold      = UnityEngine.Random.Range(200, 350);
        int relations = UnityEngine.Random.Range(20, 35);

        // make each random number relate to each kingdoms specific resources

        int failChance = 65 + ((int)(gameManager.soldierStrength - 1) * 100) + (int)((gameManager.soldierCount / 100) * 2);
        // so soldier strength helps raid chances

        int roll = UnityEngine.Random.Range(1, 100);

        gameManager.decreaseRelations(kingdom, relations);
        int modifier = UnityEngine.Random.Range(3, 7);

        gameManager.soldierCount -= ((gameManager.soldierCount / 100) * modifier);
        relationText.text         = "(-" + relations + " relations with " + kingdom.ToString() + ")";

        if (gameManager.getRelations(kingdom) <= 10)
        {
            gameManager.setAtWar(kingdom);
            gameManager.isAtWar = true;

            warTextObj.SetActive(true);
            warText.text = "You are now at war with " + kingdom + ".";
        }

        if (roll >= failChance)
        {
            setIconStatus(false);
            title.text = "Defeat!";
            failed     = true;

            return;
        }

        gameManager.gold    += gold;
        gameManager.wood    += wood;
        gameManager.stone   += stone;
        gameManager.leather += leather;

        canvas.GetComponent <ResourceUI>().updateResourceText();

        woodText.text    = wood.ToString();
        stoneText.text   = stone.ToString();
        leatherText.text = leather.ToString();
        coinText.text    = gold.ToString();
    }
Exemplo n.º 2
0
    public void updateRelationsText(GameManager.Kingdom k)
    {
        if (tradingTextUpdater == null)
        {
            tradingTextUpdater = GetComponent <TradingTextUpdater>();
        }

        tradingTextUpdater.updateText(k);
    }
Exemplo n.º 3
0
    public void updatePrices(GameManager.Kingdom k)
    {
        if (tradingTextUpdater == null)
        {
            tradingTextUpdater = GetComponent <TradingTextUpdater>();
        }

        tradingTextUpdater.updatePrice(k);
    }
    public void updateText(GameManager.Kingdom kingdom)
    {
        if (gameManager == null)
        {
            gameManager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>();
        }

        relations.text   = gameManager.getRelations(kingdom) + "%";
        tradeStatus.text = gameManager.getTradeStatus(kingdom);
    }
Exemplo n.º 5
0
    public void openSaleMenu(GameManager.Kingdom kingdom)
    {
        gameManager.currentlyBuyingFrom = kingdom.ToString();
        canvas.GetComponent <ConfirmSaleMenu>().setMaxValues(kingdom);
        confirmSale.SetActive(true);
        infoTextConfirm.text = "You are currently trading with " + kingdom.ToString() + ".";
        int woodCost    = gameManager.getCost(GameManager.Type.Wood, kingdom);
        int stoneCost   = gameManager.getCost(GameManager.Type.Stone, kingdom);
        int leatherCost = gameManager.getCost(GameManager.Type.Leather, kingdom);

        relationNo.text = gameManager.getRelations(kingdom) + "%";
    }
Exemplo n.º 6
0
    private int getSliderValue(Slider s, bool buy)
    {
        GameManager.Kingdom kingdom          = (GameManager.Kingdom)Enum.Parse(typeof(GameManager.Kingdom), gameManager.currentlyBuyingFrom);
        SliderTextUpdate    sliderTextUpdate = s.GetComponentInParent <SliderTextUpdate>();

        int max = s.GetComponentInParent <SliderTextUpdate>().max;

        if (buy)
        {
            return((int)s.value * gameManager.getCost(sliderTextUpdate.itemType, kingdom));
        }
        else
        {
            return(gameManager.getCost(sliderTextUpdate.itemType, kingdom) * (int)s.value);
        }
    }
Exemplo n.º 7
0
    public void setMaxValues(GameManager.Kingdom kingdom)
    {
        Slider b1, b2, b3, s1, s2, s3;

        b1 = buy1.GetComponentInChildren <Slider>();
        b2 = buy2.GetComponentInChildren <Slider>();
        b3 = buy3.GetComponentInChildren <Slider>();
        s1 = sell1.GetComponentInChildren <Slider>();
        s2 = sell2.GetComponentInChildren <Slider>();
        s3 = sell3.GetComponentInChildren <Slider>();

        b1.maxValue = gameManager.getMaxGoods(GameManager.Type.Wood, kingdom);
        b2.maxValue = gameManager.getMaxGoods(GameManager.Type.Stone, kingdom);
        b3.maxValue = gameManager.getMaxGoods(GameManager.Type.Leather, kingdom);
        s1.maxValue = gameManager.getMaxPlayerGoods(GameManager.Type.Wood);
        s2.maxValue = gameManager.getMaxPlayerGoods(GameManager.Type.Stone);
        s3.maxValue = gameManager.getMaxPlayerGoods(GameManager.Type.Leather);
    }
Exemplo n.º 8
0
    private void Start()
    {
        gameManager = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>();

        if (trade)
        {
            GameManager.Kingdom kingdom = (GameManager.Kingdom)Enum.Parse(typeof(GameManager.Kingdom), gameManager.currentlyBuyingFrom);

            if (buying)
            {
                max = gameManager.getMaxGoods(itemType, kingdom);
            }
            else
            {
                max = gameManager.getMaxPlayerGoods(itemType);
            }

            slider.maxValue = max;
        }
    }
Exemplo n.º 9
0
    public void onSliderChange()
    {
        GameManager.Kingdom kingdom = (GameManager.Kingdom)Enum.Parse(typeof(GameManager.Kingdom), gameManager.currentlyBuyingFrom);

        if (buying)
        {
            Slider buyS1, buyS2, buyS3;

            buyS1 = buy1.GetComponentInChildren <Slider>();
            buyS2 = buy2.GetComponentInChildren <Slider>();
            buyS3 = buy3.GetComponentInChildren <Slider>();

            int c       = getSliderValue(buyS1, true) + getSliderValue(buyS2, true) + getSliderValue(buyS3, true);
            int percent = ((c / 100) * gameManager.taxFromTrade);

            if (gameManager.getTradeStatus(kingdom) == "Taxed Goods")
            {
                c += percent;
            }

            costText.text = "Cost: " + c;
        }
        else
        {
            Slider sellS1, sellS2, sellS3;

            sellS1 = sell1.GetComponentInChildren <Slider>();
            sellS2 = sell2.GetComponentInChildren <Slider>();
            sellS3 = sell3.GetComponentInChildren <Slider>();

            int i       = getSliderValue(sellS1, false) + getSliderValue(sellS2, false) + getSliderValue(sellS3, false);
            int percent = ((i / 100) * gameManager.taxFromTrade);

            if (gameManager.getTradeStatus(kingdom) == "Taxed Goods")
            {
                i -= percent;
            }

            incomeText.text = "Income: " + i;
        }
    }
Exemplo n.º 10
0
    public void updateRelationText(GameManager.Kingdom kingdom)
    {
        switch (kingdom)
        {
        case GameManager.Kingdom.Rym:
            relationRym.text = gameManager.getRelations(kingdom) + "%";
            break;

        case GameManager.Kingdom.Galerd:
            relationGalerd.text = gameManager.getRelations(kingdom) + "%";
            break;

        case GameManager.Kingdom.Cobeth:
            relationCobeth.text = gameManager.getRelations(kingdom) + "%";
            break;

        case GameManager.Kingdom.Jalonn:
            relationJalonn.text = gameManager.getRelations(kingdom) + "%";
            break;
        }
    }
Exemplo n.º 11
0
    public void onConfirmBuy()
    {
        if (gameManager.tradesLeft == 0)
        {
            warningText.SetActive(true);
            return;
        }

        if (buying)
        {
            if (costText.text == "Cost: 0")
            {
                return;
            }

            int cost = int.Parse(costText.text.Split(':')[1]);

            if (cost > gameManager.gold)
            {
                noGoldText.SetActive(true);
                return;
            }

            gameManager.gold -= cost;
            int woodAmount    = getSliderCount(buy1);
            int stoneAmount   = getSliderCount(buy2);
            int leatherAmount = getSliderCount(buy3);

            gameManager.wood    += woodAmount;
            gameManager.stone   += stoneAmount;
            gameManager.leather += leatherAmount;
        }
        else
        {
            if (incomeText.text == "Income: 0")
            {
                return;
            }

            int income = int.Parse(incomeText.text.Split(':')[1]);

            gameManager.gold += income;
            int woodAmount    = getSliderCount(sell1);
            int stoneAmount   = getSliderCount(sell2);
            int leatherAmount = getSliderCount(sell3);

            gameManager.wood    -= woodAmount;
            gameManager.stone   -= stoneAmount;
            gameManager.leather -= leatherAmount;
        }

        gameManager.tradesLeft -= 1;
        GameManager.Kingdom kingdom = (GameManager.Kingdom)Enum.Parse(typeof(GameManager.Kingdom), gameManager.currentlyBuyingFrom);
        canvas.GetComponent <ResourceUI>().updateResourceText();
        gameManager.increaseRelations(kingdom, UnityEngine.Random.Range(minRelationBoost, maxRelationBoost));
        updateRelationText(kingdom);

        if (buying)
        {
            coverSell.SetActive(false);
        }
        else
        {
            coverBuy.SetActive(false);
        }

        resetTradeSliders();
        costText.text  = "Cost: 0";
        dropdown.value = 0;
        coverSell.SetActive(true);
        incomeText.text = "Income: 0";

        confirmSale.SetActive(false);
        actionMenu.openObjects.Remove(confirmSale);
        actionMenu.active               = false;
        actionMenu.taskOpen             = false;
        gameManager.currentlyBuyingFrom = "";
    }
Exemplo n.º 12
0
    public void onClick(string k)
    {
        GameManager.Kingdom kingdom = (GameManager.Kingdom)Enum.Parse(typeof(GameManager.Kingdom), k);
        gameManager.setAtWar(kingdom);

        int chance = -10;

        gameManager.invadePause = true;

        float modifier = gameManager.soldierCount;

        modifier = (gameManager.soldierCount * gameManager.soldierStrength);

        chance += (int)((modifier / 100) * invadeModifier);
        int roll = UnityEngine.Random.Range(1, 100);

        invade.SetActive(false);

        if (chance >= roll)
        {
            gameManager.puppetStates++;

            if (gameManager.puppetStates != 4)
            {
                invadeSuccess.SetActive(true);
            }
            gameManager.conqueredStatus[kingdom] = true;
            gameManager.warStatus[kingdom]       = false;

            textS.text = "Your forces have stormed the keep of " + kingdom.ToString() + ", and have taken the land. Your subjects congratulate you on your victory. " +
                         "There is a cost in victory though, as you have lost good men to claim these lands.";

            bool war = false;

            foreach (GameManager.Kingdom kin in gameManager.warStatus.Keys)
            {
                if (gameManager.warStatus[kin])
                {
                    war = true;
                }
            }

            if (!war)
            {
                gameManager.isAtWar = false;
            }

            float loss = ((gameManager.soldierCount / 100) * UnityEngine.Random.Range(30, 55));

            if (gameManager.ownsGarrison || gameManager.ownsBarracks)
            {
                loss -= (loss * ((gameManager.soldierStrength - 1)));
            }

            gameManager.soldierCount -= loss;
        }
        else
        {
            invadeFail.SetActive(true);
            textF.text = "Your forces were unable to overcome " + kingdom.ToString() + " 's defenses. You have lost a large majority of soldiers, and your people's happiness has dropped.";
            gameManager.soldierCount = ((gameManager.soldierCount / 100) * UnityEngine.Random.Range(15, 25)); // keep 15 to 25%
            gameManager.decreaseRelations(kingdom, 100);
        }

        if (tradeListener == null)
        {
            tradeListener = GameObject.FindGameObjectWithTag("Canvas").transform.Find("Trade").GetComponentInChildren <TradeListener>();
        }

        tradeListener.updateRelationsText(kingdom);
        gameManager.updateTradeStatus(kingdom);

        if (gameManager.puppetStates == 4)
        {
            gameManager.won = true;
            win.SetActive(true);
            actionMenu.setTask(true);
            actionMenu.openObjects.Add(win);
        }
    }
Exemplo n.º 13
0
 public void updatePrice(GameManager.Kingdom kingdom)
 {
     woodCost.text    = gameManager.getCost(GameManager.Type.Wood, kingdom).ToString();
     stoneCost.text   = gameManager.getCost(GameManager.Type.Stone, kingdom).ToString();
     leatherCost.text = gameManager.getCost(GameManager.Type.Leather, kingdom).ToString();
 }