Пример #1
0
        int maxHealth; // THe maximum health the entity has

        #endregion Fields

        #region Constructors

        // Constructor; Derived classes create an entity object
        public Hostile(int ID, GameObject gameObject)
            : base(ID, gameObject)
        {
            // Get the GameObject's ally script
            allyScript = GameObj.GetComponent<AllyList>();

            #region IEquipment Variable Initialisation

            // The entity isn't wearing any armour, wielding any weapon, or has any bonuses
            equippedArmor = null;
            equippedWeapon = null;
            bonuses = new List<Bonus>();
            attackPower = 0;
            defencePower = 0;

            #endregion

            #region IDamageable Variable Initialisation

            // The default hard coded values for now.
            health = 50;
            maxHealth = 50;
            isDead = false;

            #endregion
        }
        MercenaryMB script; // THe script reference for the Mimic enemy.

        #endregion Fields

        #region Constructors

        // Constructor used to create a Mercenary entity
        public Mercenary(int ID, GameObject gameObject)
            : base(ID, gameObject)
        {
            // Set the entity's type to Mercenary
            Type = EntityType.Mercenary;

            // Also set the entity's friendly type
            FriendlyType = Entities.FriendlyType.Mercenary;

            // Set the entity's script reference
            script = GameObj.GetComponent<MercenaryMB>();

            #region IEquipment Variable Initialisation

            // The entity isn't wearing any armour, wielding any weapon, or has any bonuses
            equippedArmor = null;
            equippedWeapon = null;
            bonuses = new List<Bonus>();
            attackPower = 0;
            defencePower = 0;

            #endregion
        }
 // Unequips a piece of armour for an entity
 public void UnequipArmor(Armor armor)
 {
     // Only unequip the armour if the merchant is wearing any
     if (equippedArmor != null)
     {
         // Unequip the given armour
         defencePower -= armor.DefenceValue;
         equippedArmor = null;
     } // end if
 }
        // Equips a piece of armour for an entity
        public void EquipArmor(Armor armor)
        {
            // Check if the merchant is wearing armour
            if (equippedArmor == null)
            {
                // The merchant isn't wearing armor so just equip the given armour
                defencePower += armor.DefenceValue;
                equippedArmor = armor;
            } // end if
            else
            {
                // The merchant is already wearing armour so unequip it first
                UnequipArmor(equippedArmor);

                // Now equip the given armour
                defencePower += armor.DefenceValue;
                equippedArmor = armor;
            } // end else
        }