コード例 #1
0
 private static void MoveToBank(int place, int toplace, PlayerInventory bag, PlayerInventory bank, ItemInfo item)
 {
     if (bag != null && item != null && bag != null)
     {
         ItemInfo toitem = bank.GetItemAt(toplace);
         if (toitem != null)
         {
             if (item.CanStackedTo(toitem) && item.Count + toitem.Count <= item.Template.MaxCount)
             {
                 if (bank.AddCountToStack(toitem, item.Count))
                 {
                     bag.RemoveItem(item, eItemRemoveType.Stack);
                 }
             }
             else
             {
                 if (toitem.Template.BagType == (eBageType)bag.BagType)
                 {
                     bag.TakeOutItem(item);
                     bank.TakeOutItem(toitem);
                     bag.AddItemTo(toitem, place);
                     bank.AddItemTo(item, toplace);
                 }
             }
         }
         else
         {
             if (bank.AddItemTo(item, toplace))
             {
                 bag.TakeOutItem(item);
             }
         }
     }
 }
コード例 #2
0
 private static void MoveFromBank(GameClient client, int place, int toplace, PlayerInventory bag, PlayerInventory tobag, ItemInfo item)
 {
     if (item != null)
     {
         PlayerInventory itemInventory = client.Player.GetItemInventory(item.Template);
         if (itemInventory == tobag)
         {
             ItemInfo itemAt = itemInventory.GetItemAt(toplace);
             if (itemAt == null)
             {
                 if (itemInventory.AddItemTo(item, toplace))
                 {
                     bag.TakeOutItem(item);
                     return;
                 }
             }
             else
             {
                 if (!item.CanStackedTo(itemAt) || item.Count + itemAt.Count > item.Template.MaxCount)
                 {
                     itemInventory.TakeOutItem(itemAt);
                     bag.TakeOutItem(item);
                     itemInventory.AddItemTo(item, toplace);
                     bag.AddItemTo(itemAt, place);
                     return;
                 }
                 if (itemInventory.AddCountToStack(itemAt, item.Count))
                 {
                     bag.RemoveItem(item, eItemRemoveType.Stack);
                     return;
                 }
             }
         }
         else
         {
             if (itemInventory.AddItem(item))
             {
                 bag.TakeOutItem(item);
             }
         }
     }
 }
コード例 #3
0
 private static void MoveFromBank(GamePlayer player, int place, int toplace, PlayerInventory bag, PlayerInventory tobag, ItemInfo item)
 {
     if (item != null)
     {
         PlayerInventory tb = player.GetItemInventory(item.Template);
         if (tb == tobag)
         {
             ItemInfo toitem = tb.GetItemAt(toplace);
             if (toitem == null)
             {
                 if (tb.AddItemTo(item, toplace))
                 {
                     bag.TakeOutItem(item);
                 }
             }
             else
             {
                 if (item.CanStackedTo(toitem) && item.Count + toitem.Count <= item.Template.MaxCount)
                 {
                     if (tb.AddCountToStack(toitem, item.Count))
                     {
                         bag.RemoveItem(item, eItemRemoveType.Stack);
                     }
                 }
                 else
                 {
                     tb.TakeOutItem(toitem);
                     bag.TakeOutItem(item);
                     tb.AddItemTo(item, toplace);
                     bag.AddItemTo(toitem, place);
                 }
             }
         }
         else
         {
             if (tb.AddItem(item))
             {
                 bag.TakeOutItem(item);
             }
         }
     }
 }
コード例 #4
0
 public void MoveToHide(GamePlayer player, PlayerInventory bag, ItemInfo item, int toSlot, PlayerInventory hideBag, int count)
 {
     if (player != null && bag != null && item != null && hideBag != null)
     {
         int      oldplace = item.Place;
         ItemInfo toItem   = hideBag.GetItemAt(toSlot);
         if (toItem != null)
         {
             if (toItem.CanStackedTo(item))
             {
                 return;
             }
             if (item.Count == 1 && item.BagType == toItem.BagType)
             {
                 bag.TakeOutItem(item);
                 hideBag.TakeOutItem(toItem);
                 bag.AddItemTo(toItem, oldplace);
                 hideBag.AddItemTo(item, toSlot);
                 return;
             }
             string          key = string.Format("temp_place_{0}", toItem.ItemID);
             PlayerInventory tb  = player.GetItemInventory(toItem.Template);
             if (player.TempProperties.ContainsKey(key) && tb.BagType == 0)
             {
                 int tempSlot = (int)player.TempProperties[key];
                 player.TempProperties.Remove(key);
                 if (tb.AddItemTo(toItem, tempSlot))
                 {
                     hideBag.TakeOutItem(toItem);
                 }
             }
             else
             {
                 if (tb.StackItemToAnother(toItem))
                 {
                     hideBag.RemoveItem(toItem, eItemRemoveType.Stack);
                 }
                 else
                 {
                     if (tb.AddItem(toItem))
                     {
                         hideBag.TakeOutItem(toItem);
                     }
                     else
                     {
                         player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserChangeItemPlaceHandler.full", new object[0]));
                     }
                 }
             }
         }
         if (hideBag.IsEmpty(toSlot))
         {
             if (item.Count == 1)
             {
                 if (hideBag.AddItemTo(item, toSlot))
                 {
                     bag.TakeOutItem(item);
                     if (item.Template.BagType == eBageType.MainBag)
                     {
                         string key = string.Format("temp_place_{0}", item.ItemID);
                         if (player.TempProperties.ContainsKey(key))
                         {
                             player.TempProperties[key] = oldplace;
                         }
                         else
                         {
                             player.TempProperties.Add(key, oldplace);
                         }
                     }
                 }
             }
             else
             {
                 ItemInfo newItem = item.Clone();
                 newItem.Count = 1;
                 if (bag.RemoveCountFromStack(item, 1, eItemRemoveType.Stack))
                 {
                     if (!hideBag.AddItemTo(newItem, toSlot))
                     {
                         bag.AddCountToStack(item, 1);
                     }
                 }
             }
         }
     }
 }
コード例 #5
0
 public void MoveToStore(GameClient client, PlayerInventory bag, ItemInfo item, int toSlot, PlayerInventory storeBag, int count)
 {
     if (client.Player != null && bag != null && item != null && storeBag != null)
     {
         int      place  = item.Place;
         ItemInfo itemAt = storeBag.GetItemAt(toSlot);
         if (itemAt != null)
         {
             if (itemAt.CanStackedTo(item))
             {
                 return;
             }
             if (item.Count == 1 && item.BagType == itemAt.BagType)
             {
                 bag.TakeOutItem(item);
                 storeBag.TakeOutItem(itemAt);
                 bag.AddItemTo(itemAt, place);
                 storeBag.AddItemTo(item, toSlot);
                 return;
             }
             string          key           = string.Format("temp_place_{0}", itemAt.ItemID);
             PlayerInventory itemInventory = client.Player.GetItemInventory(itemAt.Template);
             if (client.Player.TempProperties.ContainsKey(key) && itemInventory.BagType == 0)
             {
                 int place2 = (int)client.Player.TempProperties[key];
                 client.Player.TempProperties.Remove(key);
                 if (itemInventory.AddItemTo(itemAt, place2))
                 {
                     storeBag.TakeOutItem(itemAt);
                 }
             }
             else
             {
                 if (itemInventory.StackItemToAnother(itemAt))
                 {
                     storeBag.RemoveItem(itemAt, eItemRemoveType.Stack);
                 }
                 else
                 {
                     if (itemInventory.AddItem(itemAt))
                     {
                         storeBag.TakeOutItem(itemAt);
                     }
                     else
                     {
                         client.Player.Out.SendMessage(eMessageType.ERROR, LanguageMgr.GetTranslation("UserChangeItemPlaceHandler.full", new object[0]));
                     }
                 }
             }
         }
         if (storeBag.IsEmpty(toSlot))
         {
             if (item.Count == 1)
             {
                 if (storeBag.AddItemTo(item, toSlot))
                 {
                     bag.TakeOutItem(item);
                     if (item.Template.BagType == eBageType.MainBag && place < 31)
                     {
                         string key = string.Format("temp_place_{0}", item.ItemID);
                         if (client.Player.TempProperties.ContainsKey(key))
                         {
                             client.Player.TempProperties[key] = place;
                             return;
                         }
                         client.Player.TempProperties.Add(key, place);
                         return;
                     }
                 }
             }
             else
             {
                 ItemInfo itemInfo = item.Clone();
                 itemInfo.Count = count;
                 if (bag.RemoveCountFromStack(item, count, eItemRemoveType.Stack) && !storeBag.AddItemTo(itemInfo, toSlot))
                 {
                     bag.AddCountToStack(item, count);
                 }
             }
         }
     }
 }