Ejemplo n.º 1
0
    public override void Equip(Tapestry_ItemData item, Tapestry_EquipSlot slot)
    {
        base.Equip(item, slot);

        if (slot == Tapestry_EquipSlot.LeftHand || slot == Tapestry_EquipSlot.RightHand)
        {
            GameObject obj = (GameObject)Instantiate(Resources.Load("Items/" + item.prefabName));

            //TODO: Dupe bug when switching hands
            if (slot == Tapestry_EquipSlot.LeftHand)
            {
                CleanEquippedItem(Tapestry_EquipSlot.LeftHand);
                obj.transform.SetParent(holdContainerLeft.transform);
                if (equippedLeft != null)
                {
                    equippedLeft = item;
                }
                else
                {
                    inventory.AddItem(equippedLeft, 1);
                    equippedLeft = item;
                }
            }
            if (slot == Tapestry_EquipSlot.RightHand)
            {
                CleanEquippedItem(Tapestry_EquipSlot.RightHand);
                obj.transform.SetParent(holdContainerRight.transform);
                if (equippedRight != null)
                {
                    equippedRight = item;
                }
                else
                {
                    inventory.AddItem(equippedLeft, 1);
                    equippedLeft = item;
                }
            }
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localRotation = Quaternion.identity;

            obj.layer = 8;
            foreach (Transform t in obj.transform)
            {
                t.gameObject.layer = 8;
            }
            foreach (Collider c in obj.GetComponentsInChildren <Collider>())
            {
                if (!c.isTrigger)
                {
                    c.enabled = false;
                }
            }
            foreach (Rigidbody rb in obj.GetComponentsInChildren <Rigidbody>())
            {
                Destroy(rb);
            }
        }
    }
Ejemplo n.º 2
0
 private void CleanEquippedItem(Tapestry_EquipSlot slot)
 {
     if (slot == Tapestry_EquipSlot.LeftHand)
     {
         foreach (Transform child in holdContainerLeft.transform)
         {
             Destroy(child.gameObject);
         }
     }
     if (slot == Tapestry_EquipSlot.RightHand)
     {
         foreach (Transform child in holdContainerRight.transform)
         {
             Destroy(child.gameObject);
         }
     }
 }
Ejemplo n.º 3
0
    public virtual void Equip(Tapestry_ItemData item, Tapestry_EquipSlot slot)
    {
        if (ReferenceEquals(equipmentProfile, null))
        {
            equipmentProfile = (Tapestry_EquipmentProfile)ScriptableObject.CreateInstance("Tapestry_EquipmentProfile");
        }

        //foreach(Tapestry_ItemStack id in inventory.items)
        for (int i = inventory.items.Count - 1; i >= 0; i--)
        {
            if (inventory.items[i].item.Equals(item))
            {
                equipmentProfile.Equip(slot, item);
                inventory.RemoveItem(item, 1);
            }
        }
    }
Ejemplo n.º 4
0
 public override void UnequipAndDestroy(Tapestry_EquipSlot slot)
 {
     CleanEquippedItem(slot);
     base.UnequipAndDestroy(slot);
 }
Ejemplo n.º 5
0
 public virtual void UnequipAndDestroy(Tapestry_EquipSlot slot)
 {
     equipmentProfile.Equip(slot, null);
 }
Ejemplo n.º 6
0
 public virtual void Unequip(Tapestry_EquipSlot slot)
 {
     inventory.AddItem(equipmentProfile.GetInSlot(slot), 1);
     equipmentProfile.Equip(slot, null);
 }