예제 #1
0
        /**
         * Equips a shield on a character.
         * @param charData the character data
         * @ if an error occurs
         */
        private void EquipShield(IOCharacter charData)
        {
            // unequip old shield
            UnequipItemInSlot(charData, EquipmentGlobals.EQUIP_SLOT_SHIELD);
            // equip new shield
            charData.SetEquippedItem(EquipmentGlobals.EQUIP_SLOT_SHIELD, io.RefId);
            // TODO - attach new shield to mesh
            // EERIE_LINKEDOBJ_LinkObjectToObject(target->obj,
            // io->obj, "SHIELD_ATTACH", "SHIELD_ATTACH", io);
            int wpnID =
                charData.GetEquippedItem(EquipmentGlobals.EQUIP_SLOT_WEAPON);

            if (wpnID >= 0)
            {
                if (Interactive.Instance.HasIO(wpnID))
                {
                    BaseInteractiveObject wpn = Interactive.Instance.GetIO(wpnID);
                    if (wpn.HasTypeFlag(EquipmentGlobals.OBJECT_TYPE_2H) ||
                        wpn.HasTypeFlag(EquipmentGlobals.OBJECT_TYPE_BOW))
                    {
                        // unequip old weapon
                        UnequipItemInSlot(charData, EquipmentGlobals.EQUIP_SLOT_WEAPON);
                    }
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Equips a weapon for a character.
 /// </summary>
 /// <param name="charData">the character data</param>
 private void EquipWeapon(IOCharacter charData)
 {
     // UnityEngine.Debug.Log("EquipWeapon");
     // unequip old weapon
     UnequipItemInSlot(charData, EquipmentGlobals.EQUIP_SLOT_WEAPON);
     // equip new weapon
     charData.SetEquippedItem(EquipmentGlobals.EQUIP_SLOT_WEAPON, io.RefId);
     // attach it to player mesh
     if (io.HasTypeFlag(EquipmentGlobals.OBJECT_TYPE_BOW))
     {
         // EERIE_LINKEDOBJ_LinkObjectToObject(
         // target->obj, io->obj,
         // "WEAPON_ATTACH", "TEST", io);
     }
     else
     {
         // EERIE_LINKEDOBJ_LinkObjectToObject(
         // target->obj,
         // io->obj,
         // "WEAPON_ATTACH", "PRIMARY_ATTACH", io); //
     }
     if (io.HasTypeFlag(EquipmentGlobals.OBJECT_TYPE_2H) ||
         io.HasTypeFlag(EquipmentGlobals.OBJECT_TYPE_BOW))
     {
         // for bows or 2-handed swords, unequip old shield
         UnequipItemInSlot(charData, EquipmentGlobals.EQUIP_SLOT_SHIELD);
     }
 }
예제 #3
0
 protected void UnequipItemInSlot(IOCharacter player, int slot)
 {
     // UnityEngine.Debug.Log("UnequipItemInSlot");
     if (player.GetEquippedItem(slot) >= 0)
     {
         int slotioid = player.GetEquippedItem(slot);
         UnityEngine.Debug.Log("slot io " + slotioid);
         if (Interactive.Instance.HasIO(slotioid))
         {
             BaseInteractiveObject equipIO = Interactive.Instance.GetIO(slotioid);
             if (equipIO.HasIOFlag(IoGlobals.IO_02_ITEM) &&
                 equipIO.ItemData != null)
             {
                 equipIO.ItemData.UnEquip(player.GetIo(), false);
             }
         }
     }
 }
예제 #4
0
        /**
         * Equips a ring on a character.
         * @param charData the character data
         * @ if an error occurs
         */
        private void EquipRing(IOCharacter charData)
        {
            // check left and right finger
            // to see if it can be equipped
            bool canEquip = true;
            int  ioid     = charData.GetEquippedItem(EquipmentGlobals.EQUIP_SLOT_RING_LEFT);

            if (Interactive.Instance.HasIO(ioid))
            {
                BaseInteractiveObject oldRing = Interactive.Instance.GetIO(ioid);
                if (oldRing.ItemData.RingType == RingType)
                {
                    // already wearing that type
                    // of ring on left finger
                    canEquip = false;
                }
            }
            if (canEquip)
            {
                ioid = charData.GetEquippedItem(EquipmentGlobals.EQUIP_SLOT_RING_RIGHT);
                if (Interactive.Instance.HasIO(ioid))
                {
                    BaseInteractiveObject oldRing = Interactive.Instance.GetIO(ioid);
                    if (oldRing.ItemData.RingType == RingType)
                    {
                        // already wearing that type
                        // of ring on right finger
                        canEquip = false;
                    }
                }
            }
            if (canEquip)
            {
                int equipSlot = -1;
                if (charData.GetEquippedItem(
                        EquipmentGlobals.EQUIP_SLOT_RING_LEFT) < 0)
                {
                    equipSlot = EquipmentGlobals.EQUIP_SLOT_RING_LEFT;
                }
                if (charData.GetEquippedItem(
                        EquipmentGlobals.EQUIP_SLOT_RING_RIGHT) < 0)
                {
                    equipSlot = EquipmentGlobals.EQUIP_SLOT_RING_RIGHT;
                }
                if (equipSlot == -1)
                {
                    if (!charData.GetIo().Inventory.LeftRing)
                    {
                        ioid = charData.GetEquippedItem(EquipmentGlobals.EQUIP_SLOT_RING_RIGHT);
                        if (Interactive.Instance.HasIO(ioid))
                        {
                            BaseInteractiveObject oldIO = Interactive.Instance.GetIO(ioid);
                            if (oldIO.HasIOFlag(IoGlobals.IO_02_ITEM))
                            {
                                UnequipItemInSlot(charData, EquipmentGlobals.EQUIP_SLOT_RING_RIGHT);
                            }
                        }
                        equipSlot = EquipmentGlobals.EQUIP_SLOT_RING_RIGHT;
                    }
                    else
                    {
                        ioid = charData.GetEquippedItem(EquipmentGlobals.EQUIP_SLOT_RING_LEFT);
                        if (Interactive.Instance.HasIO(ioid))
                        {
                            BaseInteractiveObject oldIO = Interactive.Instance.GetIO(ioid);
                            if (oldIO.HasIOFlag(IoGlobals.IO_02_ITEM))
                            {
                                UnequipItemInSlot(charData, EquipmentGlobals.EQUIP_SLOT_RING_LEFT);
                            }
                        }
                        equipSlot = EquipmentGlobals.EQUIP_SLOT_RING_LEFT;
                    }
                    charData.GetIo().Inventory.LeftRing = !charData.GetIo().Inventory.LeftRing;
                }
                charData.SetEquippedItem(equipSlot, io.RefId);
            }
        }