private void HandleDropWeapon(IEventArgs args) { if ("DropWeapon" == code) { int key = FreeUtil.ReplaceInt("{key}", args); FreeData fd = (FreeData)args.GetUnit("current"); ItemInventory defInv = fd.freeInventory.GetInventoryManager().GetDefaultInventory(); for (int i = 1; i <= 5; i++) { ItemInventory ii = fd.freeInventory.GetInventoryManager().GetInventory("w" + key + "" + i); if (ii.posList.Count > 0) { ItemPosition ip = ii.posList[0]; if (BagCapacityUtil.CanAddToBag(args, fd, ip)) { int[] next = defInv.GetNextEmptyPosition(ip.key); ItemInventoryUtil.MovePosition(ip, defInv, next[0], next[1], (ISkillArgs)args); } else { ItemInventory ground = fd.freeInventory.GetInventoryManager().GetInventory("ground"); int[] next = ground.GetNextEmptyPosition(ip.key); ItemInventoryUtil.MovePosition(ip, ground, next[0], next[1], (ISkillArgs)args); } } } CarryClipUtil.AddCurrentClipToBag(key, fd, args); } }
private void MovePartToWeapon(ServerRoom room, FreeData fd, ItemPosition ip, string to, FreeItemInfo info) { string inv = PickupItemUtil.AutoPutPart(fd, info, to, room); if (inv != null && inv != "default") { ItemInventory toInv = fd.freeInventory.GetInventoryManager().GetInventory(inv); int[] xy = toInv.GetNextEmptyPosition(ip.key); ItemInventoryUtil.MovePosition(ip, toInv, xy[0], xy[1], room.FreeArgs); } else { FuntionUtil.Call(room.FreeArgs, "showBottomTip", "msg", "{desc:10076}"); } }
private void MovePartToWeapon(ServerRoom room, FreeData fd, ItemPosition ip, string to, FreeItemInfo info) { string inv = PickupItemUtil.AutoPutPart(fd, info, to, room); if (inv != null && inv != ChickenConstant.BagDefault) { ItemInventory toInv = fd.freeInventory.GetInventoryManager().GetInventory(inv); int[] xy = toInv.GetNextEmptyPosition(ip.key); ItemInventoryUtil.MovePosition(ip, toInv, xy[0], xy[1], room.ContextsWrapper.FreeArgs); } else { SimpleProto msg = FreePool.Allocate(); msg.Key = FreeMessageConstant.ChickenTip; msg.Ss.Add("word76"); FreeMessageSender.SendMessage(fd.Player, msg); } }
private void HandleAutoPartPut(IEventArgs args) { if (code == "AutoPart") { FreeData fd = (FreeData)args.GetUnit("current"); if (fd != null) { ItemPosition[] items = fd.freeInventory.GetInventoryManager().GetDefaultInventory().GetItems(); foreach (ItemPosition ip in items) { FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey()); if (info.cat == (int)ECategory.WeaponPart) { string inv = PickupItemUtil.AutoPutPart(fd, FreeItemConfig.GetItemInfo(info.cat, info.id)); if (inv != null && inv.StartsWith("w" + FreeUtil.ReplaceVar("{key}", args))) { ItemInventoryUtil.MovePosition(ip, fd.GetFreeInventory().GetInventoryManager().GetInventory(inv), 0, 0, (ISkillArgs)args); } } } } } }
public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message) { FreeData fd = (FreeData)player.freeData.FreeData; room.FreeArgs.TempUse(PARA_PLAYER_CURRENT, fd); eventKey.SetValue(message.Ss[0]); room.FreeArgs.GetDefault().GetParameters().TempUse(eventKey); room.GameRule.HandleFreeEvent(room.RoomContexts, player, message); string key = message.Ss[0]; Debug.LogFormat("click item {0}. ", key); if (message.Bs[0]) { // 显示拆分UI if (message.Bs[1]) { PickupItemUtil.ShowSplitUI(room, fd, key); return; } if (key.StartsWith("ground")) { SimpleItemInfo info = PickupItemUtil.GetGroundItemInfo(room, fd, key); if (info.cat > 0) { if (CanChangeBag(room, fd, key)) { PickupItemUtil.AddItemToPlayer(room, player, info.entityId, info.cat, info.id, info.count); } } } else if (key.StartsWith("default")) { ItemPosition ip = FreeItemManager.GetItemPosition(room.FreeArgs, key, fd.GetFreeInventory().GetInventoryManager()); FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey()); if (info.cat == (int)ECategory.WeaponPart) { string inv = PickupItemUtil.AutoPutPart(fd, FreeItemConfig.GetItemInfo(info.cat, info.id)); if (inv != null && inv != "default") { ItemInventoryUtil.MovePosition(ip, fd.GetFreeInventory().GetInventoryManager().GetInventory(inv), 0, 0, room.FreeArgs); } } else { FreeItemManager.UseItem(key, fd, room.FreeArgs); } } // 点击装配好的配件,自动进背包 else if (key.StartsWith("w") && key.Length == 3) { ItemInventory ii = fd.freeInventory.GetInventoryManager().GetInventory(key); ItemInventory defaultInventory = fd.GetFreeInventory().GetInventoryManager().GetDefaultInventory(); if (ii != null && ii.posList.Count > 0) { ItemPosition ip = ii.posList[0]; if (BagCapacityUtil.CanAddToBag(room.FreeArgs, fd, ip)) { int[] xy = defaultInventory.GetNextEmptyPosition(ip.GetKey()); ItemInventoryUtil.MovePosition(ip, defaultInventory, xy[0], xy[1], room.FreeArgs); } } } else { FreeItemManager.UseItem(key, fd, room.FreeArgs); } } room.FreeArgs.Resume(PARA_PLAYER_CURRENT); room.FreeArgs.GetDefault().GetParameters().Resume(PARA_EVENT_KEY); }
public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message) { FreeData fd = (FreeData)player.freeData.FreeData; room.ContextsWrapper.FreeArgs.TempUse(PARA_PLAYER_CURRENT, fd); eventKey.SetValue(message.Ss[0]); room.ContextsWrapper.FreeArgs.GetDefault().GetParameters().TempUse(eventKey); room.GameRule.HandleFreeEvent(room.RoomContexts, player, message); string key = message.Ss[0]; Debug.LogFormat("click item {0}. ", key); if (message.Bs[0]) { // 显示拆分UI if (message.Bs[1]) { PickupItemUtil.ShowSplitUI(room, fd, key); return; } if (key.StartsWith(ChickenConstant.BagGround)) { SimpleItemInfo info = PickupItemUtil.GetGroundItemInfo(room, fd, key); if (info.cat > 0) { if (CanChangeBag(room, fd, key)) { if (PickupItemUtil.AddItemToPlayer(room, player, info.entityId, info.cat, info.id, info.count)) { SimpleProto sp = FreePool.Allocate(); sp.Key = FreeMessageConstant.PlaySound; sp.Ks.Add(2); sp.Ins.Add(5018); sp.Bs.Add(false); FreeMessageSender.SendMessage(player, sp); } } } } else if (key.StartsWith(ChickenConstant.BagDefault)) { ItemPosition ip = FreeItemManager.GetItemPosition(room.ContextsWrapper.FreeArgs, key, fd.GetFreeInventory().GetInventoryManager()); FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey()); if (info.cat == (int)ECategory.WeaponPart) { string inv = PickupItemUtil.AutoPutPart(fd, FreeItemConfig.GetItemInfo(info.cat, info.id)); if (inv != null && inv != ChickenConstant.BagDefault) { ItemInventoryUtil.MovePosition(ip, fd.GetFreeInventory().GetInventoryManager().GetInventory(inv), 0, 0, room.ContextsWrapper.FreeArgs); } } else { FreeItemManager.UseItem(key, fd, room.ContextsWrapper.FreeArgs); } } // 点击装配好的配件,自动进背包 else if (key.StartsWith("w") && key.IndexOf(",") == 3) { ItemInventory ii = fd.freeInventory.GetInventoryManager().GetInventory(key.Substring(0, 3)); ItemInventory defaultInventory = fd.GetFreeInventory().GetInventoryManager().GetDefaultInventory(); if (ii != null && ii.posList.Count > 0) { ItemPosition ip = ii.posList[0]; if (BagCapacityUtil.CanDemountAttachment(room, fd, FreeItemConfig.GetItemInfo(ip.key.GetKey()), key, false)) { int[] xy = defaultInventory.GetNextEmptyPosition(ip.GetKey()); ItemInventoryUtil.MovePosition(ip, defaultInventory, xy[0], xy[1], room.ContextsWrapper.FreeArgs); } } } else { FreeItemManager.UseItem(key, fd, room.ContextsWrapper.FreeArgs); } } room.ContextsWrapper.FreeArgs.Resume(PARA_PLAYER_CURRENT); room.ContextsWrapper.FreeArgs.GetDefault().GetParameters().Resume(PARA_EVENT_KEY); }