private void Awake() { instance = this; foreach (Slot _slot in defaultInvetory) { Items.Add(_slot.item, _slot.amount); itemAddedEvent.Invoke(_slot.item, _slot.amount); } }
public void ClearSelection() { if (activeTab.content.Selection != null) { onDeselect.Invoke(activeTab.content.Selection.data); activeTab.content.ClearSelection(); } //fighterTab.content.ClearSelection(); //weaponTab.content.ClearSelection(); //showEnhancerTab.content.ClearSelection(); //manipulatorTab.content.ClearSelection(); //drugTab.content.ClearSelection(); }
public void AddResource(ResourceType type, int amt) { switch (type) { case ResourceType.Gold: _amtGold += amt; GoldAmt.text = "Gold: " + _amtGold.ToString(); GoldGot.Invoke(amt); GetComponent <AudioSource>().clip = GameManager.Instance.GoldSoundEffect; GetComponent <AudioSource>().Play(); break; case ResourceType.Wood: _amtWood += amt; WoodAmt.text = "Amount of wood: " + _amtWood.ToString(); WoodGot.Invoke(amt); break; case ResourceType.Stone: _amtStone += amt; StoneAmt.text = "Amount of stone: " + _amtStone.ToString(); StoneGot.Invoke(amt); break; case ResourceType.Food: _amtFood += amt; FoodAmt.text = "Amount of food: " + _amtFood.ToString(); FoodGot.Invoke(amt); break; } }
private void OnTriggerEnter2D(Collider2D col) { if (col.gameObject.CompareTag("Item")) { Tag.Tags tag = col.GetComponent <Tag>().GetMyTag(); switch (tag) { case Tag.Tags.chave1: if (!InventarioFull()) { EncheInventário("Chave1"); col.GetComponent <DialogueTrigger>().TriggerDialogue(); Destroy(col.gameObject); keyEvent.Invoke(); } break; case Tag.Tags.chave2: if (!InventarioFull()) { EncheInventário("Chave2"); col.GetComponent <DialogueTrigger>().TriggerDialogue(); Destroy(col.gameObject); key2Event.Invoke(); } break; } } }
public void SetItem(int x, int y, Item item) { // lazy initialisation if (Items == null) { Items = new Item[Width][]; for (int i = 0; i < Width; i++) { Items[i] = new Item[Height]; } } Items[x][y] = item; // Fire Inventory Update event OnUpdate.Invoke(item, x, y); }
/// <summary> /// Used to trigger any 'CanRemove' events in the item, or inventory just before dropping this item. /// If any attached handler wishes to invalidate this check they must /// set the <see cref="PGIModel.CanPerformAction"/> flag to <c>false</c> /// in the provided model parameter. /// <seealso cref="PGISlotItem.OnCanRemove"/> /// <seealso cref="PGIModel.OnCanRemoveItem"/> /// </summary> /// <param name="storage">The <see cref="PGIModel"/> whose inventory this item is being removed from.</param> public void TriggerCanRemoveEvents(PGIModel storage) { OnCanRemove.Invoke(this, storage); if (storage != null) { storage.OnCanStoreItem.Invoke(this, storage); } }
/// <summary> /// Used to trigger any OnStoreInInventoryFailed events for this item, /// and the associated inventory. /// <seealso cref="PGISlotItem.OnStoreInInventoryFailed"/> /// <seealso cref="PGIModel.OnStoreItemFailed"/> /// </summary> /// <param name="storage">The <see cref="PGIModel"/> whose inventory this item had attempted to enter.</param> public void TriggerStoreFailedEvents(PGIModel storage) { OnStoreInInventoryFailed.Invoke(this, storage); if (storage != null) { storage.OnStoreItemFailed.Invoke(this, storage); } }
/// <summary> /// Used to trigger any OnRemoved events for this item, /// and the associated inventory. /// <seealso cref="PGISlotItem.OnRemoveFromInventory"/> /// <seealso cref="PGIMode.OnRemoveItem"/> /// </summary> /// <param name="storage">The <see cref="PGIModel"/> whose inventory this item is being removed from.</param> public void TriggerRemoveEvents(PGIModel storage) { OnRemoveFromInventory.Invoke(this, storage); if (storage != null) { storage.OnRemoveItem.Invoke(this, storage); } }
private void Start() { UpdateVisuals(); foreach (ItemButton cell in cells) { cell.onBuy.AddListener((Item item) => onBuy?.Invoke(item)); cell.onSelect.AddListener((Item item) => onSelect?.Invoke(item)); } }
private void Update() { if (isInRange) { if (Input.GetKeyDown(interactKey)) { interactAction.Invoke(invokerInventory); } } }
private void Start() { foreach (ItemsRawWidget raw in raws) { raw.onBuy.AddListener((Item item) => onBuy?.Invoke(item)); raw.onSelect.AddListener((Item item) => onSelect?.Invoke(item)); } ShowHats(); }
public void AddItemAsAvailable(Item item) { if (!item) { return; } if (!availableItems.ContainsKey(item.id) && !unavailableItems.ContainsKey(item.id)) { availableItems.Add(item.id, item); } onAddAvailableItem?.Invoke(item); }
void ProceedClick() { if (item) { if (bought) { onSelect?.Invoke(item); } else { onBuy?.Invoke(item); } } }
public static void AddInteractable(CollectableItem interactable) { interactables.Add(interactable); CurrentWeight += interactable.Weight < 0 ? 0 : interactable.Weight; if (CurrentWeight >= MaximumWeight && MaximumWeight > 0) { IsFull = true; } else { IsFull = false; } OnAddItemToInventoryEvent?.Invoke(interactable); }
public void InventoryAdd(string name, int quantity) { foreach (var item in itemMetaList.items) //Find the Item in the Meta list based on String reference, add X of it to the inventory { if (item.name == name) { //items.Add(new InventoryItem(item, quantity)); Add(item, quantity); Debug.Log("Adding to Inventory: " + item.name); break; } } OnItemChanged?.Invoke(); }
public void RemoveItem(Item item, int amount = 1) { if (item == null) { return; } if (items.ContainsKey(item)) { int _amount = amount; if (items[item] < _amount) { _amount = items[item]; } items[item] -= _amount; itemRemovedEvent.Invoke(item, _amount); } }
// Selects clicked element and deselects others private void OnSelectElement(Element element, Content content) { if (fighterTab.content != content) { fighterTab.content.ClearSelection(); } if (weaponTab.content != content) { weaponTab.content.ClearSelection(); } if (showEnhancerTab.content != content) { showEnhancerTab.content.ClearSelection(); } if (manipulatorTab.content != content) { manipulatorTab.content.ClearSelection(); } // if (drugTab.content != content) // drugTab.content.ClearSelection(); Selection = element; onSelect.Invoke(element); }
public void addToInventory(ItemScript item) { bool found = false; foreach (ItemScript i in inventory) { if (i.itemName == item.itemName) { i.AddItem(); i.OnPickUp(); //Debug.Log("Player has item " + item.itemName +" Count: "+i.count); InventoryEvent?.Invoke(inventory); found = true; } } //Debug.Log("Adding " + item.itemName + " to inventory first time."); if (!found) { inventory.Add(item); item.AddItem(); item.OnPickUp(); InventoryEvent?.Invoke(inventory); } }
/// <summary> /// Add item to the inventory /// </summary> /// <param name="itemPos">Index to add the item</param> /// <param name="item">Item to add</param> public virtual void AddItem(int itemPos, Item item, InventorySlot slot) { inventory[itemPos] = item; slot.AddItemToSlot(item); onInventoryChange.Invoke(); }