using UnityEngine; using System.Collections; using System.Collections.Generic; using TMPro; namespace WPM { public partial class Country: AdminEntity { /// /// Continent name. /// public string continent; // Standardized codes public string fips10_4 = ""; public string iso_a2 = ""; public string iso_a3 = ""; public string iso_n3 = ""; /// /// Optional custom label. It set, it will be displayed instead of the country name. /// public string customLabel; /// /// Set it to true to specify a custom color for the label. /// public bool labelColorOverride; /// /// The color of the label. /// public Color labelColor = Color.white; /// /// If the label has its own font size. /// public bool labelFontSizeOverride = false; /// /// Manual font size for the label. Must set labelOverridesFontSize = true to have effect. /// public float labelFontSize = 0.1f; Font _labelFont; Material _labelShadowFontMaterial; TMP_FontAsset _labelFontTMPPro; Material _labelFontTMProMaterial; /// /// Internal method used to obtain the shadow material associated to a custom Font provided. /// /// The label shadow font material. public Material labelFontShadowMaterial { get { return _labelShadowFontMaterial; } } /// /// Optional font for this label. Note that the font material will be instanced so it can change color without affecting other labels. /// public Font labelFontOverride { get { return _labelFont; } set { if (value != _labelFont) { _labelFont = value; if (_labelFont != null) { Material fontMaterial = Object.Instantiate (_labelFont.material); _labelFont.material = fontMaterial; _labelShadowFontMaterial = Object.Instantiate (fontMaterial); _labelShadowFontMaterial.renderQueue--; } } } } /// /// Optional font (TextMesh Pro) for this label. Note that the font material will be instanced so it can change color without affecting other labels. /// public TMP_FontAsset labelFontTMProOverride { get { return _labelFontTMPPro; } set { if (value != _labelFontTMPPro) { _labelFontTMPPro = value; if (_labelFontTMPPro != null) { Material fontMaterial = Object.Instantiate(_labelFontTMPPro.material); _labelFontTMPPro.material = fontMaterial; } } } } /// /// Optional font (TextMesh Pro) material for this label. /// public Material labelFontTMProMaterialOverride { get { return _labelFontTMProMaterial; } set { if (value != _labelFontTMProMaterial) { _labelFontTMProMaterial = value; } } } /// /// Sets whether the country name will be shown or not. /// public bool labelVisible = true; /// /// If set to a value > 0 degrees then label will be rotated according to this value (and not automatically calculated). /// public float labelRotation; /// /// If set to a value != 0 in both x/y then label will be moved according to this value (and not automatically calculated). /// public Vector2 labelOffset; public override List regions { get { return _regions; } set { _regions = value; } } public override Region mainRegion { get { if (mainRegionIndex < 0 || mainRegionIndex >= regions.Count) return null; else return regions [mainRegionIndex]; } } /// /// Set to false to prevent drawing provinces for this country /// public bool allowShowProvinces = true; /// /// The index of the capital city /// public int cityCapitalIndex = -1; #region internal fields /// Used internally. Don't change fields below. public GameObject labelTextGameObject; public TextMeshPro labelTextMeshPro; public TextMesh labelTextMesh, labelShadowTextMesh; public float labelMeshWidth, labelMeshHeight; public Vector2 labelMeshCenter; Province[] _provinces; public Province[] provinces { get { if (_provinces == null && WorldMapGlobe.instance.provinces == null) { // do nothing as the second clause already loads provinces if not initialized } return _provinces; } set { _provinces = value; } } public Vector3 labelSphereEdgeTop, labelSphereEdgeBottom; public Renderer labelRenderer, labelShadowRenderer; #endregion public Country (string name, string continent) { this.name = name; this.continent = continent; this.regions = new List (); } public Country Clone () { Country c = new Country (name, continent); c.latlonCenter = latlonCenter; c.regions = regions; c.customLabel = customLabel; c.labelColor = labelColor; c.labelColorOverride = labelColorOverride; c.labelFontOverride = labelFontOverride; c.labelVisible = labelVisible; c.labelOffset = labelOffset; c.labelRotation = labelRotation; c.provinces = provinces; c.hidden = this.hidden; c.fips10_4 = fips10_4; c.iso_a2 = iso_a2; c.iso_a3 = iso_a3; c.iso_n3 = iso_n3; if (_attrib != null) { c.attrib = new JSONObject(); c.attrib.Absorb(attrib); } return c; } } }