/// <summary> /// Subprogram for the events that occur each month /// </summary> /// <param name="map"></param> public void advanceMonth(Building[,] map) { //Run the disaster check if there is a disaster, and if there is run the disaster map = randomEvents.DisasterChance(map); Residential_Facilities temp = new Residential_Facilities(); //Increase population temp.IncreasePopulation(map); //Calculate new stats CalculateStats(map); //Increase the month month++; //Add the revenue to the money money += revenue; //Remove maintenance costs from the money money -= maintenanceCosts; //If the money is less than 0, set it to 0 if (money < 0) { money = 0; } }
/// <summary> /// Calculates and updates stats /// </summary> /// <param name="map">the current map</param> private void CalculateStats(Building[,] map) { //variable to calculate the pollution int currentPollution = 0; long currentRevenue = 0; long currentMaintenanceCosts = 0; Residential_Facilities temp = new Residential_Facilities(); //Get the power output power = simSpaceTrevor.GetPower(map); //Loop through each index in the map array for (int row = 0; row < map.GetLength(0); row++) { for (int col = 0; col < map.GetLength(1); col++) { //If there is a building at the current index if (map[row, col] != null) { //If the power is greater than 0 if (power > 0) { //Add up the revenue currentRevenue += map[row, col].Revenue; } //Add up the maintenance costs currentMaintenanceCosts += map[row, col].MaintenanceCost; //Add the pollution output currentPollution += map[row, col].PollutionOutput; } } } population = temp.GetTotalPopulation(map); //Set the pollution pollution = currentPollution; //If the pollution is less than 0, set it to 0 if (pollution < 0) { pollution = 0; } //Get the total happiness happyPopulation = temp.GetTotalHappiness(map); //Set the money money += currentRevenue; //Set the revenue revenue = currentRevenue; //Set the maintenance costs maintenanceCosts = currentMaintenanceCosts; score = CalculateScore(); }
/// <summary> /// Build check residential facilities /// </summary> /// <param name="map"></param> /// <returns>new map</returns> public bool[,] BuildCheckResidentialFacilities(Building[,] map) { Residential_Facilities temp = new Residential_Facilities(); return(temp.BuildCheck(map)); }