예제 #1
0
 public void SetUp()
 {
     currentHP      = maxHP;
     currentShield  = startingShield;
     behaviorStep   = startingStep;
     preparedAction = behavior[behaviorStep];
     if (preparedAction == PreparedAction.Attack)
     {
         RollDamage();
     }
     EnemyUIUpdate?.Invoke();
 }
예제 #2
0
    public void TakeDamage(int damageTaken)
    {
        if (currentShield > 0)
        {
            int shld = currentShield;
            currentShield -= damageTaken;
            if (currentShield < 0)
            {
                int carryoverDamage = currentShield;
                currentHP += carryoverDamage; //any negative shield is carried over as HP damage
                DamageNumber?.Invoke(shld, DmgNumbers.shieldDamageColor);
                if (carryoverDamage != 0)
                {
                    DamageNumber?.Invoke(-1 * carryoverDamage, DmgNumbers.damageColor);
                }
                currentShield = 0;
            }
            else
            {
                DamageNumber?.Invoke(damageTaken, DmgNumbers.shieldDamageColor);
            }
        }
        else
        {
            currentHP -= damageTaken;
            DamageNumber?.Invoke(damageTaken, DmgNumbers.damageColor);
        }

        if (currentHP <= 0)
        {
            HighScore highScore = FindObjectOfType <HighScore>();
            highScore.IncreaseHighScore();
            Die?.Invoke();
        }
        EnemyUIUpdate?.Invoke();
    }
예제 #3
0
 public void Shield(Enemy target, int shieldAmount) //overload for shielding another enemy
 {
     target.currentShield += shieldAmount;
     EnemyUIUpdate?.Invoke();
 }
예제 #4
0
 public void Shield(int shieldAmount)
 {
     currentShield += shieldAmount;
     EnemyUIUpdate?.Invoke();
 }