public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message) { room.GameRule.HandleFreeEvent(room.RoomContexts, player, 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); FreeItemManager.MoveItem(message.Ss[0], fd, room.FreeArgs, message.Ins[0], message.Ins[1], message.Ins[2], message.Ins[3], message.Ins[4], message.Ins[5], message.Ins[6], message.Ins[7]); room.FreeArgs.Resume(PARA_PLAYER_CURRENT); room.FreeArgs.GetDefault().GetParameters().Resume(PARA_EVENT_KEY); }
public void HandleFreeEvent(Contexts room, PlayerEntity player, SimpleProto message) { if (message.Key == 1) { if (_eventKey == null) { _eventKey = new StringPara("event", ""); } if (!this.args.Triggers.IsEmpty(FreeTriggerConstant.CLICK_IMAGE)) { _eventKey.SetValue(message.Ss[0]); args.TempUsePara(_eventKey); this.args.Triggers.Trigger(FreeTriggerConstant.CLICK_IMAGE, args); args.ResumePara("event"); } } }
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; var freeArgs = room.ContextsWrapper.FreeArgs as FreeRuleEventArgs; freeArgs.TempUse(PARA_PLAYER_CURRENT, fd); eventKey.SetValue(message.Ss[0]); freeArgs.GetDefault().GetParameters().TempUse(eventKey); Debug.Log("drag from:" + message.Ss[0] + " to:" + message.Ss[1]); string from = message.Ss[0]; string to = message.Ss[1]; ItemPosition fromIp = FreeItemManager.GetItemPosition(freeArgs, from, fd.freeInventory.GetInventoryManager()); ItemPosition toIp = FreeItemManager.GetItemPosition(freeArgs, to, fd.freeInventory.GetInventoryManager()); // 显示拆分UI if (message.Bs[0] && from.StartsWith(ChickenConstant.BagDefault)) { PickupItemUtil.ShowSplitUI(room, fd, from); } else if (!HandleBag(from, to, room, fd)) { } else if (player.gamePlay.GameState == GameState.AirPlane || player.gamePlay.GameState == GameState.Gliding || player.gamePlay.GameState == GameState.JumpPlane) { } /*else if (from.StartsWith(ChickenConstant.BagBelt) || to.StartsWith(ChickenConstant.BagBelt)) * { * // 腰包不能做任何操作 * SimpleProto msg = FreePool.Allocate(); * msg.Key = FreeMessageConstant.ChickenTip; * msg.Ss.Add("word63"); * FreeMessageSender.SendMessage(fd.Player, msg); * }*/ else if (from.StartsWith(ChickenConstant.BagGround) && !to.StartsWith(ChickenConstant.BagGround)) { // 地面模糊操作 HandleAuto(from, to, room, fd); } else if (from.StartsWith(ChickenConstant.BagGround) || to.StartsWith(ChickenConstant.BagGround)) { /*if (from.StartsWith(Ground) && !to.StartsWith(Ground)) * { * handleFromGround(from, to, room, fd); * }*/ if (!from.StartsWith(ChickenConstant.BagGround) && to.StartsWith(ChickenConstant.BagGround)) { FreeItemInfo fromInfo = FreeItemConfig.GetItemInfo(fromIp.key.GetKey()); if (fromInfo.cat == (int)ECategory.WeaponPart && from.StartsWith("w")) { if (BagCapacityUtil.CanDemountAttachment(room, fd, fromInfo, from, true)) { handleToGround(from, to, room, fd); } } else { handleToGround(from, to, room, fd); } } } else if (from.StartsWith(ChickenConstant.BagDefault) && to.StartsWith("w")) { // 背包物品拖动到武器槽 if (fromIp != null) { FreeItemInfo info = FreeItemConfig.GetItemInfo(fromIp.key.GetKey()); if (info.cat == (int)ECategory.WeaponPart) { MovePartToWeapon(room, fd, fromIp, to, info); } else { FreeItemManager.DragItem(from, fd, room.ContextsWrapper.FreeArgs, to); } } } else if (PickupItemUtil.IsDefault(from) && string.IsNullOrEmpty(to)) { // 背包物品拖动到人身上 if (fromIp != null) { FreeItemInfo info = FreeItemConfig.GetItemInfo(fromIp.key.GetKey()); if (info.cat == (int)ECategory.WeaponPart) { MovePartToWeapon(room, fd, fromIp, to, info); } else { FreeItemManager.UseItem(from, fd, room.ContextsWrapper.FreeArgs); } } } else if ((from.StartsWith("w1,") && to.StartsWith("w2,")) || (from.StartsWith("w2,") && to.StartsWith("w1,"))) { ExchangeWeapon(room.ContextsWrapper.FreeArgs, fd, from, to); } else if (from.StartsWith("w") && to.StartsWith("w") && from.IndexOf(",") == 3 && to.IndexOf(",") == 2) { if (fromIp != null && toIp != null) { WeaponBaseAgent toAgent = fd.Player.WeaponController().GetWeaponAgent((EWeaponSlotType)short.Parse(to.Substring(1, 1))); FreeItemInfo fromInfo = FreeItemConfig.GetItemInfo(fromIp.key.GetKey()); if (!toAgent.WeaponConfigAssy.IsPartMatchWeapon(WeaponPartUtil.GetWeaponFstMatchedPartId(fromInfo.id, toAgent.ConfigId))) { SimpleProto msg = FreePool.Allocate(); msg.Key = FreeMessageConstant.ChickenTip; msg.Ss.Add("word77," + toAgent.WeaponConfigAssy.S_Name + "," + fromInfo.name); FreeMessageSender.SendMessage(fd.Player, msg); } else { string toPosition = to.Substring(0, 2) + from.Substring(2, 1) + ",0,0"; ItemPosition toPart = FreeItemManager.GetItemPosition(room.ContextsWrapper.FreeArgs, toPosition, fd.freeInventory.GetInventoryManager()); WeaponBaseAgent fromAgent = fd.Player.WeaponController().GetWeaponAgent((EWeaponSlotType)short.Parse(from.Substring(1, 1))); if (toPart != null) { FreeItemInfo toInfo = FreeItemConfig.GetItemInfo(toPart.key.GetKey()); if (!fromAgent.WeaponConfigAssy.IsPartMatchWeapon(WeaponPartUtil.GetWeaponFstMatchedPartId(toInfo.id, fromAgent.ConfigId))) { SimpleProto msg = FreePool.Allocate(); msg.Key = FreeMessageConstant.ChickenTip; msg.Ss.Add("word77," + fromAgent.WeaponConfigAssy.S_Name + "," + toInfo.name); FreeMessageSender.SendMessage(fd.Player, msg); } else { if (BagCapacityUtil.CanExchangeAttachment(room, fd, fromInfo, toInfo, fromAgent, toAgent)) { FreeItemManager.DragItem(from, fd, room.ContextsWrapper.FreeArgs, toPosition); } } } else { if (BagCapacityUtil.CanDemountAttachment(room, fd, fromInfo, from, false)) { FreeItemManager.DragItem(from, fd, room.ContextsWrapper.FreeArgs, toPosition); } } } } } else if (from.StartsWith("w") && from.IndexOf(",") == 3 && PickupItemUtil.IsDefault(to)) { FreeItemInfo fromInfo = FreeItemConfig.GetItemInfo(fromIp.key.GetKey()); if (BagCapacityUtil.CanDemountAttachment(room, fd, fromInfo, from, false)) { ItemInventory fromInv = fromIp.GetInventory(); ItemInventory toInv = toIp == null?fd.freeInventory.GetInventoryManager().GetInventory(ChickenConstant.BagDefault) : toIp.GetInventory(); int[] pos = toIp == null ? new int[] { 0, 0 } : toInv.GetNextEmptyPosition(toIp.GetKey()); ItemInventoryUtil.MoveItem(pos[0], pos[1], fromInv, toInv, fromInv.GetInventoryUI(), toInv.GetInventoryUI(), fromIp, null, room.ContextsWrapper.FreeArgs); } } else { FreeItemManager.DragItem(from, fd, room.ContextsWrapper.FreeArgs, to); } room.ContextsWrapper.FreeArgs.Resume(PARA_PLAYER_CURRENT); room.ContextsWrapper.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); }
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); Debug.Log("drag from:" + message.Ss[0] + " to:" + message.Ss[1]); string from = message.Ss[0]; string to = message.Ss[1]; // 显示拆分UI if (message.Bs[0] && from.StartsWith(ChickenConstant.BagDefault)) { PickupItemUtil.ShowSplitUI(room, fd, from); return; } if (!HandleBag(from, to, room, fd)) { return; } if (player.gamePlay.GameState == GameState.AirPlane) { return; } if (from.StartsWith("belt") || to.StartsWith("belt")) { // 腰包不能做任何操作 } else if (from.StartsWith(Ground) && to != Ground) { // 地面模糊操作 HandleAuto(from, to, room, fd); } else if (from.StartsWith(Ground) || to.StartsWith(Ground)) { handleFromGround(from, to, room, fd); handleToGround(from, to, room, fd); } // 背包物品拖动到武器槽 else if (from.StartsWith("default") && to.StartsWith("w")) { ItemPosition ip = FreeItemManager.GetItemPosition(room.FreeArgs, from, fd.freeInventory.GetInventoryManager()); if (ip != null) { FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey()); if (info.cat == (int)ECategory.WeaponPart) { MovePartToWeapon(room, fd, ip, to, info); } else { FreeItemManager.DragItem(message.Ss[0], fd, room.FreeArgs, message.Ss[1]); } } } // 背包物品拖动到人身上 else if (from.StartsWith("default") && string.IsNullOrEmpty(to)) { ItemPosition ip = FreeItemManager.GetItemPosition(room.FreeArgs, from, fd.freeInventory.GetInventoryManager()); if (ip != null) { FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey()); if (info.cat == (int)ECategory.WeaponPart) { MovePartToWeapon(room, fd, ip, to, info); } else { FreeItemManager.UseItem(from, fd, room.FreeArgs); } } } else { FreeItemManager.DragItem(message.Ss[0], fd, room.FreeArgs, message.Ss[1]); } room.FreeArgs.Resume(PARA_PLAYER_CURRENT); room.FreeArgs.GetDefault().GetParameters().Resume(PARA_EVENT_KEY); }
public virtual void Draw(SimpleInventoryUI ui, IEventArgs args, ItemInventory inventory, ItemPosition ip) { this.inventory = inventory; if (fui == null) { fui = new FreeUICreateAction(); Sharpen.Collections.AddAll(fui.GetComponents(), components); } ip.GetParameters().AddPara(new StringPara("inventory", inventory.GetName())); StringPara img = new StringPara("img", string.Empty); StringPara itemName = new StringPara("name", string.Empty); IntPara count = new IntPara("count", 0); args.GetDefault().GetParameters().TempUse(img); args.GetDefault().GetParameters().TempUse(count); args.GetDefault().GetParameters().TempUse(itemName); img.SetValue(ip.GetKey().GetImg()); count.SetValue(ip.GetCount()); itemName.SetValue(ip.GetKey().GetName()); FreeImageComponet back = GetBackground(); if (ui.nomouse) { back.SetNoMouse("true"); } if (ui.itemFixed) { back.SetFixed("true"); } int startX = GetX(args, ui, ip, back); int startY = GetY(args, ui, ip, back); if (!StringUtil.IsNullOrEmpty(notused) && !StringUtil.IsNullOrEmpty(used)) { if (ip.IsUsed()) { back.SetUrl(used); } else { back.SetUrl(notused); } } back.SetX(startX.ToString()); back.SetY(startY.ToString()); back.SetRelative(ui.relative); back.SetEvent(inventory.GetName() + "," + ip.GetX() + "," + ip.GetY()); FreeImageComponet itemImg = back; FreeImageComponet secondComponent = GetItemImage(); if (secondComponent != null) { back.SetEvent(string.Empty); itemImg = secondComponent; } if (ui.nomouse) { itemImg.SetNoMouse("true"); } if (ui.itemFixed) { itemImg.SetFixed("true"); } itemImg.SetUrl(ip.GetKey().GetImg()); itemImg.SetOriginalSize(ip.GetKey().GetItemWidth() + "," + ip.GetKey().GetItemHeight()); if (itemImg == back) { AdjustSize(args, ui, ip, inventory, back, itemImg, startX, startY); } else { AdjustSize(args, ui, ip, inventory, back, itemImg, 0, 0); } SetCount(ip); fui.SetKey(ip.GetUIKey()); fui.SetShow(inventory.IsOpen()); fui.SetScope(1); fui.SetPlayer("current"); fui.Act(args); UpdateHotKey(ui, args, ip); args.GetDefault().GetParameters().Resume("img"); args.GetDefault().GetParameters().Resume("name"); args.GetDefault().GetParameters().Resume("count"); }