예제 #1
0
 void OnItemSelected()
 {
     if (onItemEvent != null)
     {
         onItemEvent.Invoke("OnItemSelected");
     }
 }
예제 #2
0
    /// <summary>
    ///  Publishes current potions and ammo to gui
    /// </summary>
    private void PublishSelectedItems()
    {
        Item potionToPublish = null;

        if (selectedPotionUuid.Length > 0 && inventory.ContainsKey(selectedPotionUuid))
        {
            potionToPublish = inventory[selectedPotionUuid];
        }
        else
        {
            potionToPublish      = new Item();
            potionToPublish.uuid = EMPTY_POTION;
        }
        eventItem.Invoke(potionToPublish);

        Item ammoToPublish = null;

        if (selectedAmmoUuid.Length > 0 && inventory.ContainsKey(selectedAmmoUuid))
        {
            ammoToPublish = inventory[selectedPotionUuid];
        }
        else
        {
            ammoToPublish      = new Item();
            ammoToPublish.uuid = EMPTY_AMMO;
        }

        eventItem.Invoke(ammoToPublish);
    }
예제 #3
0
 public void SetItem(Item item, int count)
 {
     CurrentItem      = item;
     CurrentItemCount = count;
     OnItemGet.Invoke(item);
     OnItemCountChange.Invoke(count);
 }
예제 #4
0
    /// <summary>
    /// Notify to the inventory about a click on an item holder.
    /// </summary>
    /// <param name="holder"></param>
    public void NotifyClick(ItemHolder holder)
    {
        if (m_inventory.SelectedItem == holder)
        {
            return;
        }
        //Retrieve a reference to the holder inside the inventory
        var itemInInventory = Items.First((e) => e == holder);

        if (itemInInventory == null)
        {
            return;
        }

        //Show the selector
        var itemTransform = itemInInventory.transform;

        m_Selector.transform.position = itemTransform.position;
        m_Selector.SetActive(true);

        //Update the internal state of the Inventory
        m_inventory.SelectItem(holder.m_index);
        if (m_InfoLabelCoroutine != null)
        {
            StopCoroutine(m_InfoLabelCoroutine);
        }
        m_InfoLabelCoroutine = StartCoroutine(InfoLabelAnimation(holder.Item.Name));

        //Notify to all listeners
        OnItemSelected.Invoke(m_inventory.SelectedItem.Item);
    }
예제 #5
0
 public void AttemptUseItem()
 {
     if (currentItem != null)
     {
         OnUseItem.Invoke(currentItem);
     }
 }
예제 #6
0
    /// <summary>
    /// Add a new Item inside the inventory
    /// </summary>
    public void AddItem(Item newItem)
    {
        //Notify to all listeners
        m_inventory.AddItem(newItem);

        OnItemAdded.Invoke(newItem);
    }
예제 #7
0
        // This function is called by the LostItemReaction in order to remove an item from the inventory.
        public void RemoveItem(Item itemToRemove, float quantity = 1)
        {
            //If item is not present in inventory, inform and return
            if (!items.Contains(itemToRemove))
            {
                Debug.LogWarning("No item found to remove in Inventory: " + name + " with name: " + itemToRemove.name);
                return;
            }

            //Handle Item quantity only if it is stackable
            if (itemToRemove.isStackable)
            {
                float newQuantity = itemToRemove.currentQuantity - quantity;
                itemToRemove.currentQuantity = (newQuantity <= 0) ? 0 : newQuantity;
                //inventoryGUI.resetItemQuantity(itemToRemove);

                //remove the item from the inventory if the quantity is zero and is marked as removeIfEmpty
                if (itemToRemove.currentQuantity == 0 && itemToRemove.removeIfEmpty)
                {
                    items.Remove(itemToRemove);
                }

                return;
            }

            // Remove the Item (isUnique or non stackable Item cases)
            items.Remove(itemToRemove);
            OnRemoveItem.Invoke(itemToRemove);
            //inventoryGUI.removeItem(itemToRemove);
        }
예제 #8
0
 public virtual void AddItem(T item)
 {
     if (!Items.Contains(item))
     {
         Items.Add(item);
         OnAddItem.Invoke(item);
     }
 }
예제 #9
0
 public virtual void RemoveItem(T item)
 {
     if (Items.Contains(item))
     {
         Items.Remove(item);
         OnRemoveItem.Invoke(item);
     }
 }
예제 #10
0
 public void AttemptDrop()
 {
     if (currentItem != null)
     {
         currentItem.Drop(this);
         OnDropItem.Invoke(currentItem);
     }
 }
예제 #11
0
    public virtual void UIClicked(ItemUI iui)
    {
        itemSelected.Invoke(iui.item);  // referece to the item linked to the invoked ItemUI

        //Inventory.playerInventory.Add(iui.item);
        //inventory.Remove(iui.item);
        //Destroy(iui.gameObject);
    }
예제 #12
0
 public void HandleLootboxItemClicked(Item item)
 {
     if (!item.TryEquip(character))
     {
         items.Add(item);
         OnItemAddedToInventory.Invoke(item);
     }
 }
예제 #13
0
    public virtual void UIClicked(ItemUI iui)
    {
        itemSelected.Invoke(iui.item);

        //Inventory.playerInventory.Add(iui.item);
        //inventory.Remove(iui.item);

        Destroy(iui.gameObject);
    }
 public void TriggerItemEvent(CollectibleItem.ItemID id, int amt)
 {
     if (id == CollectibleItem.ItemID.Invalid || id == CollectibleItem.ItemID.kCount)
     {
         Debug.LogError("Triggering Item Event with invalid id: " + id);
         return;
     }
     m_itemGainedEvent.Invoke(id, amt);
 }
예제 #15
0
 public void UseItem()
 {
     if (CurrentItemCount > 0 && CurrentItem != null && CanUseItem && !Input.GetButton(Constants.Input.ActivateAbilityKeyboard))
     {
         InstantiateItem();
         SetCount(CurrentItemCount - 1);
         OnItemUse.Invoke(CurrentItem);
         StartCoroutine(AntiSpamRoutine());
     }
 }
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player" && other.GetComponent <BackPackBehaviour>().Items.Count < other.GetComponent <BackPackBehaviour>().Capacity)
     {
         print("Collision");
         ItemBehaviour b = this.GetComponent <ItemBehaviour>();
         OnEvent.Invoke(b.ItemRuntime);
         other.gameObject.GetComponent <BackPackBehaviour>().AddItem(b.ItemRuntime);
         Destroy(Prefab);
     }
 }
예제 #17
0
    public static void declancherEvenement(string nomEvenement, int idObjet, string nomJoueur)
    {
        ItemEvent evenement = null;

        dictionnaireEvenement.TryGetValue(nomEvenement, out evenement);
        if (evenement != null)
        {
            evenement.Invoke(idObjet, nomJoueur);
        }
        else
        {
            Debug.LogError(nomEvenement + " existe pas");
        }
    }
        /*--------------------------------------------------------------------------------------------*/
        public void RemoveItem(HoverItem pItem)
        {
            if (vItems == null)
            {
                return;
            }

            if (!vItems.Remove(pItem))
            {
                Debug.LogWarning("Cannot remove missing item '" + pItem.name + "'.", pItem);
                return;
            }

            OnItemRemoved.Invoke(pItem);
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public void AddItem(HoverItem pItem)
        {
            if (vItems == null)
            {
                return;
            }

            if (vItems.Contains(pItem))
            {
                Debug.LogWarning("Cannot add duplicate item '" + pItem.name + "'.", pItem);
                return;
            }

            vItems.Add(pItem);
            OnItemAdded.Invoke(pItem);
        }
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Item")
     {
         gotItem.Invoke(other.GetComponent <ItemScript>().getTypeOfItem(), other.transform.position);
         foreach (GameObject item in gm.IC.SpawnedItems)
         {
             if (item == other.transform.parent.gameObject)
             {
                 gm.IC.SpawnedItems.Remove(item);
                 break;
             }
         }
         Destroy(other.transform.parent.gameObject);
     }
 }
예제 #21
0
        // This function is called by the PickedUpItemReaction in order to add an item to the inventory.
        public void AddItem(Item itemToAdd, float quantity = 1)
        {
            if (!isValidItem(itemToAdd))
            {
                return;
            }

            // The item is already present in the inventory
            if (items.Contains(itemToAdd))
            {
                // is Unique
                if (itemToAdd.isUnique)
                {
                    Debug.Log("The item: " + itemToAdd.name + " is tagged as Unique and is already present in the inventory: " + this.inventoryItemList.name);
                }

                // Stackable Object
                if (itemToAdd.isStackable)
                {
                    float quantityToAdd = itemToAdd.currentQuantity + quantity;
                    itemToAdd.currentQuantity = (quantityToAdd >= itemToAdd.maxQuantity) ? itemToAdd.maxQuantity : quantityToAdd;

                    //inventoryGUI.resetItemQuantity(itemToAdd);
                }

                return;
            }


            // Inventory is full
            if (fixedSize && items.Count == numItemSlots)
            {
                return;
            }


            // If we get here, it means that item can be added to the inventory
            items.Add(itemToAdd);
            OnAddItem.Invoke(itemToAdd);
            // inventoryGUI.addItem(itemToAdd);
        }
예제 #22
0
파일: HoverItem.cs 프로젝트: OranBar/MyRoom
        /*--------------------------------------------------------------------------------------------*/
        private void UpdateWithLatestItemTypeIfNeeded()
        {
            if (_ItemType == vPrevItemType)
            {
                return;
            }

            HoverItemData newData = BuildData(_ItemType);

            TransferData(newData);
            DestroyData(_Data, newData);

            _Data = newData;

            if (OnTypeChanged != null)
            {
                OnTypeChanged.Invoke(this);
            }

            vPrevItemType = _ItemType;
        }
예제 #23
0
 protected override void ImmediateReaction(ref Interactable publisher)
 {
     inventory.RemoveItem(item);
     OnItemLost.Invoke(item);
 }
 protected override void ImmediateReaction(ref Interactable publisher)
 {
     inventory.AddItem(item);
     OnItemPickUp.Invoke(item);
 }
예제 #25
0
 public void GiveItem(Item item)
 {
     _inventory.Add(item);
     AddedItemEvent.Invoke(item);
 }
예제 #26
0
 public void RemoveItem(Item item)
 {
     _inventory.Remove(item);
     RemovedItemEvent.Invoke(item);
 }
예제 #27
0
 private void OnUnSelectedSlot()
 {
     OnUnselect.Invoke(currentSlot.item);
 }
예제 #28
0
 public virtual void UIClicked(ItemUI iui)
 {
     itemSelected.Invoke(iui.item);
 }
예제 #29
0
 public virtual void AddItem(Item item)
 {
     items.Add(item);
     OnAddItem?.Invoke(item, this);
 }
예제 #30
0
 public void OnEventRaised(Item value)
 {
     Response.Invoke(value);
 }