/// <summary> /// Parses the player's prompt based on variables into text /// </summary> /// <returns>The parsed prompt</returns> public string GetParsedPrompt() { string parsed = Prompt; parsed = parsed.Replace(Constants.Prompt.HP_CURRENT, CurrentHitPoints.ToString()); parsed = parsed.Replace(Constants.Prompt.HP_MAX, ModifiedPools.HitPoints.ToString()); parsed = parsed.Replace(Constants.Prompt.STAMINA_CURRENT, CurrentStamina.ToString()); parsed = parsed.Replace(Constants.Prompt.STAMINA_MAX, ModifiedPools.Stamina.ToString()); parsed = parsed.Replace(Constants.Prompt.ENERGY_CURRENT, CurrentEnergy.ToString()); parsed = parsed.Replace(Constants.Prompt.ENERGY_MAX, ModifiedPools.Energy.ToString()); return(parsed); }
// Update is called once per frame void Update() { if (CurrentHealht < 0) { CurrentHealht = 0; } if (CurrentStamina < 0) { CurrentStamina = 0; } if (CurrentHealht > CreatePlayer.Instance.HealthPoints) { CurrentHealht = CreatePlayer.Instance.HealthPoints; UpdateUI(); } if (CurrentStamina > CreatePlayer.Instance.StaminaPoints) { CurrentStamina = CreatePlayer.Instance.StaminaPoints; } CurrentStaminaText.text = CurrentStamina.ToString(); CurrentStamF = CurrentStamina; MaxStamF = CreatePlayer.Instance.StaminaPoints; StaminaBarLoss = CurrentStamF / CreatePlayer.Instance.StaminaPoints; StaminaBarImage.transform.localScale = new Vector3(StaminaBarLoss, StaminaBarImage.transform.localScale.y, StaminaBarImage.transform.localScale.z); if (YellowHealthBar.transform.localScale.x > HealthBarImage.transform.localScale.x) { YellowHealthBar.transform.localScale = new Vector3(YellowHealthBar.transform.localScale.x - 0.003f, YellowHealthBar.transform.localScale.y, YellowHealthBar.transform.localScale.z); } if (HealthBarImage.transform.localScale.x <= 0) { HealthBarImage.transform.localScale = new Vector3(0, HealthBarImage.transform.localScale.y, HealthBarImage.transform.localScale.z); YellowHealthBar.transform.localScale = new Vector3(0, YellowHealthBar.transform.localScale.y, YellowHealthBar.transform.localScale.z); } if (HealthBarImage.transform.localScale.x > 0.987f) { HealthBarImage.transform.localScale = new Vector3(0.987f, HealthBarImage.transform.localScale.y, HealthBarImage.transform.localScale.z); YellowHealthBar.transform.localScale = new Vector3(0.987f, YellowHealthBar.transform.localScale.y, YellowHealthBar.transform.localScale.z); } }
public void UpdateUI() { CurrentHealthText.text = CurrentHealht.ToString(); CurrentStaminaText.text = CurrentStamina.ToString(); CurrentManaText.text = CurrentMana.ToString(); }