void BuildWorld() { CalculateContinentTerritory(); int tile = MapMetrics.Tile; MapMesh.regionIndex = regionIndex; MapMesh.regions = regions; for (int i = 0; i < h; i += tile) { for (int j = 0; j < w; j += tile) { MapMesh mapMesh = Instantiate(mapMeshPrefab); MapMeshes.Add(mapMesh); mapMesh.TriangulateMap(j, i); mapMesh.transform.localPosition = Vector3.zero; } } SetProvNames(); SetTowns(); foreach (var state in states) { state.Text = Instantiate(Text); state.Text.layer = 8; state.SetName(); state.SetNameStatus(true); Region cap = state.Capital; cap.Corona = Instantiate(CoronaPrefab, cap.Town.transform); cap.Corona.transform.localPosition = Vector3.up * 0.8f; } for (int i = 0; i < regions.Count; i++) { regions[i].UpdateBorder(); } regionMap = MapMetrics.map = new Texture2D(w, h, TextureFormat.RGBA32, false); MapMetrics.provincemap = new Texture2D(w, h, TextureFormat.RGBA32, false, false); occupationMap = MapMetrics.occupemap = new Texture2D(w, h, TextureFormat.RGBA32, false); regionMap.filterMode = FilterMode.Point; occupationMap.filterMode = FilterMode.Point; MapMetrics.UpdateColorMap(); MapMetrics.UpdateOccupedMap(); MapMetrics.UpdateProvincesMap(); System.IO.File.WriteAllBytes("DasIst.png", regionMap.EncodeToPNG()); terrainMat.SetTexture("_OccupeMap", MapMetrics.occupemap); terrainMat.SetColor("_Select", Color.white); Shader.SetGlobalTexture("_StateColor", MapMetrics.map); Shader.SetGlobalTexture("_ProvincesColor", MapMetrics.provincemap); Shader.SetGlobalVector("_NoiseConst", new Vector4(MapMetrics.noiseScale, MapMetrics.cellPerturbStrength, 0, 0)); Shader.SetGlobalTexture("_SplatMap", MapMetrics.GetSplatMap()); Shader.SetGlobalVector("_Size", new Vector4(1f / w, 1f / h, w, h)); Shader.SetGlobalTexture("_HeightMap", MapMetrics.GetHeightMap); Shader.SetGlobalTexture("_Noise", MapMetrics.noise); Shader.SetGlobalFloat("_MaxHeight", MapMetrics.MaxHeight); Shader.SetGlobalFloat("_SeaLevel", MapMetrics.SeaLevel); }
public void Annexation(State annexator, State target, List <Region> land) { foreach (var war in target.diplomacy.war) { foreach (var reg in war.Enemy(target).regions) { if (reg.ocptby == target) { reg.ocptby = null; } } } foreach (var reg in land) { reg.owner.regions.Remove(reg); reg.owner = annexator; reg.ocptby = null; annexator.regions.Add(reg); } foreach (var reg in regions) { reg.UpdateSplateState(curPlayer); } /*foreach (var agent in curPlayer.army) * MapMetrics.UpdateAgentVision(agent.curPosition, agent.curPosition, agent.VisionRadius, 1); * foreach (var agent in curPlayer.ships) * MapMetrics.UpdateAgentVision(agent.curPosition, agent.curPosition, agent.VisionRadius, 1);*/ annexator.SetName(); if (target.regions.Count == 0) { target.DestroyState(); } else { target.SetName(); } if (target.stateAI.autoArmyCommander.IsOn) { target.stateAI.autoArmyCommander.RecalculateRegions(); } if (annexator.stateAI.autoArmyCommander.IsOn) { annexator.stateAI.autoArmyCommander.RecalculateRegions(); } MapMetrics.UpdateColorMap(); MapMetrics.UpdateOccupedMap(); MapMetrics.UpdateSplatMap(); }