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 WhitePeace(State annexator, State target) { foreach (var reg in annexator.regions) { if (reg.ocptby == target) { reg.ocptby = null; } } foreach (var army in annexator.army) { if (army.navAgent.target?.curOwner == target) { army.navAgent.target = null; } } foreach (var reg in target.regions) { if (reg.ocptby == annexator) { reg.ocptby = null; } } foreach (var army in target.army) { if (army.navAgent.target?.curOwner == annexator) { army.navAgent.target = null; } } 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); } if (target.stateAI.autoArmyCommander.IsOn) { target.stateAI.autoArmyCommander.RecalculateRegions(); } if (annexator.stateAI.autoArmyCommander.IsOn) { annexator.stateAI.autoArmyCommander.RecalculateRegions(); } MapMetrics.UpdateOccupedMap(); MapMetrics.UpdateSplatMap(); }
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(); }
public void Occupated(Region r, State occupant) { r.Destoyed = false; State realOwner = r.owner; State curOwner = r.curOwner; if (occupant != r.owner) { r.ocptby = occupant; Debug.Log(string.Format("Страна {0} захватила {1}", occupant.name, r.name)); } else { r.ocptby = null; Debug.Log(string.Format("Страна {0} вернула {1}", occupant.name, r.name)); } if (realOwner.stateAI.autoArmyCommander.IsOn) { realOwner.stateAI.autoArmyCommander.RecalculateRegions(); } AutoArmyCommander autoArmy = realOwner.stateAI.autoArmyCommander; if (autoArmy.IsOn) { autoArmy.RecalculateRegions(); } if (!r.InFogFrom(curPlayer)) { MapMetrics.SetRegionSplatState(r.territory, LandShowMode.Visible); } MapMetrics.UpdateOccupedMap(); MapMetrics.UpdateSplatMap(); }