Beispiel #1
0
 public void StepBehavior()
 {
     //check to make sure shit hasn't just gone completely south
     if (behaviorStep + 1 >= behavior.Length || behaviorStep < 0)
     {
         //if it has, reset
         behaviorStep = 0;
     }
     else
     {
         //otherwise, business as normal.
         behaviorStep++;
         //loop behavior
         if (behaviorStep > behavior.Length)
         {
             behaviorStep = 0;
         }
     }
     preparedAction = behavior[behaviorStep];
     if (preparedAction == PreparedAction.Attack)
     {
         RollDamage();
     }
     EnemyUIUpdate?.Invoke();
 }
Beispiel #2
0
 public void SetUp()
 {
     currentHP      = maxHP;
     currentShield  = startingShield;
     behaviorStep   = startingStep;
     preparedAction = behavior[behaviorStep];
     if (preparedAction == PreparedAction.Attack)
     {
         RollDamage();
     }
     EnemyUIUpdate?.Invoke();
 }
Beispiel #3
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();
    }
Beispiel #4
0
 public void Shield(Enemy target, int shieldAmount) //overload for shielding another enemy
 {
     target.currentShield += shieldAmount;
     EnemyUIUpdate?.Invoke();
 }
Beispiel #5
0
 public void Shield(int shieldAmount)
 {
     currentShield += shieldAmount;
     EnemyUIUpdate?.Invoke();
 }