// Set health and armor values, which are translated into fill amounts and text numbers public void SetHealthArmor(float healthCur, float healthMax, float armorCur, float armorMax, bool burnPossible) { float healthRatio = healthCur / (Mathf.RoundToInt(healthMax) != 0 ? healthMax : 1); healthFill.rectTransform.sizeDelta = new Vector2((1 - healthRatio) * -rootWidth, healthFill.rectTransform.sizeDelta.y); foreach (Text text in healthText) { text.text = StringFromFloat(healthCur) + "/" + StringFromFloat(healthMax); } // Tooltip healthTooltip.SetText(!burnPossible ? "Burn Immune\nEven if this unit's health is below the burn threshold, it will not take burn damage over time." : string.Format("Burn threshold: {0:0}\nIf health drops below this threshold, it will start taking {1:0} damage over every 10 seconds.", healthMax * gameRules.HLTH_burnThresh, (gameRules.HLTH_burnMin + gameRules.HLTH_burnMax) * 5)); float armorRatio = armorCur / (Mathf.RoundToInt(armorMax) != 0 ? armorMax : 1); armorFill.rectTransform.sizeDelta = new Vector2((1 - armorRatio) * -rootWidth, armorFill.rectTransform.sizeDelta.y); foreach (Text text in armorText) { text.text = StringFromFloat(armorCur) + "/" + StringFromFloat(armorMax); } string armorToolotipText = Mathf.RoundToInt(armorMax) == 0 ? "This unit has no armor." : Mathf.FloorToInt(armorCur) < gameRules.ABLY_armorDrainGPSEnemy * 2 ? "Armor has been destroyed." : string.Format("Absorption limit: {0:0.0}\nCan take up to {0:0.0} damage in one shot before letting excess damage through to health.", (armorCur / armorMax) * gameRules.ARM_absorbScaling + gameRules.ARM_absorbFlat); //Tooltip armorTooltip.SetText(armorToolotipText); }
public void UpdateResCounter(int res, int rec) { resText.text = res.ToString(); recText.text = rec.ToString(); // Tooltips resTooltip.SetText(string.Format("Resource points: {0}\nUsed primarily for calling in additional units.", res)); recTooltip.SetText(string.Format("Raw materials: {0}\nRecovered from your destroyed units.", rec)); }
// Set visibility of the shield icon and set text number to be displayed next to the shield icon public void SetShields(float shieldsCur, float shieldsMax) { if (Mathf.RoundToInt(shieldsMax) == 0) { shieldBkg.gameObject.SetActive(false); } else { shieldBkg.gameObject.SetActive(true); } foreach (Text text in shieldsText) { text.text = StringFromFloat(shieldsCur) + "/" + StringFromFloat(shieldsMax); } shieldTooltip.SetText(Mathf.RoundToInt(shieldsMax) != 0 ? string.Format("Current shield pool: {0:0.0} / {1:0.0}\nShields take damage before this unit's health pool and regenerate over time.", shieldsCur, shieldsMax) : "This unit has no shields."); }
// Set name to be displayed as the title of the EntityStats panel public void SetDisplayEntity(EntityType type) { nameText.text = EntityUtils.GetDisplayName(type); nameTooltip.SetText(EntityUtils.GetDisplayDesc(type)); }
public void UpdateTime(float time) { timeCur = time; timeFill.fillAmount = minMaxFill.x + timeCur * (minMaxFill.y - minMaxFill.x); timeTooltip.SetText(string.Format("Next resource point in: {0:0.0}s\nEvery {1:0} seconds a raw material point is converted into a resource point.", (1 - time) * gameRules.RES_reclaimTime, gameRules.RES_reclaimTime)); }