public void RepairUnit(Selectable s) { Health h = s.GetComponent <Health>(); float cost = s.Data.Cost * ((h.InitialHealth - h.HealthValue) / h.InitialHealth); Data.Credits -= cost; h.HealthValue = h.InitialHealth; }
void KillMe(Selectable go) { Instantiate(Explosion, go.transform.position, go.transform.rotation); Selection.Remove(go.GetComponent <Selectable>()); Bounds.SetUnits(Selection); go.transform.parent = null; MyTeam.GetComponent <LimitsMan>().CheckBuild(go.Data.Type); GameObject.Destroy(go.gameObject, 0.5f); }
void SlowUpdate() { if (Target != null) { Health h = Target.GetComponent <Health>(); HealthText.text = Mathf.RoundToInt(h.HealthValue / h.InitialHealth * 100).ToString() + "%"; CostText.text = Target.Data.Cost.ToString(); } else { HealthText.text = "???"; CostText.text = "???"; } }