예제 #1
0
        public void SetMapDisplayMode(MapDisplayMode mode)
        {
            int newValue = (int)mode;

            if (newValue == OverlayDropdown.value)
            {
                RefreshMapDisplay();
            }
            else
            {
                OverlayDropdown.value = (int)mode;
            }
        }
    public void DrawMap(LandmassMap map, MapDisplayMode displayMode)
    {
        CheckRefs();

        // Store values
        Map = map;

        // If display mode is a texture type
        if (DisplayModeIsTextureType(displayMode))
        {
            // Init vars
            Texture2D texture;

            // Generate texture
            switch (displayMode)
            {
            case MapDisplayMode.Noise:
                texture = TextureGenerator.NewHeightMap(map.Width, map.Height, map.NoiseMap);
                break;

            case MapDisplayMode.Colour:
                texture = TextureGenerator.NewColourMap(map.Width, map.Height, map.ColourMap);
                break;

            default: goto case MapDisplayMode.Noise;
            }

            // Apply texture
            textureRenderer.sharedMaterial.mainTexture = texture;
        }
        // If display mode is a mesh type
        else if (displayMode == MapDisplayMode.Mesh)
        {
            // Generate data
            var meshData = MeshGenerator.GenerateTerrianMesh(map.NoiseMap, map.MeshHeighMultiplier, map.MeshHeightCurve, map.LOD);
            var texture  = TextureGenerator.NewColourMap(map.Width, map.Height, map.ColourMap);

            // Apply data
            meshFilter.sharedMesh = meshData.ToMesh();
            meshRenderer.sharedMaterial.mainTexture = texture;
        }
        else
        {
            // Display mode is invalid
            throw new InvalidStateException("Display mode cannot be " + displayMode.ToString()
                                            + " as no display option is configured for this state");
        }
        transform.localScale = new Vector3(map.Width, (map.Width + map.Height) / 2, map.Height);
    }
예제 #3
0
        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();
        }
예제 #4
0
 public void Init(ElectionTacticsGame game, MapDisplayMode mode)
 {
     Game = game;
     Map  = game.Map;
     SetMapDisplayMode(mode);
 }
 private bool DisplayModeIsTextureType(MapDisplayMode displayMode)
 {
     return
         (displayMode == MapDisplayMode.Colour ||
          displayMode == MapDisplayMode.Noise);
 }