예제 #1
0
        public BackpackData(PackEntry e)
        {
            var pinfo = PackInfo.CreateBuilder();

            pinfo.PackEntry = e;
            packInfo        = pinfo.Build();
            entry           = e;
            //num = entry.Count;
            itemData = Util.GetItemData(e.GoodsType, baseId);
        }
예제 #2
0
        public static void UserDressEquip(KBEngine.Packet packet)
        {
            var inpb  = packet.protoBody as CGUserDressEquip;
            var pinfo = ServerData.Instance.playerInfo;

            PackInfo oldEquip = null;

            if (inpb.DestEquipId != 0)
            {
                foreach (var p in pinfo.DressInfoList)
                {
                    if (p.PackEntry.Id == inpb.DestEquipId)
                    {
                        oldEquip = p;
                        pinfo.DressInfoList.Remove(oldEquip);
                        break;
                    }
                }
            }
            PackInfo newEquip = null;

            if (inpb.SrcEquipId != 0)
            {
                foreach (var p in pinfo.PackInfoList)
                {
                    if (p.PackEntry.Id == inpb.SrcEquipId)
                    {
                        newEquip = p;
                        RemoveEquipFromPackage(inpb.SrcEquipId);
                        break;
                    }
                }
            }

            if (oldEquip != null)
            {
                PutEquipInPackage(oldEquip);
            }
            Log.Net("PutEquipInPackage " + oldEquip.PackEntry.Id);

            var newEquip2 = PackInfo.CreateBuilder(newEquip);

            newEquip2.PackEntry.Count = 1;

            pinfo.DressInfoList.Add(newEquip2.Build());

            var au = GCUserDressEquip.CreateBuilder();

            au.DressEquip = newEquip.PackEntry;
            if (oldEquip != null)
            {
                au.PackEquip = oldEquip.PackEntry;
            }
            ServerBundle.SendImmediate(au, packet.flowId);
        }
예제 #3
0
        public static void CreateCharacter(KBEngine.Packet packet)
        {
            var inpb = packet.protoBody as CGCreateCharacter;
            var au   = GCCreateCharacter.CreateBuilder();
            var role = RolesInfo.CreateBuilder();

            role.Name     = inpb.PlayerName;
            role.PlayerId = 100;
            //playerId++;
            role.Level = 1;
            role.Job   = inpb.Job;

            var msg = role.Build();

            ServerData.Instance.playerInfo.Roles = RolesInfo.CreateBuilder(msg).Build();

            var dress = new int[]
            {
                97, 68, 69, 70, 71, 72,
            };
            int id    = 1;
            var pinfo = ServerData.Instance.playerInfo;

            foreach (var d in dress)
            {
                var pkinfo  = PackInfo.CreateBuilder();
                var pkEntry = PackEntry.CreateBuilder();
                pkEntry.Id        = id++;
                pkEntry.BaseId    = d;
                pkEntry.GoodsType = 1;
                pkEntry.Level     = 1;
                pkinfo.PackEntry  = pkEntry.Build();
                pinfo.AddDressInfo(pkinfo);
            }

            var cinfo = GCCopyInfo.CreateBuilder();
            var cin   = CopyInfo.CreateBuilder();

            cin.Id     = 209;
            cin.IsPass = true;
            cinfo.AddCopyInfo(cin);
            var msg2 = cinfo.Build();

            pinfo.CopyInfos = msg2;

            au.AddRolesInfos(msg);
            ServerBundle.SendImmediate(au, packet.flowId);

            //投掷 跳跃
            pinfo.Roles.Level = 10;
            AddSkillPoint(10);
            LevelUpSkill(3);
            LevelUpSkill(4);
        }
예제 #4
0
        public static void CreateCharacter(KBEngine.Packet packet)
        {
            var inpb = packet.protoBody as CGCreateCharacter;
            var au   = GCCreateCharacter.CreateBuilder();
            var role = RolesInfo.CreateBuilder();

            role.Name     = inpb.PlayerName;
            role.PlayerId = 100;
            //playerId++;
            role.Level = 1;
            role.Job   = inpb.Job;

            var msg = role.Build();

            ServerData.Instance.playerInfo.Roles = msg;

            var dress = new int[]
            {
                97, 68, 69, 70, 71, 72,
            };
            int id    = 1;
            var pinfo = ServerData.Instance.playerInfo;

            foreach (var d in dress)
            {
                var pkinfo  = PackInfo.CreateBuilder();
                var pkEntry = PackEntry.CreateBuilder();
                pkEntry.Id        = id++;
                pkEntry.BaseId    = d;
                pkEntry.GoodsType = 1;
                pkEntry.Level     = 1;
                pkinfo.PackEntry  = pkEntry.Build();
                pinfo.AddDressInfo(pkinfo);
            }

            au.AddRolesInfos(msg);


            ServerBundle.SendImmediate(au, packet.flowId);
        }
예제 #5
0
        //Notify
        //Props Stack
        /// <summary>
        /// 得到的道具装备都是白装,自己不断升级,类似怪物猎人
        /// </summary>
        /// <param name="itemId">Item identifier.</param>
        /// <param name="num">Number.</param>
        public static void AddItemInPackage(int itemId, int num)
        {
            var pinfo    = ServerData.Instance.playerInfo;
            var itemData = Util.GetItemData(0, itemId);

            if (itemData.UnitType == ItemData.UnitTypeEnum.GOLD)
            {
                PlayerData.AddGold(num);
                return;
            }

            //Has Such Objects
            if (itemData.MaxStackSize > 1)
            {
                Log.Sys("AddItemInStack");
                foreach (var p in pinfo.PackInfoList)
                {
                    if (p.PackEntry.BaseId == itemId && p.PackEntry.GoodsType == (int)ItemData.GoodsType.Props)
                    {
                        pinfo.PackInfoList.Remove(p);
                        var newPkinfo  = PackInfo.CreateBuilder(p);
                        var newPkEntry = PackEntry.CreateBuilder(p.PackEntry);
                        newPkEntry.Count   += num;
                        newPkinfo.PackEntry = newPkEntry.Build();
                        var msg = newPkinfo.Build();
                        pinfo.PackInfoList.Add(msg);


                        var push = GCPushPackInfo.CreateBuilder();
                        push.BackpackAdjust = false;
                        push.PackType       = PackType.DEFAULT_PACK;
                        push.PackInfoList.Add(msg);

                        ServerBundle.SendImmediatePush(push);

                        SendNotify(string.Format("[ff0a0a]{0}+{1}[-]", itemData.ItemName, num));
                        return;
                    }
                }
            }
            //new Item
            //all Slot
            PackInfo[] packList = new PackInfo[BackPack.MaxBackPackNumber];
            long       maxId    = 0;

            foreach (var p in pinfo.PackInfoList)
            {
                packList [p.PackEntry.Index] = p;
                maxId = (long)Mathf.Max(p.PackEntry.Id + 1, maxId);
            }

            foreach (var p in pinfo.DressInfoList)
            {
                maxId = (long)Mathf.Max(p.PackEntry.Id + 1, maxId);
            }

            if (maxId < 0)
            {
                maxId++;
            }

            for (int i = 0; i < BackPack.MaxBackPackNumber; i++)
            {
                if (packList [i] == null)
                {
                    var pkInfo  = PackInfo.CreateBuilder();
                    var pkentry = PackEntry.CreateBuilder();
                    pkInfo.CdTime = 0;

                    pkentry.Id        = maxId;
                    pkentry.BaseId    = itemId;
                    pkentry.GoodsType = 0;
                    pkentry.Count     = num;
                    pkentry.Index     = i;

                    pkInfo.PackEntry = pkentry.Build();
                    var msg = pkInfo.Build();
                    pinfo.PackInfoList.Add(msg);

                    var push = GCPushPackInfo.CreateBuilder();
                    push.BackpackAdjust = false;
                    push.PackType       = PackType.DEFAULT_PACK;
                    push.PackInfoList.Add(msg);
                    ServerBundle.SendImmediatePush(push);

                    SendNotify(string.Format("[ff0a0a]{0}+{1}[-]", itemData.ItemName, num));
                    return;
                }
            }

            //PackFull
            var notify = GCPushNotify.CreateBuilder();

            notify.Notify = "背包已满";
            ServerBundle.SendImmediatePush(notify);
        }
예제 #6
0
        /// <summary>
        /// 背包中增加新获得的武器
        /// 背包改造为无限长度 并且没有限制
        /// </summary>
        public static void AddEquipInPackage(int equipId, int initAttack, int initDefense)
        {
            Log.Sys("AddEquipInpackage " + equipId + " initAttack " + initAttack + " initDef " + initDefense);
            var pinfo    = ServerData.Instance.playerInfo;
            var itemData = Util.GetItemData((int)GoodsTypeEnum.Equip, equipId);

            PackInfo[] packList = new PackInfo[BackPack.MaxBackPackNumber];
            long       maxId    = 0;

            foreach (var p in pinfo.PackInfoList)
            {
                packList [p.PackEntry.Index] = p;
                maxId = (long)Mathf.Max(p.PackEntry.Id + 1, maxId);
            }

            foreach (var p in pinfo.DressInfoList)
            {
                maxId = (long)Mathf.Max(p.PackEntry.Id + 1, maxId);
            }

            if (maxId < 0)
            {
                maxId++;
            }
            for (int i = 0; i < BackPack.MaxBackPackNumber; i++)
            {
                if (packList [i] == null)
                {
                    var pkInfo  = PackInfo.CreateBuilder();
                    var pkentry = PackEntry.CreateBuilder();
                    pkInfo.CdTime = 0;

                    pkentry.Id         = maxId;
                    pkentry.BaseId     = equipId;
                    pkentry.GoodsType  = 1;
                    pkentry.Count      = 1;
                    pkentry.Index      = i;
                    pkentry.Level      = 1;
                    pkentry.RndAttack  = initAttack;
                    pkentry.RndDefense = initDefense;

                    pkInfo.PackEntry = pkentry.Build();
                    var msg = pkInfo.Build();
                    pinfo.PackInfoList.Add(msg);

                    var push = GCPushPackInfo.CreateBuilder();
                    push.BackpackAdjust = false;
                    push.PackType       = PackType.DEFAULT_PACK;
                    push.PackInfoList.Add(msg);
                    ServerBundle.SendImmediatePush(push);

                    SendNotify(string.Format("[ff0a0a]{0}+{1}[-]", itemData.ItemName, 1));
                    return;
                }
            }

            //PackFull
            var notify = GCPushNotify.CreateBuilder();

            notify.Notify = "[f00b00]背包已满[-]";
            ServerBundle.SendImmediatePush(notify);
        }