示例#1
0
    protected override void Update()
    {
        if (!stats.alive)
        {
            return;
        }

        base.Update();

        #region Health potion

        if (Input.GetKeyDown(KeyCode.E))
        {
            usePotion();
        }

        hPotion.updateUses();

        #endregion

        #region Restore health

        RestoreHeatlhOn = WeaponController.wc.equippedWeapon.restoreHealthMechanic;

        if (RestoreHeatlhOn)
        {
            if (timeToRH > 0)
            {
                timeToRH -= Time.deltaTime;
            }
            else
            {
                if (RHDecayIntervalTime <= 0)
                {
                    RHDecayIntervalTime = RHDecayInterval;

                    if (healthToRestore >= RHDecayAmount)
                    {
                        healthToRestore -= RHDecayAmount;
                    }
                    else
                    {
                        healthToRestore = 0;
                    }
                }
                else
                {
                    RHDecayIntervalTime -= Time.deltaTime;
                }
            }
        }
        else
        {
            timeToRH        = 0;
            healthToRestore = 0;
        }

        #endregion
    }