Exemple #1
0
    private void Start()
    {
        playerController = GetComponent <vThirdPersonController>();
        playerAnim       = GetComponent <Animator>();

        thirstWaitTime = new WaitForSeconds(thirstTime);
        hungerWaitTime = new WaitForSeconds(hungerTime);
        healthWaitTime = new WaitForSeconds(healthTime);

        var myPlayer = PlayerManager.instance.currentPlayer.inventoryPlayer;

        healthStat = myPlayer.stats.Get("Default", "Health");
        thirstStat = myPlayer.stats.Get("Default", "Thirst");
        hungerStat = myPlayer.stats.Get("Default", "Hunger");

        healthStat.SetCurrentValueRaw(startHealth);
        thirstStat.SetCurrentValueRaw(startThirst);
        hungerStat.SetCurrentValueRaw(startHunger);

        StartCoroutine(DegradeThirstOverTime());
        StartCoroutine(DegradeHungerOverTime());
        StartCoroutine(DegradeHealthOverTimer());

        thirstStat.OnValueChanged += ThirstStat_OnValueChanged;
        hungerStat.OnValueChanged += HungerStat_OnValueChanged;
    }
Exemple #2
0
        void SetHealth(float to, bool crit, IDamageSource source)
        {
            if (to < 0f)
            {
                to = 0f;
            }

            m_Critical = crit;
            m_Source   = source;
            m_HealthStat.SetCurrentValueRaw(to);
        }
Exemple #3
0
    protected IEnumerator DegradeHungerOverTime()
    {
        while (hungerStat.currentValue > 0)
        {
            yield return(hungerWaitTime);

            hungerStat.ChangeCurrentValueRaw(-1);
        }

        if (hungerStat.currentValue <= 0)
        {
            hungry = true;
            hungerStat.SetCurrentValueRaw(0);
        }
        //else hungry = false;
    }
Exemple #4
0
    protected IEnumerator DegradeThirstOverTime()
    {
        while (thirstStat.currentValue > 0)
        {
            yield return(thirstWaitTime);

            thirstStat.ChangeCurrentValueRaw(-1);
        }

        if (thirstStat.currentValue <= 0)
        {
            thirsty = true;
            thirstStat.SetCurrentValueRaw(0);
        }
        //else thirsty = false;
    }
Exemple #5
0
 public void AdjustHealth()
 {
     healthStat.SetCurrentValueRaw(playerController.currentHealth);
 }