Пример #1
0
    public void goToNextYear()
    {
        paused     = true;
        taxChanged = false;
        cameraMove.moveDown();
        statsUI.setActive(false);
        resourceUI.setActive(false);
        tradesLeft = originalTrades;

        canvas.GetComponent <ConfirmSaleMenu>().warningText.SetActive(false);
        canvas.GetComponent <ConfirmSaleMenu>().noGoldText.SetActive(false);
        canvas.GetComponent <ConfirmSaleMenu>().resetTradeSliders();
        // just incase. ^

        canvas.GetComponent <Transition>().fadeOut();

        float oldGold     = gold;
        float soldierCost = (soldierCount * soldierExpense);

        if (ownsBarracks)
        {
            soldierCost = ((soldierCost / 100) * 90);
        }

        yearlyExpenses += soldierCost;

        generateGoodPrices();
        resourceUI.updateResources();
        resourceUI.updateResourceText();
        yearlyExpenses += resourceUI.loadGoodsExpenses();

        gold -= yearlyExpenses;
        gold += calculateTaxReturns();
        updateHappiness();

        if (plague)
        {
            soldierStrength += ((soldierStrength / 100) * 10);
            plague           = false;
        }

        if (drought)
        {
            soldierStrength += ((soldierStrength / 100) * 50);
            drought          = false;
        }

        if (gold < 0)
        {
            happiness -= 15;
        }

        if (isAtWar)
        {
            happiness -= Random.Range(5, 10);
        }

        if (happiness < 0)
        {
            happiness = 0;
        }

        population += (int)(happiness / happinessPopulationModifier * populationModifier);

        if (happiness <= 5)
        {
            population -= ((population / 100) * Random.Range(10, 20)); // lose 15% of your population
        }

        GetComponent <Raiding>().setButtonInteractable();

        canvas.GetComponent <YearlyUI>().updateUI(oldGold);
        checkRelations();

        year++;

        if (year >= gracePeriodYear)
        {
            gracePeriod = true;
        }

        StartCoroutine(showUI());
        secondsBetweenYears = originalSeconds;

        DataHandler.save(this);
    }