Example #1
0
 public static GameObject makeItem(Equipment equipment)
 {
     GameObject item = GameObject.Instantiate(Resources.Load("ui/InventoryItem", typeof(GameObject))) as GameObject;
     item.GetComponent<InventoryItem>().init(equipment);
     item.transform.localPosition = Positions.CENTER;
     return item;
 }
Example #2
0
 private void addItem(Equipment eqipment)
 {
     var newItem = InventoryItemFactory.makeItem(eqipment);
     newItem.transform.SetParent(itemCont);
     newItem.transform.localScale = Vector3.one;
     inventoryItems.Add(newItem.GetComponent<InventoryItem>());
 }
Example #3
0
        public void dequip(Equipment item)
        {
            if (!item.equipped)
            {
                Debug.LogError("cant dequip weapon that is not equiped");
                return;
            }

            int slotID = (int)item.slot;
            equipped[slotID].equipped = false;
            equipped[slotID] = null;
        }
Example #4
0
        public void equip(Equipment item)
        {
            if (item.equipped)
            {
                Debug.LogError("itm already equiped!");
                return;
            }

            int slotID = (int)item.slot;
            if (equipped[slotID] != null)
                dequip(equipped[slotID]);

            equipped[slotID] = item;
            equipped[slotID].equipped = true;
        }
Example #5
0
 private void onItemHold(Equipment equipment)
 {
     itemInfo.init(equipment);
 }
Example #6
0
 private void onItemTap(Equipment equipment)
 {
     if (equipment.equipped)
     {
         playerModel.dequip(equipment);
     }
     else
     {
         playerModel.equip(equipment);
     }
     updateView();
 }
Example #7
0
 public void updateView(Equipment equipment)
 {
     slots[(int)equipment.slot].init(equipment);
 }
Example #8
0
 public void dropItem(Equipment item)
 {
     inventory.Remove(item);
 }
Example #9
0
 private void pickUpItem(Equipment item)
 {
     inventory.Add(item);
 }
Example #10
0
 public void init(Equipment equipment)
 {
     this.infoText.text = equipment.description;
     gameObject.SetActive(true);
 }