/// <summary> /// 从数据库中加载 /// </summary> /// <param name="playerId"></param> public void LoadFromDatabase(int playerId) { using (PlayerBussiness pb = new PlayerBussiness()) { ItemInfo[] list = pb.GetUserBagByType(playerId, _bagType); foreach (ItemInfo item in list) { _items[item.Place] = item; } } }
/// <summary> /// 从数据库中加载 /// </summary> /// <param name="playerId"></param> public void LoadFromDatabase(int playerId) { using (PlayerBussiness pb = new PlayerBussiness()) { //ItemInfo[] list = pb.GetUserItem(playerId); ItemInfo[] list = pb.GetUserBagByType(playerId, _bagType); foreach (ItemInfo item in list) { _items[item.Place] = item; } for (int i = 0; i < 11; i++) { ItemInfo item = _items[i]; if (item == null) continue; if (!_items[i].IsValidItem()) { UpdatePlayerProperties(item, false); int place = base.FindFirstEmptySlot(11); if (place != -1) { MoveItem(item.Place, place); } else { MailInfo mail = new MailInfo(); mail.Annex1 = item.ItemID.ToString(); mail.Content = "物品已过期!"; mail.Gold = 0; mail.IsExist = true; mail.Money = 0; mail.Receiver = _player.PlayerCharacter.NickName; mail.ReceiverID = item.UserID; mail.Sender = _player.PlayerCharacter.NickName; mail.SenderID = item.UserID; mail.Title = "物品已过期!"; if (pb.SendMail(mail)) { item.UserID = 0; RemoveItem(item); } } } } UpdatePlayerProperties(); } }
/// <summary> /// 从数据库中加载 /// </summary> /// <param name="playerId"></param> public void LoadFromDatabase(int playerId) { using (PlayerBussiness pb = new PlayerBussiness()) { ItemInfo[] list = pb.GetUserBagByType(playerId, _bagType); foreach (ItemInfo item in list) { if (item.Place >= _count || item.Place < 0) continue; m_items[item.Place] = item; } } if (_bagType == 11) { SendStoreToMail(); } }
public virtual void LoadFromDatabase() { if (m_saveToDb) { using (PlayerBussiness pb = new PlayerBussiness()) { ItemInfo[] list = pb.GetUserBagByType(m_player.PlayerCharacter.ID, BagType); BeginChanges(); try { foreach (ItemInfo item in list) { AddItemTo(item, item.Place); } } finally { CommitChanges(); } } } }