예제 #1
0
    /// <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();
        }
    }
예제 #2
0
        public ItemUseEvent ToBoltItemUseEventEvent(BoltEntity reciever)
        {
            ItemUseEvent evnt = ItemUseEvent.Create(reciever);

            evnt.Slot = SlotId;

            return(evnt);
        }
예제 #3
0
 public void activateItem()
 {
     if (HeldItem != null && !HeldItem.isOnCooldown)
     {
         HeldItem.activateItem();
         onItemUse?.Invoke(HeldItem);
         ItemUseEvent?.Invoke();
     }
 }
예제 #4
0
        public Item(ItemData itemData)
        {
            this.itemData = itemData;

            OnLeftClick       = new ItemUseEvent();
            OnRightClick      = new ItemUseEvent();
            ReleaseLeftClick  = new ItemUseEvent();
            ReleaseRightClick = new ItemUseEvent();

            InitializeModifiers();
        }
예제 #5
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);
        }
예제 #6
0
        // Not merged with EquipmentItem as this'll contain data on how to physically equip a weapon
        // Equipment items won't be physically equippable though, they'll just add to stats

        public override void Equip()
        {
            ItemUseEvent.Raise(this);
        }
예제 #7
0
 public static ItemUseData FromBoltEvent(ItemUseEvent evnt)
 {
     return(new ItemUseData(evnt.Slot));
 }
예제 #8
0
        public override void OnEvent(ItemUseEvent evnt)
        {
            ItemUseData data = ItemUseData.FromBoltEvent(evnt);

            Character.Inventory.SpawnPrimaryEffects(data);
        }