public void draw_border(PolyBorder pb, List <Vector3> poly, Vector3 offset) { m_border = pb; var border = pb.GetFullLengthBorder(); var fix = new List <Vector3>(); foreach (var v in border) { fix.Add(new Vector3(v.x + offset.x, v.y + offset.y, -0.8f)); } if (m_connection.ConnectionType == ConnectionType.RIVER || m_connection.ConnectionType == ConnectionType.SHALLOWRIVER) { var offset_poly = new List <Vector3>(); foreach (var v in poly) { offset_poly.Add(new Vector3(v.x + offset.x, v.y + offset.y, -0.8f)); } var key_start = new Keyframe(0f, ArtManager.s_art_manager.CurrentArtConfiguration.ProvinceBorderWidth * 2f); var key_end = new Keyframe(1f, ArtManager.s_art_manager.CurrentArtConfiguration.ProvinceBorderWidth * 2f); BorderLine.widthCurve = new AnimationCurve(key_start, key_end); BorderLine.startColor = GenerationManager.s_generation_manager.BorderColor; BorderLine.endColor = GenerationManager.s_generation_manager.BorderColor; BorderLine.positionCount = offset_poly.Count; BorderLine.SetPositions(offset_poly.ToArray()); return; } var arr = fix.ToArray(); var border_scale = 1f; if ((m_connection.Node1.ProvinceData.IsWater && !m_connection.Node2.ProvinceData.IsWater) || (!m_connection.Node1.ProvinceData.IsWater && m_connection.Node2.ProvinceData.IsWater)) { border_scale = 2f; } var key1 = new Keyframe(0f, ArtManager.s_art_manager.CurrentArtConfiguration.ProvinceBorderWidth * border_scale); var key2 = new Keyframe(1f, ArtManager.s_art_manager.CurrentArtConfiguration.ProvinceBorderWidth * border_scale); BorderLine.widthCurve = new AnimationCurve(key1, key2); BorderLine.positionCount = arr.Length; BorderLine.SetPositions(arr); if (m_connection.IsSeaConnection) { BorderLine.materials = new Material[] { MatSeaBorder }; BorderLine.startColor = GenerationManager.s_generation_manager.SeaBorderColor; BorderLine.endColor = GenerationManager.s_generation_manager.SeaBorderColor; } else { BorderLine.materials = new Material[] { MatLandBorder }; BorderLine.startColor = GenerationManager.s_generation_manager.BorderColor; BorderLine.endColor = GenerationManager.s_generation_manager.BorderColor; } }
public void draw_border(PolyBorder pb, Vector3 offset) { m_border = pb; BorderLine.positionCount = 2; BorderLine.SetPositions(new Vector3[] { new Vector3(900, 900, 0), new Vector3(901, 900, 0) }); if (m_connection.ConnectionType == ConnectionType.RIVER || m_connection.ConnectionType == ConnectionType.SHALLOWRIVER) { return; } List <Vector3> border = pb.GetFullLengthBorder(); List <Vector3> fix = new List <Vector3>(); foreach (Vector3 v in border) { fix.Add(new Vector3(v.x + offset.x, v.y + offset.y, -0.8f)); } Vector3[] arr = fix.ToArray(); BorderLine.positionCount = arr.Length; BorderLine.SetPositions(arr); Color c = new Color(0f, 0f, 0f, ArtManager.s_art_manager.BorderOpacity); BorderLine.startColor = c; BorderLine.endColor = c; }
public void draw_border(PolyBorder pb, Vector3 offset) { m_border = pb; BorderLine.positionCount = 2; BorderLine.SetPositions(new Vector3[] { new Vector3(900, 900, 0), new Vector3(901, 900, 0) }); if (m_connection.ConnectionType == ConnectionType.RIVER || m_connection.ConnectionType == ConnectionType.SHALLOWRIVER) { return; } var border = pb.GetFullLengthBorder(); var fix = new List <Vector3>(); foreach (var v in border) { fix.Add(new Vector3(v.x + offset.x, v.y + offset.y, -0.8f)); } var arr = fix.ToArray(); BorderLine.positionCount = arr.Length; BorderLine.SetPositions(arr); BorderLine.startColor = GenerationManager.s_generation_manager.BorderColor; BorderLine.endColor = GenerationManager.s_generation_manager.BorderColor; }
void draw_shore(Vector3 offset) { if (m_stroke != null) { GameObject.Destroy(m_stroke.gameObject); m_stroke = null; } if ((m_parent.Prov1.Node.ProvinceData.IsWater && !m_parent.Prov2.Node.ProvinceData.IsWater) || (m_parent.Prov2.Node.ProvinceData.IsWater && !m_parent.Prov1.Node.ProvinceData.IsWater)) { GameObject g = GameObject.Instantiate(InnerStrokePrefab); m_stroke = g.GetComponent <InnerStroke>(); m_stroke.DrawStroke(PolyBorder.GetFullLengthBorder(), offset); } }
private void draw_shore() { if (m_stroke != null) { GameObject.Destroy(m_stroke.gameObject); m_stroke = null; } if ((Prov1.Node.ProvinceData.IsWater && !Prov2.Node.ProvinceData.IsWater) || (Prov2.Node.ProvinceData.IsWater && !Prov1.Node.ProvinceData.IsWater)) { var g = GameObject.Instantiate(InnerStrokePrefab); m_stroke = g.GetComponent <InnerStroke>(); m_stroke.UpdateArtStyle(); m_stroke.DrawStroke(PolyBorder.GetFullLengthBorder(), Vector3.zero); } }
private void draw_shore(Vector3 offset) { if (m_stroke != null) { GameObject.Destroy(m_stroke.gameObject); m_stroke = null; } if ((m_parent.Prov1.Node.ProvinceData.IsWater && !m_parent.Prov2.Node.ProvinceData.IsWater) || (m_parent.Prov2.Node.ProvinceData.IsWater && !m_parent.Prov1.Node.ProvinceData.IsWater)) { var g = GameObject.Instantiate(InnerStrokePrefab); m_stroke = g.GetComponent <InnerStroke>(); m_stroke.UpdateArtStyle(); m_stroke.DrawStroke(PolyBorder.GetFullLengthBorder(), offset, true, ArtManager.s_art_manager.CurrentArtConfiguration.MinimumSeaShoreWidth, ArtManager.s_art_manager.CurrentArtConfiguration.MaximumSeaShoreWidth); } }
public void RecalculatePoly() { BorderLine.positionCount = 2; BorderLine.SetPositions(new Vector3[] { new Vector3(900, 900, 0), new Vector3(901, 900, 0) }); RoadLine.positionCount = 2; RoadLine.SetPositions(new Vector3[] { new Vector3(900, 900, 0), new Vector3(901, 900, 0) }); MeshFilter.mesh.Clear(); if (m_culling_points == null) { m_culling_points = new List <Vector3>(); } if (PolyBorder == null) { return; } draw_shore(); if (m_connection.ConnectionType == ConnectionType.RIVER || m_connection.ConnectionType == ConnectionType.SHALLOWRIVER) { m_poly = get_contour(PolyBorder, 0.02f, 0.08f); ConstructPoly(); draw_river_shore(); SetSeason(GenerationManager.s_generation_manager.Season); return; } else if (m_connection.ConnectionType == ConnectionType.ROAD) { var dir = (m_pos2 - m_pos1).normalized; var p1 = m_pos1 + dir * 0.4f; var p2 = m_pos2 - dir * 0.4f; if (Vector3.Distance(m_pos1, m_pos2) > 3f) { p1 = m_pos1 + dir * 0.6f; p2 = m_pos2 - dir * 0.6f; } if (Vector3.Distance(p1, p2) < 0.5f) { p1 = m_pos1 + dir * 0.3f; p2 = m_pos2 - dir * 0.3f; } var fake = new PolyBorder(p1, p2, m_connection); m_culling_points = fake.OrderedPoints; m_poly = fake.OrderedFinePoints; draw_road(fake); } var border = PolyBorder.GetFullLengthBorder(); var fix = new List <Vector3>(); foreach (var v in border) { fix.Add(new Vector3(v.x, v.y, -0.8f)); } var arr = fix.ToArray(); BorderLine.positionCount = arr.Length; BorderLine.SetPositions(arr); BorderLine.startColor = GenerationManager.s_generation_manager.BorderColor; BorderLine.endColor = GenerationManager.s_generation_manager.BorderColor; SetSeason(GenerationManager.s_generation_manager.Season); }
public void RecalculatePoly() { BorderLine.positionCount = 2; BorderLine.SetPositions(new Vector3[] { new Vector3(900, 900, 0), new Vector3(901, 900, 0) }); RoadLine.positionCount = 2; RoadLine.SetPositions(new Vector3[] { new Vector3(900, 900, 0), new Vector3(901, 900, 0) }); MeshFilter.mesh.Clear(); if (m_culling_points == null) { m_culling_points = new List <Vector3>(); } if (PolyBorder == null) { return; } draw_shore(); if (m_connection.ConnectionType == ConnectionType.RIVER || m_connection.ConnectionType == ConnectionType.SHALLOWRIVER) { m_poly = get_contour(PolyBorder, ArtManager.s_art_manager.CurrentArtConfiguration.MinimumRiverWidth, ArtManager.s_art_manager.CurrentArtConfiguration.MaximumRiverWidth); m_full_contour = new List <Vector3>(); m_full_contour.AddRange(m_poly); m_full_contour.Add(m_poly[0]); var key_start = new Keyframe(0f, ArtManager.s_art_manager.CurrentArtConfiguration.ProvinceBorderWidth * 2f); var key_end = new Keyframe(1f, ArtManager.s_art_manager.CurrentArtConfiguration.ProvinceBorderWidth * 2f); BorderLine.widthCurve = new AnimationCurve(key_start, key_end); BorderLine.startColor = GenerationManager.s_generation_manager.BorderColor; BorderLine.endColor = GenerationManager.s_generation_manager.BorderColor; BorderLine.positionCount = m_full_contour.Count; BorderLine.SetPositions(m_full_contour.ToArray()); ConstructPoly(); draw_river_shore(); SetSeason(GenerationManager.s_generation_manager.Season); return; } else if (m_connection.ConnectionType == ConnectionType.ROAD) { var distance = Vector3.Distance(m_pos1, m_pos2); var scaled_reduction = distance * ArtManager.s_art_manager.CurrentArtConfiguration.RoadShortening; var dir = (m_pos2 - m_pos1).normalized; var p1 = m_pos1 + dir * scaled_reduction; var p2 = m_pos2 - dir * scaled_reduction; var road_line = new PolyBorder(p1, p2, m_connection, true); m_culling_points = road_line.OrderedPoints; m_poly = road_line.OrderedFinePoints; draw_road(road_line); } var border = PolyBorder.GetFullLengthBorder(); var fix = new List <Vector3>(); foreach (var v in border) { fix.Add(new Vector3(v.x, v.y, -0.8f)); } var border_scale = 1f; if ((m_connection.Node1.ProvinceData.IsWater && !m_connection.Node2.ProvinceData.IsWater) || (!m_connection.Node1.ProvinceData.IsWater && m_connection.Node2.ProvinceData.IsWater)) { border_scale = 2f; } var arr = fix.ToArray(); var key1 = new Keyframe(0f, ArtManager.s_art_manager.CurrentArtConfiguration.ProvinceBorderWidth * border_scale); var key2 = new Keyframe(1f, ArtManager.s_art_manager.CurrentArtConfiguration.ProvinceBorderWidth * border_scale); BorderLine.widthCurve = new AnimationCurve(key1, key2); BorderLine.positionCount = arr.Length; BorderLine.SetPositions(arr); if (m_connection.IsSeaConnection) { BorderLine.materials = new Material[] { MatSeaBorder }; BorderLine.startColor = GenerationManager.s_generation_manager.SeaBorderColor; BorderLine.endColor = GenerationManager.s_generation_manager.SeaBorderColor; } else { BorderLine.materials = new Material[] { MatLandBorder }; BorderLine.startColor = GenerationManager.s_generation_manager.BorderColor; BorderLine.endColor = GenerationManager.s_generation_manager.BorderColor; } SetSeason(GenerationManager.s_generation_manager.Season); }