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; }
/// <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(); } }
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)); }
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)); } }
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); }
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); }
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."); } } }
private void RaiseItemUsed(PlayerItem item) { ItemUsed?.Invoke(this, item); }
protected virtual void OnItemUsed(object source, ItemUsedEventArgs args) { ItemUsed?.Invoke(this, args); }
internal void UseItem(IInventoryItem item) { ItemUsed?.Invoke(this, new InventoryEventArgs(item)); }
public void useItem(IInventoryItem item) { { ItemUsed.Invoke(this, new InventoryEventArgs(item)); } }
private void OnItemUsed(ItemInfo itemUsed) { ItemEventArgs itemEventArgs = new ItemEventArgs(itemUsed); ItemUsed?.Invoke(this, itemEventArgs); }