Exemplo n.º 1
0
        /// <summary>
        /// Provides the description of the model settings for summary (GetFullSummary)
        /// </summary>
        /// <param name="formatForParentControl">Use full verbose description</param>
        /// <returns></returns>
        public override string ModelSummary(bool formatForParentControl)
        {
            string html = "\n<div class=\"activityentry\">";

            html += "This land type has an area of <span class=\"setvalue\">" + (this.LandArea * ProportionOfTotalArea).ToString("#,##0.##") + "</span>";
            string units = (this as IResourceType).Units;

            if (units != "NA")
            {
                if (units == null || units == "")
                {
                    html += "";
                }
                else
                {
                    html += " <span class=\"setvalue\">" + units + "</span>";
                }
            }

            if (PortionBuildings > 0)
            {
                html += " of which <span class=\"setvalue\">" + this.PortionBuildings.ToString("0.##%") + "</span> is buildings";
            }
            html += "</div>";
            html += "\n<div class=\"activityentry\">";
            html += "This land has soil of index <span class=\"setvalue\">" + SoilType.ToString() + "</span>";
            html += "\n</div>";
            return(html);
        }
Exemplo n.º 2
0
        public GameObject SpawnSoil(SoilType soilType)
        {
            GameObject prefab   = soilData.First(pair => pair.Key.Equals(soilType)).Value.Prefabs.GetRandomItem();
            GameObject instance = Instantiate(prefab, CachedTransform.position, CachedTransform.rotation);

            instance.transform.Translate(soilSpawnpoint, Space.World);

            instance.name = soilType.ToString().ReplaceUnderscoreWithSpace();

            return(instance);
        }
    // Use this for initialization
    void Start()
    {
        GameObject _GM = GameObject.Find("_GM");

        solutions    = _GM.GetComponent <Solutions>();
        buildingList = _GM.GetComponent <BuildingList>();
        upgradeList  = _GM.GetComponent <UpgradeList>();

        sprite = GetComponentInChildren <SpriteRenderer>();

        // Raycast downwards to terrain and assign joint anchor
        RaycastHit2D terrainHit = Physics2D.Raycast(transform.position + Vector3.up * 10, -Vector2.up, float.MaxValue, terrainLayer);

        if (terrainHit.collider != null)
        {
            Vector2 hitPoint    = terrainHit.point;
            string  terrainName = terrainHit.collider.gameObject.name;

            // Try to automatically set soil type based on terrain name

            string[] typeNames = Enum.GetNames(typeof(SoilType));
            Array    typeVals  = Enum.GetValues(typeof(SoilType));
            for (int i = 0; i < typeNames.Length; i++)
            {
                if (terrainName.Equals(typeNames[i]))
                {
                    soilType = (SoilType)typeVals.GetValue(i);
                }
            }

            gameObject.name = gameObject.name + " of " + soilType + " on " + terrainHit.collider.gameObject.name;

            if (!soilType.ToString().Equals(terrainName))
            {
                Debug.Log("WARNING: Soil type property name of building zone do not equal terrain name: " + soilType + " != " + terrainHit.collider.gameObject.name);
            }
        }
        else
        {
            Debug.Log("WARNING: Terrain not found of building platform");
        }
    }
Exemplo n.º 4
0
        /// <summary>
        /// Provides the description of the model settings for summary (GetFullSummary)
        /// </summary>
        /// <param name="formatForParentControl">Use full verbose description</param>
        /// <returns></returns>
        public override string ModelSummary(bool formatForParentControl)
        {
            string html = "\n<div class=\"activityentry\">";

            if (LandArea == 0)
            {
                html += "<span class=\"errorlink\">NO VALUE</span> has been set for the area of this land";
            }
            else if (ProportionOfTotalArea == 0)
            {
                html += "The proportion of total area assigned to this land type is <span class=\"errorlink\">0</span> so no area is assigned";
            }
            else
            {
                html += "This land type has an area of <span class=\"setvalue\">" + (this.LandArea * ProportionOfTotalArea).ToString("#,##0.##") + "</span>";
                string units = (this as IResourceType).Units;
                if (units != "NA")
                {
                    if (units == null || units == "")
                    {
                        html += "";
                    }
                    else
                    {
                        html += " <span class=\"setvalue\">" + units + "</span>";
                    }
                }
            }

            if (PortionBuildings > 0)
            {
                html += " of which <span class=\"setvalue\">" + this.PortionBuildings.ToString("0.##%") + "</span> is buildings";
            }
            html += "</div>";
            html += "\n<div class=\"activityentry\">";
            html += "This land is identified as <span class=\"setvalue\">" + SoilType.ToString() + "</span>";
            html += "\n</div>";
            return(html);
        }
Exemplo n.º 5
0
        /// <inheritdoc/>
        public override string ModelSummary()
        {
            using (StringWriter htmlWriter = new StringWriter())
            {
                htmlWriter.Write("\r\n<div class=\"activityentry\">");
                if (LandArea == 0)
                {
                    htmlWriter.Write("<span class=\"errorlink\">NO VALUE</span> has been set for the area of this land");
                }
                else if (ProportionOfTotalArea == 0)
                {
                    htmlWriter.Write("The proportion of total area assigned to this land type is <span class=\"errorlink\">0</span> so no area is assigned");
                }
                else
                {
                    htmlWriter.Write("This land type has an area of <span class=\"setvalue\">" + (this.LandArea * ProportionOfTotalArea).ToString("#,##0.##") + "</span>");
                }
                string units = (this as IResourceType).Units;
                if (units != "NA")
                {
                    if (units == null || units == "")
                    {
                        htmlWriter.Write("");
                    }
                    else
                    {
                        htmlWriter.Write(" <span class=\"setvalue\">" + units + "</span>");
                    }
                }

                if (PortionBuildings > 0)
                {
                    htmlWriter.Write(" of which <span class=\"setvalue\">" + this.PortionBuildings.ToString("0.##%") + "</span> is buildings");
                }
                htmlWriter.Write("</div>");
                htmlWriter.Write("\r\n<div class=\"activityentry\">");
                htmlWriter.Write("This land is identified as <span class=\"setvalue\">" + SoilType.ToString() + "</span>");
                htmlWriter.Write("\r\n</div>");
                return(htmlWriter.ToString());
            }
        }