Пример #1
0
    public void ExpandOilRights()
    {
        ResourceManager rm  = GameObject.FindObjectOfType <ResourceManager>();
        OilSlickManager osm = GameObject.FindObjectOfType <OilSlickManager>();

        (bool, float)affordability = osm.PriceToUnlockNextOilSlick();

        if (rm.AttemptPurchase(affordability.Item2))
        {
            hasGrantedExpandedOilRights = true;
            osm.UnlockOilSlickLevel(osm.CurrentOilSlickLevel + 1);
        }
    }
    // Update is called once per frame
    void Update()
    {
        elapsedTime += Time.deltaTime;
        if (elapsedTime > 1.0f)
        {
            elapsedTime = 0.0f;

            incomeRunningAvg.InsertNewValue(_depositedFunds);
            expensesRunningAvg.InsertNewValue(_withdrawnFunds);

            oilProductionRunningAvg.InsertNewValue(_producedOil);
            oilExportRunningAvg.InsertNewValue(_exportedOil);

            _depositedFunds = 0.0f;
            _withdrawnFunds = 0.0f;

            _producedOil = 0.0f;
            _exportedOil = 0.0f;
        }

        CalculateOilMetrics();
        CalculateMoney();
        CalculateEnvironmentHealth();
        CalculatePublicSentiment();
        CalculateOilStorage();

        if (EnvironmentHealth > 95f && PublicSentiment < 5f)
        {
            TriggerGameLose();
            return;
        }

        if (_oilSlickManager.CurrentOilSlickLevel == OilSlickLevel.Sea3)
        {
            _oilSlickManager.UnlockOilSlickLevel(OilSlickLevel.Sea4);
            _endGameEvent.TriggerEndGame();
        }

        if (HellCity.CurrentOilDemand <= 100)
        {
            TriggerGameWin();
        }
    }