/// <summary> /// アイテムを追加する /// </summary> public void AddItem(MasterDataItem.Record item, int amount) { var itemId = item.Id; if (this.items.ContainsKey(itemId)) { this.items[itemId] += amount; } else { this.items.Add(itemId, amount); } Broker.Global.Publish(AddedItem.Get(this, item, amount)); }
public void Add(int itemHash, int number) { Assert.IsTrue(number >= 1); if (!this.Items.ContainsKey(itemHash)) { this.Items.Add(itemHash, 0); } this.Items[itemHash] += number; var itemSpecs = GameController.Instance.ItemSpecs; var item = itemSpecs.Get(itemHash); if (item.AddedInventoryTask != null) { item.AddedInventoryTask.Do(); } UniRxEvent.GlobalBroker.Publish(AddedItem.Get(item)); Debug.Log(string.Format("{0} x {1}", item.Name, this.Items[itemHash])); }