private void SetupVitalDisplays() { PlayerVitals.inst.Subscribe(this); foreach (string key in PlayerVitals.inst.vitals.Keys) { Debug.Log("initializing vital '" + key + "'"); IVital vital = PlayerVitals.inst.vitals[key]; DisplayNewVital(vital); } }
private void DisplayNewVital(IVital vital) { Debug.Log("displaying new vital '" + vital.name + "'"); // creates a new text object based on the given IVital, and puts it in the display. GameObject newTextObj = Instantiate <GameObject>(textPrefab); Text txt = newTextObj.GetComponent <Text>(); txt.text = GenerateVitalText(vital); txt.color = vital.color; vitalDisplays.Add(vital.name, txt); newTextObj.transform.SetParent(this.transform); }
public void ApplyVitalUse(float cost, IVital vit) { vit.CurValue -= cost; }
public void UpdateVital(string key, IVital vital) { Text text = vitalDisplays[key]; text.text = GenerateVitalText(vital); }
private string GenerateVitalText(IVital vital) { return(vital.name + ": " + vital.current + " / " + vital.max); }
/// <summary> /// Sets the primary values and variables required for the ability. /// </summary> /// <param name="user">User.</param> public virtual void SetValue(BaseCharacter user) { _user = user; _userInput = _user.CharInput; if (_user == null) Debug.LogError ("user is null"); if (_user.CharStats == null) Debug.LogError ("user stats are null"); _userVital = _user.CharStats.CharVitals.Find (i => i.Name == vitalType.ToString()); if (cost > 0) { enterAbility += delegate { _userVital.StopRegen = true; }; exitAbility += delegate { _userVital.StopRegen = false; }; } }