private void ShowOverlayLegend(string title) { ClearLegend(); LegendTitleText.text = "Impact " + title; foreach (KeyValuePair <Color, string> kvp in ImpactLegend) { Legend.Add(kvp.Key, kvp.Value); } foreach (KeyValuePair <Color, string> kvp in Legend) { LegendEntry entry = Instantiate(LegendEntryPrefab, LegendContainer.transform); entry.Init(kvp.Key, kvp.Value); } }
private void DoSetMapDisplayMode(MapDisplayMode mode) { ClearLegend(); // Show region borders in active districts only foreach (Region r in Map.LandRegions) { r.SetShowRegionBorders(Game.VisibleDistricts.ContainsKey(r)); } DisplayMode = mode; switch (mode) { case MapDisplayMode.NoOverlay: LegendTitleText.text = "Districts"; foreach (KeyValuePair <Color, string> kvp in NoOverlayLegend) { Legend.Add(kvp.Key, kvp.Value); } foreach (Region r in Map.LandRegions) { if (Game.VisibleDistricts.ContainsKey(r)) { r.SetColor(ColorManager.Singleton.NoImpactColor); } else { r.SetColor(ColorManager.Singleton.InactiveDistrictColor); } } break; case MapDisplayMode.LastElection: LegendTitleText.text = "Parties"; Legend.Add(ColorManager.Singleton.NoImpactColor, "None"); foreach (Party party in Game.Parties) { Legend.Add(party.Color, party.Acronym); } foreach (Region r in Map.LandRegions) { if (Game.VisibleDistricts.ContainsKey(r)) { Party displayedParty = Game.VisibleDistricts[r].CurrentWinnerParty; if (displayedParty != null) { r.SetColor(displayedParty.Color); } else { r.SetColor(ColorManager.Singleton.NoImpactColor); } } else { r.SetColor(ColorManager.Singleton.InactiveDistrictColor); } } break; case MapDisplayMode.Popularity: PopularityLegend.gameObject.SetActive(true); LegendTitleText.text = "Popularity"; int maxPopularity = 90 + 10 * Game.ElectionCycle; PopularityLegendBotLimitText.text = "- 0"; PopularityLegendTopLimitText.text = "- " + maxPopularity; foreach (Region r in Map.LandRegions) { if (Game.VisibleDistricts.ContainsKey(r)) { int popularity = Game.VisibleDistricts[r].GetPartyPopularity(Game.LocalPlayerParty); float f = popularity / (float)maxPopularity; Mathf.Clamp(f, 0f, 1f); r.SetColor(new Color(1f - f, f, 0f)); } else { r.SetColor(ColorManager.Singleton.InactiveDistrictColor); } } break; case MapDisplayMode.Language: LegendTitleText.text = "Languages"; foreach (Region r in Map.LandRegions) { if (Game.VisibleDistricts.ContainsKey(r)) { string label = EnumHelper.GetDescription(Game.VisibleDistricts[r].Language); HandleLegendEntry(r, label); } else { r.SetColor(ColorManager.Singleton.InactiveDistrictColor); } } break; case MapDisplayMode.Religion: LegendTitleText.text = "Religions"; foreach (Region r in Map.LandRegions) { if (Game.VisibleDistricts.ContainsKey(r)) { string label = EnumHelper.GetDescription(Game.VisibleDistricts[r].Religion); HandleLegendEntry(r, label); } else { r.SetColor(ColorManager.Singleton.InactiveDistrictColor); } } break; case MapDisplayMode.AgeGroup: LegendTitleText.text = "Age Groups"; foreach (Region r in Map.LandRegions) { if (Game.VisibleDistricts.ContainsKey(r)) { string label = EnumHelper.GetDescription(Game.VisibleDistricts[r].AgeGroup); HandleLegendEntry(r, label); } else { r.SetColor(ColorManager.Singleton.InactiveDistrictColor); } } break; case MapDisplayMode.Density: LegendTitleText.text = "Density"; foreach (Region r in Map.LandRegions) { if (Game.VisibleDistricts.ContainsKey(r)) { string label = EnumHelper.GetDescription(Game.VisibleDistricts[r].Density); HandleLegendEntry(r, label); } else { r.SetColor(ColorManager.Singleton.InactiveDistrictColor); } } break; } foreach (KeyValuePair <Color, string> kvp in Legend) { LegendEntry entry = Instantiate(LegendEntryPrefab, LegendContainer.transform); entry.Init(kvp.Key, kvp.Value); } Canvas.ForceUpdateCanvases(); }