Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (Globals.gameIsPaused)
        {
            return;
        }

        timePassed += 5;
        if (timePassed % 60 == 0)
        {
            minute++;
            if (minute % 60 == 0)
            {
                minute = 0;
                hour++;
                if (hour % 24 == 0)
                {
                    hour = 0;
                    day++;
                }
            }

            if (minute < 10)
            {
                minStr = "0" + minute;
            }
            else
            {
                minStr = minute.ToString();
            }

            if (hour < 10)
            {
                hourStr = "0" + hour;
            }
            else
            {
                hourStr = hour.ToString();
            }
        }

        dayText.text  = "Day " + day;
        timeText.text = "Time: " + hourStr + ":" + minStr;

        population = houseManager.GetPopulation();
        infected   = houseManager.GetInfected();
        detected   = houseManager.GetDetected();
        recovered  = houseManager.GetRecovered();
        death      = houseManager.GetToll();

        populationText.text = "Population: " + population;
        infectedText.text   = "Infected: " + infected;
        detectedText.text   = "Detected: " + detected;
        recoveredText.text  = "Recovered: " + recovered;
        deathText.text      = "Deaths: " + death;
    }
    // Update is called once per frame
    void Update()
    {
        if (Globals.gameIsPaused)
        {
            return;
        }

        timePassed += 50;
        if (timePassed % 60 == 0)
        {
            minute++;
            if (minute % 60 == 0)
            {
                minute = 0;
                hour++;
                if (hour % 24 == 0)
                {
                    hour = 0;
                    day++;
                }
            }

            if (minute < 10)
            {
                minStr = "0" + minute;
            }
            else
            {
                minStr = minute.ToString();
            }

            if (hour < 10)
            {
                hourStr = "0" + hour;
            }
            else
            {
                hourStr = hour.ToString();
            }
        }

        dayText.text  = "Day " + day;
        timeText.text = "Time: " + hourStr + ":" + minStr;

        population = houseManager.GetPopulation();
        infected   = houseManager.GetInfected();
        detected   = houseManager.GetDetected();
        recovered  = houseManager.GetRecovered();
        death      = houseManager.GetToll();

        populationText.text = "Population: " + population;
        infectedText.text   = "Infected: " + infected;
        detectedText.text   = "Detected: " + detected;
        recoveredText.text  = "Recovered: " + recovered;
        deathText.text      = "Deaths: " + death;

        /*
         * dataVisualizer.addInfection(infected,GetCurTime());
         * dataVisualizer.addInfecti(detected,GetCurTime());
         * dataVisualizer.addInfection(recovered,GetCurTime());
         * dataVisualizer.addInfection(death,GetCurTime());
         */

        if (previousPopulation != population || previousInfected != infected || previousDetected != detected || previousRecovered != recovered || previousDeath != death)
        {
            if (previousInfected != infected)
            {
                infected_rate = GetCurTime();
                //dataVisualizer.addInfection(infected,infected_rate);
            }
            if (previousRecovered != recovered)
            {
                recover_rate = GetCurTime();
                //dataVisualizer.addRecovered(recovered,recover_rate);
            }
            if (previousDetected != detected)
            {
                detected_rate = GetCurTime();
                //dataVisualizer.addRecovered(detected,detected_rate);
            }
            if (previousDeath != death)
            {
                death_rate = GetCurTime();
                //dataVisualizer.addRecovered(death,death_rate);
            }

            using (StreamWriter writePtr = new StreamWriter(path))
            {
                line = line + string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8}\n", population,
                                            infected, detected, recovered, death, GetCurTime(), infected_rate, recover_rate, death_rate);
                writePtr.Write(line);
            }
            previousPopulation = population;
            previousInfected   = infected;
            previousDetected   = detected;
            previousRecovered  = recovered;
            previousDeath      = death;
            //dataVisualizer.presentGraph();
        }
    }