Exemplo n.º 1
0
    public void AddToHistory(System.DateTime date, CityResources avgDailyResources, CityFinances avgDailyFinances)
    {
        if (history.Count >= maxHistory)
        {
            history.RemoveAt(0);
        }

        history.Add(new TimePoint(date, avgDailyResources, avgDailyFinances));
    }
Exemplo n.º 2
0
    public void UpdateHistory(System.DateTime date)
    {
        //Divide the sum by the amounts added to get the average
        CityResources averageDailyResources = dailySumResources / (float)helperCounter;
        CityFinances  averageDailyFinances  = dailySumFinances / (float)helperCounter;

        //Add to history
        resourceHistory.AddToHistory(date, averageDailyResources, averageDailyFinances);

        //reset the averages objects and counter
        dailySumResources = new CityResources();
        dailySumFinances  = new CityFinances();
        helperCounter     = 0;
    }
Exemplo n.º 3
0
    public static CityResources operator/(CityResources res, float denominator)
    {
        CityResources result = new CityResources();

        result.powerDemand                  = res.powerDemand / denominator;
        result.powerConsumption             = res.powerConsumption / denominator;
        result.totalAvailablePower          = res.totalAvailablePower / denominator;
        result.waterDemand                  = res.waterDemand / denominator;
        result.waterConsumption             = res.waterConsumption / denominator;
        result.totalAvailableWaterSupply    = res.totalAvailableWaterSupply / denominator;
        result.studentsCount                = (uint)Mathf.RoundToInt((float)res.studentsCount / denominator);
        result.totalAvailableEducationSeats = (uint)Mathf.RoundToInt((float)res.totalAvailableEducationSeats / denominator);
        result.filledHospitalBeds           = (uint)Mathf.RoundToInt((float)res.filledHospitalBeds / denominator);
        result.totalAvailableHospitalBeds   = (uint)Mathf.RoundToInt((float)res.totalAvailableHospitalBeds / denominator);

        result.totalHousingSlots     = res.totalHousingSlots / denominator;
        result.occuppiedHousingSlots = res.occuppiedHousingSlots / denominator;

        return(result);
    }
Exemplo n.º 4
0
    public static CityResources operator+(CityResources res1, CityResources res2)
    {
        CityResources sum = new CityResources();

        sum.powerDemand                  = res1.powerDemand + res2.powerDemand;
        sum.powerConsumption             = res1.powerConsumption + res2.powerConsumption;
        sum.totalAvailablePower          = res1.totalAvailablePower + res2.totalAvailablePower;
        sum.waterDemand                  = res1.waterDemand + res2.waterDemand;
        sum.waterConsumption             = res1.waterConsumption + res2.waterConsumption;
        sum.totalAvailableWaterSupply    = res1.totalAvailableWaterSupply + res2.totalAvailableWaterSupply;
        sum.studentsCount                = res1.studentsCount + res2.studentsCount;
        sum.totalAvailableEducationSeats = res1.totalAvailableEducationSeats + res2.totalAvailableEducationSeats;
        sum.filledHospitalBeds           = res1.filledHospitalBeds + res2.filledHospitalBeds;
        sum.totalAvailableHospitalBeds   = res1.totalAvailableHospitalBeds + res2.totalAvailableHospitalBeds;

        sum.totalHousingSlots     = res1.totalHousingSlots + res2.totalHousingSlots;
        sum.occuppiedHousingSlots = res1.occuppiedHousingSlots + res2.occuppiedHousingSlots;

        return(sum);
    }
Exemplo n.º 5
0
 public TimePoint(System.DateTime _date, CityResources _resources, CityFinances _finances)
 {
     date      = _date;
     resources = _resources;
     finances  = _finances;
 }
Exemplo n.º 6
0
    //TODO while CityResources change over the course of the day, the majority of CityFinances (as of July, 3rd implementation) are the same per day, difference is in the treasury
    //only (which could change due to player paying for constructions, etc). The current implementation in TimeProgress() and UpdateHistory() has some redundant calculations.
    //For now, leaving it as is, as there *might* be additional variables in the future in CityFinances that are are updated hourly. If that didn't turn out to be the case, this
    //is a venue for some cleanup and optimization (for prolly statistically insignificant gains, but still).

    public void TimeProgress(int hours)
    {
        dailySumResources += resources;
        dailySumFinances  += finances;
        helperCounter++;
    }