示例#1
0
    // Update is called once per frame
    void UpdateEveryMinute()
    {
        if (!inGame)
        {
            return;
        }
        float epochC02      = 0.0f;
        float epochNuclear  = 0.0f;
        float epochPower    = 0.0f;
        float epochWellness = 0.0f;
        float epochMoney    = 0.0f;

        for (int i = 0; i < nTiles; i++)
        {
            HexTile hexTile = tiles[i].GetComponent <HexTile>();
            epochC02      += hexTile.GetC02Polution();
            epochNuclear  += hexTile.GetNuclearWaste();
            epochPower    += hexTile.GetPower();
            epochWellness += hexTile.GetWellness();
            epochMoney    += hexTile.GetMoney();
        }

        // update number of houses
        int population = GetPopulation();
        int popSpace   = numberHouses * 500;

        while (popSpace < population)
        {
            AddHouse();
            popSpace = numberHouses * 500;
        }
        // update money
        // currentMoney += population * 1;
        // Debug.Log(currentMoney);

        epoch++;
        currentMoney -= epochMoney;



        // Update world
        UpdateC02(epochC02);
        UpdateNuclear(epochNuclear);
        UpdatePower(epochPower);
        UpdateWellness(epochWellness);
        gameStatistics.UpdatePanel(1900 + epoch * 10, epochC02, epochNuclear, epochPower, historyWellness[epoch], currentMoney, population, GetPowerDesire());
        //UpdateMoney();

        /*
         *
         */
        // Update plots

        /*
         * plot.UpdateEpoch(epoch);
         * plot.UpdateC02(historyC02);
         * plot.UpdateNuclear(historyNuclear);
         * plot.UpdatePower(historyPower);
         * plot.UpdateWellness(historyWellness);
         *
         * // Update Natural Disasters probability
         * disasters.UpdateEpoch(epoch);
         * disasters.UpdateC02(historyC02);
         * disasters.UpdateNuclear(historyNuclear);
         * disasters.UpdatePower(historyPower);
         * disasters.UpdateWellness(historyWellness);
         */
        buildManager.UpdateEpoch(epoch);

        if (epoch > 14)
        {
            gameOverController.YouWon();
            inGame = false;
        }
        string s = "";

        Debug.Log("len " + historyWellness.Length);

        /*
         * for (int i = 0; i < historyWellness.Length; i++)
         * {
         *  s += historyPower[i]+" , " ;
         * }
         */
        Debug.Log(s);

        /*
         * if(epoch>1)
         * {
         *  windowGraph.ShowGraph(historyWellness, epoch,0,100);
         *  windowGraphPower.ShowGraph(historyPowerPlot, epoch,0,100);
         *  windowGraphCO2.ShowGraph(historyC02Plot, epoch, 0, 100);
         * }*/
    }