public CollectableSO GetItemInSlot(int slotNo) { CollectableSO value = null; mInventory.TryGetValue(slotNo, out value); return(value); }
public RepairItems(CollectableSO cooling, CollectableSO core, CollectableSO spaceTimeComp, CollectableSO circuit, CollectableSO antenna) { Cooling = cooling; Core = core; SpaceTimeComp = spaceTimeComp; Circuit = circuit; Antenna = antenna; }
private int FindIndexFor(CollectableSO item) { foreach (var cur in mInventory) { if (cur.Value.Equals(item)) { return(cur.Key); } } return(-1); }
public bool AddItem(int slotNo, CollectableSO item) { Predicate <int> slotNoEmpty = sNo => mInventory.ContainsKey(sNo); if (itemNotNull(item) && slotNoEmpty(slotNo)) { mInventory.Add(slotNo, item); OnInventoryChanged.Invoke(this, new InventoryObject(slotNo, item)); mSound.Play("Add"); return(true); } return(false); }
//################# //## INTERFACE ## //################# public bool AddItem(CollectableSO item) { int slot = FindNextOpenSlot(); if (itemNotNull(item) && slotAvailable(slot)) { mInventory.Add(slot, item); OnInventoryChanged.Invoke(this, new InventoryObject(slot, item)); mSound.Play("Add"); return(true); } return(false); }
private void OnTriggerEnter2D(Collider2D other) { ICollectable col = other.GetComponent <ICollectable>(); if (col != null) { CollectableSO so = col.OnCollect(); if (so == null) { return; } if (mInventory.AddItem(so)) { mAudioSource.Play(); Destroy(other.gameObject); } else { col.IsCollected = false; } } }
public InventoryObject(int slotNo, CollectableSO item) { SlotNo = slotNo; Item = item; }
public void RemoveItem(CollectableSO item) { RemoveItem(FindIndexFor(item)); }