コード例 #1
0
ファイル: Health.cs プロジェクト: Ylla-/TotemQuest
    public void AdjustCurrentHealth(int value)
    {
        if (value < 0 && flashSprite != null)          //If damage taken is >1. Flash Sprite.
        {
            flashSprite.Flash(Color.white);
        }
        if (shield)
        {
            curHealth = curHealth + (int)(value * shieldRatio);             //for mole shielding
        }
        else
        {
            curHealth += value;
        }

        if (curHealth < 1)
        {
            curHealth = 0;
            //CharacterController cc = GetComponent(typeof(CharacterController)) as CharacterController;
            //cc.enabled = false; // Turn off the component
            Die();
        }
        if (curHealth > maxHealth)
        {
            curHealth = maxHealth;
        }
        healthBarLength = (Screen.width / 3) * (curHealth / (float)(maxHealth));
    }
コード例 #2
0
ファイル: Health.cs プロジェクト: Telek/TotemQuest
    public void AdjustCurrentHealth(int value)
    {
        if (value < 0 && flashSprite != null)          //If damage taken is >1. Flash Sprite.
        {
            flashSprite.Flash(Color.white);
        }
        if (shield)
        {
            curHealth = curHealth + (int)(value * shieldRatio);                     //for mole shielding
        }
        else
        {
            curHealth += value;
        }

        if (curHealth < 1)
        {
            curHealth = 0;
            Die();
        }
        if (curHealth > maxHealth)
        {
            curHealth = maxHealth;
        }
        healthBarLength = (Screen.width / 3) * (curHealth / (float)(maxHealth));
    }
コード例 #3
0
    void Update()
    {
        if (active)
        {
            if (_explodeTimer > 0)
            {
                _explodeTimer -= Time.deltaTime;
            }
            else
            {
                Explode();
            }

            if (_flashTimer > 0)
            {
                _flashTimer -= Time.deltaTime;
            }
            else
            {
                flashSprite.Flash();
                _flashTimer = flashFrequencyCurve.Evaluate(_explodeTimer);
            }
        }
    }
コード例 #4
0
 void Flash(Color flashColor)
 {
     flashSprite.Flash(flashColor);
 }