Пример #1
0
 public virtual void Attack(Adventurer target)
 {
     if (weapon == null)
     {
         //We have no weapon equipped, so let's tell the player
         Debug.Log(adventurerName + " has no weapon equipped!");
     }
     else
     {
         //Rather than having a big chunk of code here, we can instead run a different function - which is much cleaner to look at and easier to fix.
         DealDamage(target);
     }
 }
Пример #2
0
        public virtual void DealDamage(Adventurer target)
        {
            float damage = Random.Range(weapon.minDamage, weapon.maxDamage);

            if (damage > target.armour)
            {
                Debug.Log(adventurerName + " does " + target.TakeDamage(damage) + " damage to " + target.adventurerName + " with their " + weapon.name + "!");
                Debug.Log(target.adventurerName + " has " + target.health + "HP remaining!");
            }
            else
            {
                //We didn't do enough damage to get through armour, so inform the player.
                Debug.Log(adventurerName + " could not penetrate " + target.adventurerName + "'s armour with their " + weapon.name + "!");
            }
        }