/// <summary> /// /// </summary> /// <param name="spot"></param> /// <param name="updateText"></param> /// <param name="statuses"></param> /// <param name="colors"></param> /// <returns></returns> public int ProcessStatus(BuildingSpot spot, bool updateText, ref List <string> statuses, ref List <Color> colors) { if (updateText) { foreach (Text text in statusTexts) { text.text = ""; } overviewAlert.SetActive(false); productionAlert.SetActive(false); projectAlert.SetActive(false); maintenanceAlert.SetActive(false); } if (!spot.Built) { if (spot.constructionHalted) { ProcessIndividualStatus("Construction stopped", GM.I.art.red, overviewAlert, ref statuses, ref colors, updateText); } else { ProcessIndividualStatus("Under construction", GM.I.art.light, null, ref statuses, ref colors, updateText); } } else { if (spot.Cost.Limited(GM.I.resource.resources)) { ProcessIndividualStatus("Not enough resources!", GM.I.art.red, maintenanceAlert, ref statuses, ref colors, updateText); } if (spot.maintenance) { ProcessIndividualStatus("Under maintenance", GM.I.art.light, maintenanceAlert, ref statuses, ref colors, updateText); } else if (spot.DangerousIntegrity) { ProcessIndividualStatus("Needs maintenance!", GM.I.art.red, maintenanceAlert, ref statuses, ref colors, updateText); } else if (spot.BadIntegrity) { ProcessIndividualStatus("Needs maintenance", GM.I.art.orange, maintenanceAlert, ref statuses, ref colors, updateText); } if (spot.currentBuilding.housing) { if (spot.OverPopulated) { ProcessIndividualStatus("Overpopulated!", GM.I.art.red, overviewAlert, ref statuses, ref colors, updateText); } else if (spot.HighPopulated) { ProcessIndividualStatus("Crowded!", GM.I.art.orange, overviewAlert, ref statuses, ref colors, updateText); } } if (spot.currentBuilding.productor) { if (!spot.producing) { ProcessIndividualStatus("Production stopped", GM.I.art.light, productionAlert, ref statuses, ref colors, updateText); } else if (!spot.maintenance) { if (spot.LowPopulated) { ProcessIndividualStatus("Not enough workers", GM.I.art.orange, productionAlert, ref statuses, ref colors, updateText); } if (spot.storage == spot.ResourcePortion()) { ProcessIndividualStatus("Storage full", GM.I.art.light, productionAlert, ref statuses, ref colors, updateText); } } } if (spot.currentBuilding.research) { if (spot.currentProject == null) { ProcessIndividualStatus("Needs a project", GM.I.art.pink, projectAlert, ref statuses, ref colors, updateText); } } } if (statuses.Count == 0) { ProcessIndividualStatus("Working correctly", GM.I.art.green, null, ref statuses, ref colors, updateText); } int statusNumber = 0; for (int i = 0; i < statusTexts.Count; i++) { if (i < statuses.Count) { if (updateText) { statusTexts[i].text = statuses[i]; statusTexts[i].color = colors[i]; } if (colors[i] == GM.I.art.red) { statusNumber = 4; } if (colors[i] == GM.I.art.orange && statusNumber <= 2) { statusNumber = 3; } if (colors[i] == GM.I.art.pink && statusNumber <= 1) { statusNumber = 2; } if (colors[i] == GM.I.art.light && statusNumber == 0) { statusNumber = 1; } } } return(statusNumber); }
/// <summary> /// Updates the information for a specific building spot /// </summary> /// <param name="spot">The building spot that you want to update</param> public void UpdateMenuInfo(BuildingSpot spot) { buildingImage.sprite = spot.currentBuilding.sprite; buildingName.text = spot.currentBuilding.buildingName + " " + spot.district; Color populationColor = spot.OverPopulated ? GM.I.art.red : GM.I.art.white; populationName.text = spot.currentBuilding.populationName; populationText.text = UIManager.ColoredString(UIManager.HumanNotation(spot.population), populationColor) + " / " + UIManager.HumanNotation(spot.currentBuilding.populationRequirement); overviewMenu.SetActive(overviewToggle.isOn); productionMenu.SetActive(productionToggle.isOn); maintenanceMenu.SetActive(maintenanceToggle.isOn); productionToggle.gameObject.SetActive(spot.currentBuilding.productor); projectToggle.gameObject.SetActive(spot.currentBuilding.research); maintenanceToggle.gameObject.SetActive(true); if (projectToggle.isOn) { UpdateProject(); } else { projectDetail.SetActive(false); projectMenu.SetActive(false); } costInfo.text = spot.currentBuilding.costInfo; shortageEffect.text = spot.Cost.Limited(GM.I.resource.resources)? spot.currentBuilding.shortageEffect:""; integrity.SetActive(spot.Built && !spot.currentBuilding.control); buildDate.text = "Built in " + UIManager.TimeToDate(spot.constructionDate); integrityMeterText.text = UIManager.HumanNotation(spot.integrity); maintenanceEffecText.text = spot.currentBuilding.maintenanceEffect; integrityMeter.fillAmount = spot.integrity; if (spot.BadIntegrity) { integrityMeter.color = GM.I.art.orange; integrityRiskText.color = GM.I.art.orange; integrityRiskText.text = "FAILURE RISK - MEDIUM"; } else if (spot.DangerousIntegrity) { integrityMeter.color = GM.I.art.red; integrityRiskText.color = GM.I.art.red; integrityRiskText.text = "FAILURE RISK - HIGH"; } else { integrityMeter.color = GM.I.art.light; integrityRiskText.color = GM.I.art.light; integrityRiskText.text = "FAILURE RISK - LOW"; } monthlyProduction.UpdateRessourceBox(spot.Production); monthlyCost.UpdateRessourceBox(spot.Cost); storage.text = (int)spot.ResourcePortion() + " / " + spot.storage; storageBar.fillAmount = spot.ResourcePortion() / spot.storage; storageBar.color = spot.currentBuilding.color; storageOutline.color = spot.currentBuilding.color; increaseStorageButton.SetActive(!(spot.increaseStorage || spot.storage == spot.storageMax)); stopStorageButton.SetActive(!(!spot.increaseStorage || spot.storage == spot.storageMax)); increaseStorageCost.gameObject.SetActive(spot.storage != spot.storageMax); increaseStorageTime.gameObject.SetActive(spot.storage != spot.storageMax); increaseStorageCost.UpdateRessourceBox(spot.currentBuilding.storageIncreaseMonthlyCost); increaseStorageTime.text = spot.storageCounter + " months"; StartMaintenance(spot.maintenance); StopProduction(!spot.producing); ProcessStatus(spot, true); for (int i = 0; i < spot.currentBuilding.projects.Count; i++) { Project project = spot.currentBuilding.projects[i]; projectChoices[i].Init(project, spot); } if (spot.currentBuilding.control) { destroyButton.SetActive(false); } if (!overviewToggle.isOn) { DestroyMenu(false); } }