Esempio n. 1
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);
         }
         if (equipmentSlots[i] != null)
         {
             UpdateCharacterEquip(equipmentSlots[i], item);
         }
         if (item is Armor)
         {
             _defence = (item as Armor).GetDefence();     //TODO get defence working
         }
         //Equip Gameobject
         if (equipmentSlots[3] != item)
         {
             Transform hand = player.umaData.skeleton.GetBoneGameObject(UMASkeleton.StringToHash("RightHand")).transform;
             if (currentMainHand != item.GetItemPrefab() | currentMainHand == null)
             {
                 if (currentMainHand != null & currentMainHand != item.GetItemPrefab())
                 {
                     Destroy(_item.gameObject);
                 }
                 _item = item.GetItemPrefab();
                 _item = Instantiate(item.GetItemPrefab(), hand);
                 _item.transform.SetParent(hand);
                 _item.transform.localPosition = hand.transform.localPosition - new Vector3(-0.158f, 0.1f, 0.05f);     //new Vector3(-0.158f, 0.372f, -0.02f);
                 _item.transform.localRotation = Quaternion.Euler(new Vector3(-0.02f, 356f, 8.12f));
                 currentMainHand = item.GetItemPrefab();
             }
         }
     }
     previousItem = null;
     return(false);
 }