コード例 #1
0
ファイル: ItemPlacerComponent.cs プロジェクト: Rixium/Mayday
        public void MouseDown(MouseButton button)
        {
            if (button != MouseButton.Left || Time.GameTime.TotalGameTime.TotalSeconds < _lastPlaced + 0.5f)
            {
                return;
            }

            var itemPlacer = ItemPlacers.FirstOrDefault(x => x.PlacerFor(SelectedItem));

            if (itemPlacer == null)
            {
                return;
            }

            var(i, y, _, _) = MouseState.Bounds(_camera.GetMatrix());
            var mouseTileX = i / GameWorld.TileSize;
            var mouseTileY = y / GameWorld.TileSize;

            if (!itemPlacer.Place(Entity, GameWorld, SelectedItem, mouseTileX, mouseTileY))
            {
                return;
            }

            YetiGame.ContentManager.Load <SoundEffect>("place").Play();
            ItemUsed?.Invoke(SelectedItem);
            _lastPlaced = Time.GameTime.TotalGameTime.TotalSeconds;
        }
コード例 #2
0
        /// <summary>
        ///     Uses the item, if it can be used.
        /// </summary>
        public void Use()
        {
            if (!CanBeUsed())
            {
                return;
            }

            // play some nice vfx to support item
            foreach (ParticleSystem system in _onUseVFX)
            {
                system.Play();
            }

            UseInternal();
            // instant use means cooldown starts directly after usage, otherwise cooldown starts after effect has stopped
            if (_model.InstantUse)
            {
                StartCooldown();
            }
            else
            {
                _isActive          = true;
                _remainingDuration = _model.Duration;
                ItemUsed?.Invoke();
            }
        }
コード例 #3
0
        public static void NotifyItemUsed(ICharacter character, IItem item)
        {
            if (item == null)
            {
                Api.Logger.Error("Item is null for " + nameof(NotifyItemUsed));
                return;
            }

            Api.SafeInvoke(() => ItemUsed?.Invoke(character, item));
        }
コード例 #4
0
    public void useItem(IInventoryItem item)
    {
        //items.Remove(item);

        //broadcast event to the door
        if (ItemUsed != null)
        {
            Debug.Log("Inventory broadcasting event");
            ItemUsed.Invoke(this, new InventoryEventArgs(item));
        }
    }
コード例 #5
0
ファイル: ObjectPool.cs プロジェクト: kevinmel2000/HoneyTown
        private void Use(T item)
        {
            item.Initialize(_returnToPoolDelegate);
            item.NextNode = null;
            if (item != _tailNode)
            {
                item.PreviousNode  = _tailNode;
                _tailNode.NextNode = item;
                _tailNode          = item;
            }

            ItemUsed?.Invoke(item);
        }
コード例 #6
0
    public bool UseItem(InventoryItem item)
    {
        if (Inventory.Contains(item))
        {
            var           index = Inventory.IndexOf(item);
            InventoryItem use   = GameWorldReferenceClass.GW_Player.charInventory.Inventory.Find(x => x == item);
            use.usableItem.Use(GameWorldReferenceClass.GW_Player, use);

            if (use.currentCharges <= 0)
            {
                ItemDepleted?.Invoke(this, index);
                Inventory.Remove(item);
                return(true);
            }
            else
            {
                ItemUsed?.Invoke(this, index);
                return(false);
            }
        }
        Debug.Log("You do not have that item.");
        return(false);
    }
コード例 #7
0
 public void useItem(IInventoryItem item)
 {
     //broadcast event to keyopener and HUDManager
     if (ItemUsed != null)
     {
         Debug.Log("the item is " + item.itemName);
         if ((item.tag == "ingredient" && cauldron.GetComponent <KeyOpener>().inRange))
         {
             IngredientUsed.Invoke(this, new IngredientEventArgs(item.tag, item.itemImage));
             items.Remove(item);
         }
         else if (item.tag == "book")
         {
             Debug.Log("Inventory broadcasting event");
             ItemUsed.Invoke(this, new InventoryEventArgs(item));
             items.Remove(item);
         }
         else
         {
             Debug.Log("not in range to use item");
             manager.SetNotificationText("You can't use that here.");
         }
     }
 }
コード例 #8
0
 private void RaiseItemUsed(PlayerItem item)
 {
     ItemUsed?.Invoke(this, item);
 }
コード例 #9
0
 protected virtual void OnItemUsed(object source, ItemUsedEventArgs args)
 {
     ItemUsed?.Invoke(this, args);
 }
コード例 #10
0
 internal void UseItem(IInventoryItem item)
 {
     ItemUsed?.Invoke(this, new InventoryEventArgs(item));
 }
コード例 #11
0
 public void useItem(IInventoryItem item)
 {
     {
         ItemUsed.Invoke(this, new InventoryEventArgs(item));
     }
 }
コード例 #12
0
ファイル: Inventory.cs プロジェクト: Freezer-Games/Frozen-Out
        private void OnItemUsed(ItemInfo itemUsed)
        {
            ItemEventArgs itemEventArgs = new ItemEventArgs(itemUsed);

            ItemUsed?.Invoke(this, itemEventArgs);
        }