Exemplo n.º 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();
        }
    }
Exemplo n.º 2
0
        public ItemUseEvent ToBoltItemUseEventEvent(BoltEntity reciever)
        {
            ItemUseEvent evnt = ItemUseEvent.Create(reciever);

            evnt.Slot = SlotId;

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

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

            InitializeModifiers();
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 7
0
 public static ItemUseData FromBoltEvent(ItemUseEvent evnt)
 {
     return(new ItemUseData(evnt.Slot));
 }
Exemplo n.º 8
0
        public override void OnEvent(ItemUseEvent evnt)
        {
            ItemUseData data = ItemUseData.FromBoltEvent(evnt);

            Character.Inventory.SpawnPrimaryEffects(data);
        }