public void UnEquip(EquippableItem item)
 {
     if (!inventory.IsFull() && equipmentPanel.RemoveItem(item))
     {
         item.UnEquip(character);
         character.StatPanel.UpdateStatValues();
         inventory.AddItem(item);
     }
 }
        // TODO Rework this later to only be used when a character first logs in. A different system will be needed to ensure previously equipped items from last login remain equipped.
        public void EquipStartingItems(EquippableItem item)
        {
            EquippableItem previousItem;

            if (equipmentPanel.AddItem(item, out previousItem))
            {
                OnItemEquipped(item);
                item.Equip(character);
                character.StatPanel.UpdateStatValues();
            }
        }
示例#3
0
 void CheckForCorrectEquipmentType(EquipmentType equipmentType, EquippableItem item)
 {
     if (equipmentType == gearSlotEquipmentType)
     {
         if (equipmentType == EquipmentType.PrimaryWeapon)
         {
             OnPrimaryWeaponEquipped(item);
         }
         AttachClothingAnimations(item.AnimationClips);
         item.ItemUnEquipped += RemoveCurrentAnimations;
     }
 }
示例#4
0
 public bool RemoveItem(EquippableItem item)
 {
     for (int i = 0; i < equipmentSlots.Length; i++)
     {
         if (equipmentSlots[i].Item == item)
         {
             equipmentSlots[i].Item = null;
             return(true);
         }
     }
     return(false);
 }
示例#5
0
 public bool AddItem(EquippableItem item, out EquippableItem previousItem)
 {
     for (int i = 0; i < equipmentSlots.Length; i++)
     {
         if (equipmentSlots[i].EquipmentType == item.EquipmentType)
         {
             previousItem           = (EquippableItem)equipmentSlots[i].Item;
             equipmentSlots[i].Item = item;
             return(true);
         }
     }
     previousItem = null;
     return(false);
 }
        void Drop(ItemSlot dropItemSlot)
        {
            if (draggedSlot == null)
            {
                return;
            }

            if (dropItemSlot.CanReceiveItem(draggedSlot.Item) && draggedSlot.CanReceiveItem(dropItemSlot.Item))
            {
                EquippableItem dragItem = draggedSlot.Item as EquippableItem;
                EquippableItem dropItem = dropItemSlot.Item as EquippableItem;

                if (draggedSlot is EquipmentSlot)
                {
                    if (dragItem != null)
                    {
                        dragItem.UnEquip(character);
                    }
                    if (dropItem != null)
                    {
                        dropItem.Equip(character);
                    }
                }

                if (dropItemSlot is EquipmentSlot)
                {
                    if (dragItem != null)
                    {
                        OnItemEquipped(dragItem);
                        dragItem.Equip(character);
                    }
                    if (dropItem != null)
                    {
                        dropItem.UnEquip(character);
                    }
                }
                character.StatPanel.UpdateStatValues();

                Item draggedItem = draggedSlot.Item;
                draggedSlot.Item  = dropItemSlot.Item;
                dropItemSlot.Item = draggedItem;
            }
        }
 public void Equip(EquippableItem item)
 {
     if (inventory.RemoveItem(item))
     {
         EquippableItem previousItem;
         if (equipmentPanel.AddItem(item, out previousItem))
         {
             if (previousItem != null)
             {
                 inventory.AddItem(previousItem);
                 previousItem.UnEquip(character);
                 character.StatPanel.UpdateStatValues();
             }
             OnItemEquipped(item);
             item.Equip(character);
             character.StatPanel.UpdateStatValues();
         }
         else
         {
             inventory.AddItem(item);
         }
     }
 }
示例#8
0
        public void RemoveCurrentAnimations(EquipmentType equipmentType, EquippableItem item)
        {
            animatorOverrideController["BaseCharacterMaleCastDown"]  = null;
            animatorOverrideController["BaseCharacterMaleCastLeft"]  = null;
            animatorOverrideController["BaseCharacterMaleCastRight"] = null;
            animatorOverrideController["BaseCharacterMaleCastUp"]    = null;

            animatorOverrideController["BaseCharacterMaleDeath"] = null;

            animatorOverrideController["BaseCharacterMaleIdleDown"]  = null;
            animatorOverrideController["BaseCharacterMaleIdleLeft"]  = null;
            animatorOverrideController["BaseCharacterMaleIdleRight"] = null;
            animatorOverrideController["BaseCharacterMaleIdleUp"]    = null;

            animatorOverrideController["BaseCharacterMaleShootDown"]  = null;
            animatorOverrideController["BaseCharacterMaleShootLeft"]  = null;
            animatorOverrideController["BaseCharacterMaleShootRight"] = null;
            animatorOverrideController["BaseCharacterMaleShootUp"]    = null;

            animatorOverrideController["BaseCharacterMaleSlashDown"]  = null;
            animatorOverrideController["BaseCharacterMaleSlashLeft"]  = null;
            animatorOverrideController["BaseCharacterMaleSlashRight"] = null;
            animatorOverrideController["BaseCharacterMaleSlashUp"]    = null;

            animatorOverrideController["BaseCharacterMaleWalkDown"]  = null;
            animatorOverrideController["BaseCharacterMaleWalkLeft"]  = null;
            animatorOverrideController["BaseCharacterMaleWalkRight"] = null;
            animatorOverrideController["BaseCharacterMaleWalkUp"]    = null;

            Color c = spriteRenderer.color;

            c.a = 0;
            spriteRenderer.color = c;
            item.ItemUnEquipped -= RemoveCurrentAnimations;
            item.ItemEquipped   -= CheckForCorrectEquipmentType;
            OnPrimaryWeaponUnEquipped();
        }
示例#9
0
 void RegisterEquippedItemEvent(EquippableItem item)
 {
     item.ItemEquipped += CheckForCorrectEquipmentType;
 }
示例#10
0
 void SetWeapon(EquippableItem item)
 {
     primaryWeapon = item as Weapon;
 }