Exemplo n.º 1
0
        private void handleFromGround(string from, string to, ServerRoom room, FreeData fd)
        {
            if (from.StartsWith(Ground) && !to.StartsWith(Ground))
            {
                SimpleItemInfo info = PickupItemUtil.GetGroundItemInfo(room, fd, from);
                if (info.cat > 0)
                {
                    ItemInventory inv = fd.freeInventory.GetInventoryManager().GetInventory("ground");

                    if (inv != null)
                    {
                        inv.Clear();
                        FreeItem item = FreeItemManager.GetItem(room.FreeArgs, FreeItemConfig.GetItemKey(info.cat, info.id), info.count);
                        item.GetParameters().AddPara(new IntPara("entityId", info.entityId));
                        inv.AddItem(room.FreeArgs, item, false);

                        DragGroundOne(fd, room, to);
                    }
                    else
                    {
                        Debug.LogErrorFormat("inventory {0} not existed.", from);
                    }
                }
            }
        }
Exemplo n.º 2
0
 private void handleToGround(string from, string to, ServerRoom room, FreeData fd)
 {
     if (!from.StartsWith(Ground) && to.StartsWith(Ground))
     {
         FreeItemManager.DragItem(from, fd, room.FreeArgs, Ground);
     }
 }
Exemplo n.º 3
0
        public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message)
        {
            FreeData fd = (FreeData)player.freeData.FreeData;

            room.FreeArgs.TempUse(PARA_PLAYER_CURRENT, fd);

            string key   = message.Ss[0];
            int    count = message.Ins[0];

            if (key.StartsWith(ChickenConstant.BagDefault))
            {
                ItemPosition ip   = FreeItemManager.GetItemPosition(room.FreeArgs, key, fd.GetFreeInventory().GetInventoryManager());
                FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey());

                if (ip.GetCount() > count)
                {
                    ip.SetCount(ip.GetCount() - count);
                    ip.GetInventory().GetInventoryUI().ReDraw((ISkillArgs)room.FreeArgs, ip.GetInventory(), true);
                }
                else
                {
                    ip.GetInventory().RemoveItem((ISkillArgs)room.FreeArgs, ip);
                }

                room.RoomContexts.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleEquipmentEntity(
                    (Assets.XmlConfig.ECategory)info.cat,
                    info.id,
                    count,
                    fd.Player.position.Value);
            }

            room.FreeArgs.Resume(PARA_PLAYER_CURRENT);
        }
Exemplo n.º 4
0
 private void DragGroundOne(FreeData fd, ServerRoom room, string to)
 {
     if (to.StartsWith(ChickenConstant.BagDefault))
     {
         FreeItemManager.DragItem("ground,0,0", fd, room.ContextsWrapper.FreeArgs, ChickenConstant.BagDefault);
     }
     else
     {
         FreeItemManager.DragItem("ground,0,0", fd, room.ContextsWrapper.FreeArgs, to);
     }
 }
Exemplo n.º 5
0
 private void DragGroundOne(FreeData fd, ServerRoom room, string to)
 {
     if (to.StartsWith("default"))
     {
         FreeItemManager.DragItem("ground,0,0", fd, room.FreeArgs, "default");
     }
     else
     {
         FreeItemManager.DragItem("ground,0,0", fd, room.FreeArgs, to);
     }
 }
Exemplo n.º 6
0
        public void Handle(ServerRoom room, PlayerEntity player, SimpleProto message)
        {
            FreeData fd = (FreeData)player.freeData.FreeData;

            room.ContextsWrapper.FreeArgs.TempUse(PARA_PLAYER_CURRENT, fd);

            string key   = message.Ss[0];
            int    count = message.Ins[0];

            if (key.StartsWith(ChickenConstant.BagDefault))
            {
                ItemPosition ip   = FreeItemManager.GetItemPosition(room.ContextsWrapper.FreeArgs, key, fd.GetFreeInventory().GetInventoryManager());
                FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey());

                if (ip.GetCount() > count)
                {
                    if (info.cat == (int)ECategory.Weapon && SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(info.id).Type == (int)EWeaponType_Config.ThrowWeapon)
                    {
                        CarryClipUtil.DeleteGrenade(count, info.id, fd, room.ContextsWrapper.FreeArgs);
                        for (int i = 0; i < count; i++)
                        {
                            player.WeaponController().RemoveGreande(info.id);
                        }
                    }
                    else
                    {
                        ip.SetCount(ip.GetCount() - count);
                        ip.GetInventory().GetInventoryUI().ReDraw((ISkillArgs)room.ContextsWrapper.FreeArgs, ip.GetInventory(), true);
                    }
                }
                else
                {
                    ip.GetInventory().RemoveItem((ISkillArgs)room.ContextsWrapper.FreeArgs, ip);
                }

                room.RoomContexts.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleObjectEntity(
                    (ECategory)info.cat, info.id, count, fd.Player.position.Value);

                if (info.cat == (int)ECategory.GameItem && SingletonManager.Get <GameItemConfigManager>().GetConfigById(info.id).Type == (int)GameItemType.Bullet)
                {
                    player.WeaponController().SetReservedBullet((EBulletCaliber)info.id, CarryClipUtil.GetClipCount(info.id, fd, room.ContextsWrapper.FreeArgs));
                }

                SimpleProto sp = FreePool.Allocate();
                sp.Key = FreeMessageConstant.PlaySound;
                sp.Ks.Add(2);
                sp.Ins.Add(5017);
                sp.Bs.Add(false);
                FreeMessageSender.SendMessage(fd.Player, sp);
            }

            room.ContextsWrapper.FreeArgs.Resume(PARA_PLAYER_CURRENT);
        }
Exemplo n.º 7
0
        private void handleToGround(string from, string to, ServerRoom room, FreeData fd)
        {
            PlayerStateUtil.AddPlayerState(EPlayerGameState.InterruptItem, fd.Player.gamePlay);
            FreeItemManager.DragItem(from, fd, room.ContextsWrapper.FreeArgs, ChickenConstant.BagGround);

            SimpleProto sp = FreePool.Allocate();

            sp.Key = FreeMessageConstant.PlaySound;
            sp.Ks.Add(2);
            sp.Ins.Add(5017);
            sp.Bs.Add(false);
            FreeMessageSender.SendMessage(fd.Player, sp);
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        private bool HandleBag(string from, string to, ServerRoom room, FreeData fd)
        {
            FreeItemInfo info = null;

            if (from.StartsWith(ChickenConstant.BagGround))
            {
                SimpleItemInfo sinfo = PickupItemUtil.GetGroundItemInfo(room, fd, from);
                info = FreeItemConfig.GetItemInfo(sinfo.cat, sinfo.id);
            }
            else
            {
                ItemPosition ip = FreeItemManager.GetItemPosition(room.ContextsWrapper.FreeArgs, from, fd.freeInventory.GetInventoryManager());
                if (ip == null)
                {
                    ItemInventory ii = fd.freeInventory.GetInventoryManager().GetInventory(from.Trim());
                    if (ii != null && ii.posList.Count > 0)
                    {
                        ip = ii.posList[0];
                    }
                }
                if (ip != null)
                {
                    info = FreeItemConfig.GetItemInfo(ip.key.GetKey());
                }
            }

            if (info != null && info.cat == 9)
            {
                RoleAvatarConfigItem avatar = SingletonManager.Get <RoleAvatarConfigManager>().GetConfigById(info.id);
                if (avatar.Capacity > 0)
                {
                    if (from.StartsWith(ChickenConstant.BagGround) && !to.StartsWith(ChickenConstant.BagGround))
                    {
                        return(BagCapacityUtil.CanAddToBag(room.ContextsWrapper.FreeArgs, fd, info.cat, info.id, 1));
                    }

                    if (to.StartsWith(ChickenConstant.BagGround) && !from.StartsWith(ChickenConstant.BagGround))
                    {
                        return(BagCapacityUtil.CanTakeOff(room.ContextsWrapper.FreeArgs, fd, info.cat, info.id));
                    }
                }
            }

            return(true);
        }
Exemplo n.º 10
0
 public static void ShowSplitUI(ServerRoom room, FreeData fd, string key)
 {
     // 分拆道具
     if (key.StartsWith("default"))
     {
         ItemPosition ip   = FreeItemManager.GetItemPosition(room.FreeArgs, key, fd.GetFreeInventory().GetInventoryManager());
         FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey());
         if (ip.count > 1)
         {
             SimpleProto data = FreePool.Allocate();
             data.Key = FreeMessageConstant.ShowSplitUI;
             data.Ins.Add(info.cat);
             data.Ins.Add(info.id);
             data.Ins.Add(ip.count);
             data.Ss.Add(key);
             data.Ss.Add(ip.GetKey().GetName());
             FreeMessageSender.SendMessage(fd.Player, data);
         }
     }
 }
Exemplo n.º 11
0
 public static void ShowSplitUI(ServerRoom room, FreeData fd, string key)
 {
     // 分拆道具
     if (key.StartsWith(ChickenConstant.BagDefault))
     {
         ItemPosition ip        = FreeItemManager.GetItemPosition(room.ContextsWrapper.FreeArgs, key, fd.GetFreeInventory().GetInventoryManager());
         FreeItemInfo info      = FreeItemConfig.GetItemInfo(ip.key.GetKey());
         var          stackable = true;
         if (info.cat == (int)ECategory.Weapon)
         {
             WeaponResConfigItem item = SingletonManager.Get <WeaponResourceConfigManager>().GetConfigById(info.id);
             if (item.Type != (int)EWeaponType_Config.ThrowWeapon)
             {
                 stackable = false;
             }
         }
         else
         {
             if (info.stack <= 1)
             {
                 stackable = false;
             }
         }
         SimpleProto data = FreePool.Allocate();
         if (!stackable || ip.count <= 1)
         {
             data.Key = FreeMessageConstant.ChickenTip;
             data.Ss.Add("word78");
             FreeMessageSender.SendMessage(fd.Player, data);
             return;
         }
         data.Key = FreeMessageConstant.ShowSplitUI;
         data.Ins.Add(info.cat);
         data.Ins.Add(info.id);
         data.Ins.Add(ip.count);
         data.Ss.Add(key);
         data.Ss.Add(ip.GetKey().GetName());
         FreeMessageSender.SendMessage(fd.Player, data);
         PlayerStateUtil.AddPlayerState(EPlayerGameState.InterruptItem, fd.Player.gamePlay);
     }
 }
Exemplo n.º 12
0
        public static void AddClip(int count, int clipType, FreeData fd, IEventArgs args)
        {
            if (BagCapacityUtil.CanAddToBag(args, fd, (int)ECategory.GameItem, clipType, count))
            {
                int            leftCount = count;
                ItemPosition[] ips       = fd.freeInventory.GetInventoryManager().GetDefaultInventory().GetItems();
                foreach (ItemPosition ip in ips)
                {
                    FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.key.GetKey());
                    if (ip.GetParameters().HasPara("ClipType") && (int)ip.GetParameters().Get("ClipType").GetValue() == clipType)
                    {
                        int added = Math.Min(leftCount, info.stack - ip.count);
                        leftCount -= added;

                        ip.SetCount(ip.GetCount() + added);
                        ip.GetInventory().GetInventoryUI().UpdateItem((FreeRuleEventArgs)args, ip.GetInventory(), ip);
                    }
                }

                if (leftCount > 0)
                {
                    FreeItem item = FreeItemManager.GetItem((FreeRuleEventArgs)args, FreeItemConfig.GetItemKey((int)ECategory.GameItem, clipType), leftCount);
                    if (item != null)
                    {
                        fd.freeInventory.GetInventoryManager().GetDefaultInventory().AddItem((ISkillArgs)args, item, true);
                    }
                }
            }
            else
            {
                FreeItem item = FreeItemManager.GetItem((FreeRuleEventArgs)args, FreeItemConfig.GetItemKey((int)ECategory.GameItem, clipType), count);
                if (item != null)
                {
                    fd.freeInventory.GetInventoryManager().GetInventory(ChickenConstant.BagGround).AddItem((ISkillArgs)args, item, true);
                }
            }
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
        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);
        }