コード例 #1
0
ファイル: PlayerStats.cs プロジェクト: kenttim/MAGD488
    void Start()
    {
        maxHealth     = SetMaxHealthFromHealthLevel();
        currentHealth = maxHealth;
        healthbar.SetMaxHealth(maxHealth);
        healthbar.SetCurrentHealth(currentHealth);

        maxStamina     = SetMaxStaminaFromStaminaLevel();
        currentStamina = maxStamina;
        staminabar.SetMaxStamina(maxStamina);
        staminabar.SetCurrentStamina(currentStamina);
    }
コード例 #2
0
 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);
 }
コード例 #3
0
    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);
    }
コード例 #4
0
 public void UpdateStaminaBar()
 {
     playerStaminaBar.SetCurrentStamina(playerStamina.GetCurrentStamina());
     playerStaminaBar.UpdateStaminaBar();
 }
コード例 #5
0
 public void TakeStaminaDamage(int damage)
 {
     currentStamina = currentStamina - damage;
     staminaBar.SetCurrentStamina(Mathf.RoundToInt(currentStamina)); //set stamina a la barra
 }