コード例 #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
        void ReleaseDesignerOutlets()
        {
            if (Calc != null)
            {
                Calc.Dispose();
                Calc = null;
            }

            if (Calc != null)
            {
                Calc.Dispose();
                Calc = null;
            }

            if (ItemUsed != null)
            {
                ItemUsed.Dispose();
                ItemUsed = null;
            }

            if (LevelInput != null)
            {
                LevelInput.Dispose();
                LevelInput = null;
            }

            if (ResultsLabel != null)
            {
                ResultsLabel.Dispose();
                ResultsLabel = null;
            }
        }
コード例 #3
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();
            }
        }
コード例 #4
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));
        }
コード例 #5
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));
        }
    }
コード例 #6
0
 public void RemoveItem(ItemUsed obj)
 {
     Product.ItemsUsed.Remove(obj);
     if (Product.ItemsUsed != null && Product.ItemsUsed.Count > 0)
     {
         AddTotal(obj);
     }
     else
     {
         Product.CostPrice = 0;
     }
 }
コード例 #7
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);
        }
コード例 #8
0
        public async void RemoveItem(ItemUsed obj)
        {
            bool confirm = await DialogService.DisplayAlertAsync("Item Delete", "Do you want to Delete?", "Delete", "Cancel");

            if (confirm)
            {
                Product.ItemsUsed.Remove(obj);
                if (Product.ItemsUsed != null && Product.ItemsUsed.Count > 0)
                {
                    AddTotal(obj);
                }
                else
                {
                    Product.CostPrice = 0;
                }
            }
        }
コード例 #9
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);
    }
コード例 #10
0
 public async Task <int> SaveItemUsed(ItemUsed itemUsed)
 {
     try
     {
         if (App.Connection != null)
         {
             int res = 0;
             if (string.IsNullOrEmpty(itemUsed.Id))
             {
                 res = await App.Connection.InsertAsync(itemUsed);
             }
             else
             {
                 res = await App.Connection.UpdateAsync(itemUsed);
             }
             //await App.Connection.CloseAsync();
             return(res);
         }
     }
     catch (Exception ex)
     {
     }
     return(-1);
 }
コード例 #11
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.");
         }
     }
 }
コード例 #12
0
 private void RaiseItemUsed(PlayerItem item)
 {
     ItemUsed?.Invoke(this, item);
 }
コード例 #13
0
 public void useItem(IInventoryItem item)
 {
     {
         ItemUsed.Invoke(this, new InventoryEventArgs(item));
     }
 }
コード例 #14
0
 protected virtual void OnItemUsed(object source, ItemUsedEventArgs args)
 {
     ItemUsed?.Invoke(this, args);
 }
コード例 #15
0
 internal void UseItem(IInventoryItem item)
 {
     ItemUsed?.Invoke(this, new InventoryEventArgs(item));
 }
コード例 #16
0
ファイル: Player.cs プロジェクト: babyboucher/EXILED
 /// <summary>
 /// Called after a player used a medical item.
 /// </summary>
 /// <param name="ev">The <see cref="UsedItemEventArgs"/> instance.</param>
 public static void OnItemUsed(UsedItemEventArgs ev) => ItemUsed.InvokeSafely(ev);
コード例 #17
0
ファイル: Inventory.cs プロジェクト: Freezer-Games/Frozen-Out
        private void OnItemUsed(ItemInfo itemUsed)
        {
            ItemEventArgs itemEventArgs = new ItemEventArgs(itemUsed);

            ItemUsed?.Invoke(this, itemEventArgs);
        }