コード例 #1
0
    //Update the player's currentHealth and animate their health bar.
    //The red health bar changes to the new currentHealth value immediately.
    //AnimateHealthBar is then called to inform behvaior of the yellow bar
    public override void TakeDamage(float damageTaken, Energy.Elements element)
    {
        previousHealth = currentHealth;
        currentHealth -= damageTaken * elementalWeaknesses[(int)element];

        if (currentHealth < 0)
        {
            currentHealth = 0;
        }

        healthBarObject.transform.localScale = new Vector3(currentHealth * (1.0f / maxHealth), healthBarObject.transform.localScale.y, healthBarObject.transform.localScale.z);

        //Reset time passed and position for animating yellow bar to interrupt any previous animation
        currentAnimatedHealth = previousHealth;
        damageTakenObject.transform.localScale = new Vector3(previousHealth * (1.0f / maxHealth), damageTakenObject.transform.localScale.y, damageTakenObject.transform.localScale.z);
        healthDrainAnimationTimePassed         = 0;
    }
コード例 #2
0
ファイル: Battle_Character.cs プロジェクト: ZapKanon/Node-Old
    // Update is called once per frame
    //void Update()
    //{

    //}

    public virtual void TakeDamage(float damageTaken, Energy.Elements element)
    {
        currentHealth -= damageTaken * elementalWeaknesses[(int)element];
    }