Beispiel #1
0
        public void EquipItem(NeoInventoryEquippableItem item)
        {
            // Do nothing if already equipped
            if (equipped != null && equipped.inventoryItem == item)
            {
                return;
            }

            if (item == null)
            {
                equipped = m_Fallback;
                return;
            }

            for (int i = 0; i < m_Items.Count; ++i)
            {
                if (m_Items[i] != null && m_Items[i].inventoryItem == item)
                {
                    equipped = m_Items[i];
                    return;
                }
            }

            if (item.firstPersonPrototype != null)
            {
                var instance = Instantiate(item.firstPersonPrototype, Vector3.zero, Quaternion.identity, itemRoot);
                instance.Attach(this, item);
                m_Items.Add(instance);
                equipped = instance;
            }
        }
Beispiel #2
0
        public void Attach(NeoInventoryFirstPersonItemHandler h, NeoInventoryEquippableItem i)
        {
            handler       = h;
            inventoryItem = i;

            var t = transform;

            t.SetParent(handler.itemRoot);
            t.localPosition = Vector3.zero;
            t.localRotation = Quaternion.identity;
            t.localScale    = Vector3.one;
        }
Beispiel #3
0
 public void Detach()
 {
     handler       = null;
     inventoryItem = null;
     gameObject.SetActive(false);
 }
Beispiel #4
0
 public void UnequipItem(NeoInventoryEquippableItem item)
 {
     equipped = null;
 }