void Start() { maxHealth = SetMaxHealthFromHealthLevel(); currentHealth = maxHealth; healthbar.SetMaxHealth(maxHealth); healthbar.SetCurrentHealth(currentHealth); maxStamina = SetMaxStaminaFromStaminaLevel(); currentStamina = maxStamina; staminabar.SetMaxStamina(maxStamina); staminabar.SetCurrentStamina(currentStamina); }
void Awake() { //Obtains the player player = GameObject.FindGameObjectWithTag("Player"); //Obtains the health atributes playerHealth = player.GetComponent <Health>(); playerHealthBar = GetComponentInChildren <HealthBar>(); playerHealthBar.SetMaxHealth(playerHealth.GetMaxHealth()); playerHealthBar.SetCurrentHealth(GameManager.instance.data.HasPlayerData() ? GameManager.instance.GetCurrentPlayerHealth() : playerHealth.GetMaxHealth()); //Obtains the stamina atributes playerStamina = player.GetComponent <Stamina>(); playerStaminaBar = GetComponentInChildren <StaminaBar>(); playerStaminaBar.SetMaxStamina(playerStamina.GetMaxStamina()); playerStaminaBar.SetCurrentStamina(playerStamina.GetMaxStamina()); //Disable the panels npcNamePanel.SetActive(false); textPanel.SetActive(false); introTextPanel.SetActive(false); savePanel.SetActive(false); unlockWeaponPanel.SetActive(false); deathPanel.SetActive(false); outOfAmmoPanel.SetActive(false); sentenceOptionsPanel.SetActive(false); fuelBarUI.SetActive(false); }
float GetClampedForceToApply(float forceAddedMagnitudeClamped) { float staminaPercUsed = forceAddedMagnitudeClamped / differenceTotalForce; float oldStaminaCache = staminaBar.GetPercentStamina(); float newStaminaPerc = Mathf.Clamp(oldStaminaCache - staminaPercUsed, 0, 1); staminaBar.SetPercentStamina(newStaminaPerc); staminaBar.SetCurrentStamina(staminaBar.GetMaxStamina() * newStaminaPerc); float forceCalculationWithCurrentStamina = Mathf.Clamp(oldStaminaCache * differenceTotalForce, minForceToApply, forceAddedMagnitudeClamped); return(forceCalculationWithCurrentStamina); }
public void UpdateStaminaBar() { playerStaminaBar.SetCurrentStamina(playerStamina.GetCurrentStamina()); playerStaminaBar.UpdateStaminaBar(); }
public void TakeStaminaDamage(int damage) { currentStamina = currentStamina - damage; staminaBar.SetCurrentStamina(Mathf.RoundToInt(currentStamina)); //set stamina a la barra }