public Item(TCharacterItem item) { this.dbItem = item; this.ItemID = (short)item.IteamID; this.Count = (short)item.ItemCount; }
public bool AddItem(int itemId, int count) { Item item = null; if (this.Items.TryGetValue(itemId, out item)) { item.Add(count); } else { TCharacterItem TItem = new TCharacterItem() { CharacterID = Owner.Data.ID, Character = Owner.Data, ItemID = itemId, Count = count }; Owner.Data.CharacterItems.Add(TItem); item = new Item(TItem); this.Items.Add(itemId, item); } Owner.statusManager.AddItemChange(itemId, count); //DBService.Instance.Save(); return(true); }
public bool AddItem(int itemId, int count) { Item item = null; //字典有加数目,没有数据库和角色、字典添加道具 if (this.Items.TryGetValue(itemId, out item)) { item.Add(count); } else { TCharacterItem dbItem = new TCharacterItem(); dbItem.CharacterID = this.Owner.Data.ID; dbItem.Owner = this.Owner.Data; dbItem.ItemID = itemId; dbItem.ItemCount = count; this.Owner.Data.Items.Add(dbItem); item = new Item(dbItem); Items.Add(itemId, item); //Items[itemId] = item; } this.Owner.StatusManager.AddItemChange(itemId, count, StatusAction.Add);//加入状态 Log.InfoFormat("[{0}]AddItem[{1}] addCount:{2}", this.Owner.Data.ID, itemId, count); DBService.Instance.Save(); return(true); }
public bool AddItem(int itemId, int count) { Item item = null; if (this.Items.TryGetValue(itemId, out item)) { item.Add(count); } else { TCharacterItem TItem = Owner.Data.CharacterItems.Where(x => x.ItemID == itemId && x.CharacterID == Owner.Id).FirstOrDefault(); if (TItem == null) { TItem = new TCharacterItem() { CharacterID = Owner.Data.ID, Character = Owner.Data, ItemID = itemId, Count = count }; Owner.Data.CharacterItems.Add(TItem); } else { TItem.Count = count; } item = new Item(TItem); this.Items.Add(itemId, item); } Owner.statusManager.AddItemChange(itemId, count); return(true); }
public void AddItem(int id, int amount = 1) { Item item = null; if (items.TryGetValue(id, out item)) { item.Add(amount); } //if item is not stored in the dictionary, create a new record else { TCharacterItem tItem = new TCharacterItem() { ItemID = id, Count = amount, Owner = owner.Data }; owner.Data.Items.Add(tItem); items.Add(id, new Item(tItem)); } //save changes to database DBService.Instance.Entities.SaveChanges(); }
public bool AddItem(int itemId, int count) { Item item = null; if (this.Items.TryGetValue(itemId, out item)) { item.Add(count); } else { TCharacterItem dbItem = new TCharacterItem(); dbItem.TCharacterID = Owner.Data.ID; dbItem.ItemID = itemId; dbItem.Owner = Owner.Data; dbItem.ItemCount = count; Owner.Data.Items.Add(dbItem); item = new Item(dbItem); this.Items.Add(itemId, item); Log.InfoFormat("AddItem id = {0},count = {1}", itemId, count); } DBService.Instance.Save(); return(true); }
public bool AddItem(int itemId, int count) { Item item = null; if (this.Items.TryGetValue(itemId, out item)) { item.Add(count); } else { TCharacterItem dbItem = new TCharacterItem(); dbItem.TCharacterID = Owner.Data.ID; dbItem.Owner = Owner.Data; dbItem.IteamID = itemId; dbItem.ItemCount = count; Owner.Data.Items.Add(dbItem); item = new Item(dbItem); this.Items.Add(itemId, item); } this.Owner.StatusManager.AddItemChange(itemId, count, StatusAction.Add); Log.InfoFormat("[{0}]AddItem[{1}] addCount:{2}", this.Owner.Data.ID, item, count); // DBService.Instance.Save(); return(true); }
public Item(TCharacterItem item) { dbItem = item; ItemID = item.ItemID; Count = item.ItemCount; }
public Item(TCharacterItem Titem) { this.tcharacterItem = Titem; this.Id = Titem.ItemID; this.Count = Titem.Count; }
public Item(TCharacterItem item) { mItem = item; ID = mItem.ItemID; Count = item.Count; }