/// <summary>
    /// Event for when the player uses the held item
    /// </summary>
    public void UseItem()
    {
        bool itemUsedUp; // Check if the item is "used up" / has no more uses

        // If the item type is a Turret
        GameObject instantiatedItem;

        if (selectedItem.itemType == ItemType.Turret)
        {
            // Instantiate the turret
            // This Utilises "SpawnTurret" prefabs
            // These are empty GameObjects with the SpawnTurret script attached
            // They instantiate the turret, and are destroyed after
            instantiatedItem = Instantiate(selectedItem.usableObject);
            Destroy(instantiatedItem);
        }

        // Broadcast event
        if (ItemUseEvent != null)
        {
            ItemUseEvent.Invoke(this, new InventoryEventArgs(InventoryEventType.Use, selectedItem));
        }

        // If the item duration is 0, remove the item
        itemUsedUp = selectedItem.UseItem();
        if (itemUsedUp && enableItemDuration)
        {
            RemoveItem();
        }
    }
Esempio n. 2
0
 public void activateItem()
 {
     if (HeldItem != null && !HeldItem.isOnCooldown)
     {
         HeldItem.activateItem();
         onItemUse?.Invoke(HeldItem);
         ItemUseEvent?.Invoke();
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Uses the item, inflicting the EntityEffect on the designated entities
        /// </summary>
        /// <param name="User">The BattleEntity that used the Item</param>
        /// <param name="Entities">The BattleEntities affected by the Item</param>
        public void OnUse(BattleEntity User, params BattleEntity[] Entities)
        {
            //Call use event
            ItemUseEvent?.Invoke(this, User);

            if (Entityeffect == null)
            {
                Debug.LogError($"Item {Name}'s EntityEffect is null!");
                return;
            }

            Entityeffect.UseEffect(new Globals.AffectableInfo(User, this), Entities);
        }
Esempio n. 4
0
 public void ReleaseRightClickEvent(Entity entity, Vector2 pos)
 {
     ReleaseRightClick.Invoke(entity, pos);
 }
Esempio n. 5
0
 public void OnRightClickEvent(Entity entity, Vector2 pos)
 {
     OnRightClick.Invoke(entity, pos);
 }
Esempio n. 6
0
 public bool Use(GameObject g, RaycastHit h)
 {
     OnUse.Invoke(g, h);
     return(OnUse.GetPersistentEventCount() != 0);
 }