Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        //keyboardScan();  //no keyboard operation for now

        //This calls 1 time / second
        DateTime now = DateTime.Now;
        TimeSpan s   = now - lastCall;

        if (s.Seconds < 1)
        {
            return;
        }

        lastCall = now;

        resources.UpdateRes();

        double temp = 1;

        switch (Tech.techStatus[1])  //population
        {
        case Tech.LEVEL.L1:
            temp = Constants.PopL1Factor;
            break;

        case Tech.LEVEL.L2:
            temp = Constants.PopL2Factor;
            break;

        case Tech.LEVEL.L3:
            temp = Constants.PopL3Factor;
            break;
        }
        populationRateNum  = 0.01;
        populationRateNum *= temp;
        populationNum     += populationRateNum;

        for (int i = 0; i < 5; i++)
        {
            resourceTracker[i].text = Res.numRes[i].ToString();

            double cRate = Constants.CollectBaseSpeed * Res.numCollector[i] - populationNum * Constants.P_consume_per_s;
            switch (Tech.techStatus[0])
            {
            case Tech.LEVEL.L0:
                break;

            case Tech.LEVEL.L1:
                cRate *= Constants.CollectL1Factor;
                break;

            case Tech.LEVEL.L2:
                cRate *= Constants.CollectL2Factor;
                break;

            case Tech.LEVEL.L3:
                cRate *= Constants.CollectL3Factor;
                break;
            }

            string rateString = cRate + "/s";
            rateTracker[i].text = rateString;
        }


        population.text     = System.String.Format("{0:F2}", populationNum) + "K people"; //2 digit only
        populationRate.text = populationRateNum.ToString() + "K people/s";

        tweakTechButton_Popu_Status();
        techButtonsColor();

        TimeSpan ts = now - techStart;

        if (techStart != DateTime.MinValue && ts.Seconds >= techTimeToWait)
        {
            int    flag = tech.DoResearch(techTypeToResearch, selection);
            string result;
            if (flag == 1)
            {
                result = "Failed: Not Enough Resources";
            }
            else if (flag == 0)
            {
                result = "Succeeded";
            }
            else
            {
                result = "Failed: Wrong Types";
            }
            researchHistory.text = researchString;
            researchResults.text = result;
            techStart            = DateTime.MinValue;
            for (int i = 0; i < 5; i++)
            {
                selection[i] = false;
            }
        }
    }