Exemple #1
0
        /// <summary>
        /// 测试的时候设置人物数据
        /// </summary>
        public void TestSetRole()
        {
            var role = RolesInfo.CreateBuilder();

            role.Name     = "战士";
            role.PlayerId = 103;
            role.Level    = 1;
            role.Job      = (Job)1;
            selectChar    = role.Build();
        }
Exemple #2
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);
        }
Exemple #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 = 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);
        }
Exemple #4
0
        public void InitNewPlayerInfo()
        {
            playerInfo      = PlayerInfo.CreateBuilder();
            playerInfo.Exp  = 0;
            playerInfo.Gold = 0;
            var role = RolesInfo.CreateBuilder();

            role.Name        = "test";
            role.PlayerId    = 100;
            role.Level       = 1;
            role.Job         = Job.WARRIOR;
            playerInfo.Roles = role.Build();

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

            cin.Id     = 209;
            cin.IsPass = true;
            cinfo.AddCopyInfo(cin);
            playerInfo.CopyInfos = cinfo.Build();

            WindowMng.windowMng.ShowNotifyLog("初始化新的数据");
        }
Exemple #5
0
        private IEnumerator CheckBlack()
        {
            if (pressYet)
            {
                yield break;
            }
            pressYet = true;
            yield return(StatisticsManager.Instance.StartCoroutine(StatisticsManager.Instance.CheckBlack()));

            if (StatisticsManager.Instance.IsClose)
            {
                pressYet = false;
                yield break;
            }
            if (string.IsNullOrEmpty(name.value))
            {
                Util.ShowMsg("帐号名不能为空,请先登录帐号");
                pressYet = false;
                yield break;
            }

#if UNITY_ANDROID && !UNITY_EDITOR
            StatisticsManager.Instance.StartCoroutine(StatisticsManager.Instance.CheckNewUser(name.value));
#else
            var role = RolesInfo.CreateBuilder();
            role.PlayerId   = 1;
            role.Name       = "test";
            role.Level      = 1;
            role.Job        = Job.WARRIOR;
            role.CreateTime = 0;

            SaveGame.saveGame.SetSelectChar(role.Build());
            StartCoroutine(StatisticsManager.Instance.LoginServer(name.value));
#endif
            pressYet = false;
        }
Exemple #6
0
        void handleMsg(KBEngine.Packet packet)
        {
            var receivePkg = packet.protoBody.GetType().FullName;

            Debug.Log("Server Receive " + receivePkg);
            var          className   = receivePkg.Split(char.Parse(".")) [1];
            IBuilderLite retPb       = null;
            uint         flowId      = packet.flowId;
            bool         findHandler = false;

            if (className == "CGAutoRegisterAccount")
            {
                var au = GCAutoRegisterAccount.CreateBuilder();
                au.Username = "******";
                retPb       = au;
            }
            else if (className == "CGRegisterAccount")
            {
                var au = GCRegisterAccount.CreateBuilder();
                retPb = au;
            }
            else if (className == "CGLoginAccount")
            {
                var au         = GCLoginAccount.CreateBuilder();
                var playerInfo = ServerData.Instance.playerInfo;
                if (playerInfo.HasRoles)
                {
                    var role = RolesInfo.CreateBuilder().MergeFrom(playerInfo.Roles);
                    au.AddRolesInfos(role);
                }

                retPb = au;
            }
            else if (className == "CGSelectCharacter")
            {
                var inpb = packet.protoBody as CGSelectCharacter;
                if (inpb.PlayerId == 101)
                {
                    selectPlayerJob = 4;
                }
                else if (inpb.PlayerId == 102)
                {
                    selectPlayerJob = 2;
                }
                else
                {
                    selectPlayerJob = 1;
                }
                var au = GCSelectCharacter.CreateBuilder();
                au.TokenId = "12345";
                retPb      = au;
            }
            else if (className == "CGBindingSession")
            {
                var au = GCBindingSession.CreateBuilder();
                au.X             = 22;
                au.Y             = 1;
                au.Z             = 17;
                au.Direction     = 10;
                au.MapId         = 0;
                au.DungeonBaseId = 0;
                au.DungeonId     = 0;
                retPb            = au;
            }
            else if (className == "CGEnterScene")
            {
                var inpb = packet.protoBody as CGEnterScene;
                var au   = GCEnterScene.CreateBuilder();
                au.Id = inpb.Id;
                retPb = au;
            }
            else if (className == "CGListBranchinges")
            {
                var au   = GCListBranchinges.CreateBuilder();
                var bran = Branching.CreateBuilder();
                bran.Line        = 1;
                bran.PlayerCount = 2;
                au.AddBranching(bran);
                retPb = au;
            }
            else if (className == "CGHeartBeat")
            {
            }
            else if (className == "CGCopyInfo")
            {
                var pinfo = ServerData.Instance.playerInfo;
                if (pinfo.HasCopyInfos)
                {
                    retPb = GCCopyInfo.CreateBuilder().MergeFrom(pinfo.CopyInfos);
                }
                else
                {
                    //First Fetch Login Info
                    var au  = GCCopyInfo.CreateBuilder();
                    var cin = CopyInfo.CreateBuilder();
                    cin.Id     = 101;
                    cin.IsPass = false;
                    au.AddCopyInfo(cin);
                    var msg = au.Build();
                    pinfo.CopyInfos = msg;
                    retPb           = GCCopyInfo.CreateBuilder().MergeFrom(msg);
                }
            }


            else if (className == "CGUserDressEquip")
            {
                PlayerData.UserDressEquip(packet);
                findHandler = true;
            }
            else if (className == "CGAutoRegisterAccount")
            {
                var au = GCAutoRegisterAccount.CreateBuilder();
                au.Username = "******" + random.Next();
                retPb       = au;
            }
            else if (className == "CGRegisterAccount")
            {
                var inpb = packet.protoBody as CGRegisterAccount;
                ServerData.Instance.playerInfo.Username = inpb.Username;

                var au = GCRegisterAccount.CreateBuilder();
                retPb = au;
            }
            else if (className == "CGPlayerMove")
            {
                var au = GCPlayerMove.CreateBuilder();
                retPb = au;
            }
            else
            {
                var fullName    = packet.protoBody.GetType().FullName;
                var handlerName = fullName.Replace("MyLib", "ServerPacketHandler");

                var tp = Type.GetType(handlerName);
                if (tp == null)
                {
                    if (ServerPacketHandler.HoldCode.staticTypeMap.ContainsKey(handlerName))
                    {
                        tp = ServerPacketHandler.HoldCode.staticTypeMap [handlerName];
                    }
                }

                if (tp == null)
                {
                    Debug.LogError("PushMessage noHandler " + handlerName);
                }
                else
                {
                    findHandler = true;
                    var ph = (ServerPacketHandler.IPacketHandler)Activator.CreateInstance(tp);
                    ph.HandlePacket(packet);
                }
            }


            if (retPb != null)
            {
                SendPacket(retPb, flowId);
            }
            else
            {
                if (className != "CGHeartBeat" && !findHandler)
                {
                    Debug.LogError("DemoServer::not Handle Message " + className);
                }
            }
        }
Exemple #7
0
        void handleMsg(KBEngine.Packet packet)
        {
            var receivePkg = packet.protoBody.GetType().FullName;

            Debug.Log("Server Receive " + receivePkg);
            var          className   = receivePkg.Split(char.Parse(".")) [1];
            IBuilderLite retPb       = null;
            uint         flowId      = packet.flowId;
            bool         findHandler = false;

            if (className == "CGAutoRegisterAccount")
            {
                var au = GCAutoRegisterAccount.CreateBuilder();
                au.Username = "******";
                retPb       = au;
            }
            else if (className == "CGRegisterAccount")
            {
                var au = GCRegisterAccount.CreateBuilder();
                retPb = au;
            }
            else if (className == "CGLoginAccount")
            {
                var au         = GCLoginAccount.CreateBuilder();
                var playerInfo = ServerData.Instance.playerInfo;
                if (playerInfo.HasRoles)
                {
                    var role = RolesInfo.CreateBuilder().MergeFrom(playerInfo.Roles);
                    au.AddRolesInfos(role);
                }

                retPb = au;
            }
            else if (className == "CGSelectCharacter")
            {
                var inpb = packet.protoBody as CGSelectCharacter;
                if (inpb.PlayerId == 101)
                {
                    selectPlayerJob = 4;
                }
                else if (inpb.PlayerId == 102)
                {
                    selectPlayerJob = 2;
                }
                else
                {
                    selectPlayerJob = 1;
                }
                var au = GCSelectCharacter.CreateBuilder();
                au.TokenId = "12345";
                retPb      = au;
            }
            else if (className == "CGBindingSession")
            {
                var au = GCBindingSession.CreateBuilder();
                au.X             = 22;
                au.Y             = 1;
                au.Z             = 17;
                au.Direction     = 10;
                au.MapId         = 0;
                au.DungeonBaseId = 0;
                au.DungeonId     = 0;
                retPb            = au;
            }
            else if (className == "CGEnterScene")
            {
                var inpb = packet.protoBody as CGEnterScene;
                var au   = GCEnterScene.CreateBuilder();
                au.Id = inpb.Id;
                retPb = au;
            }
            else if (className == "CGListBranchinges")
            {
                var au   = GCListBranchinges.CreateBuilder();
                var bran = Branching.CreateBuilder();
                bran.Line        = 1;
                bran.PlayerCount = 2;
                au.AddBranching(bran);
                retPb = au;
            }
            else if (className == "CGHeartBeat")
            {
            }
            else if (className == "CGLoadSaleItems")
            {
                var au = GCLoadSaleItems.CreateBuilder();
                retPb = au;
            }
            else if (className == "CGListAllTeams")
            {
                var au = GCListAllTeams.CreateBuilder();
                retPb = au;
            }
            else if (className == "CGCopyInfo")
            {
                var pinfo = ServerData.Instance.playerInfo;
                if (pinfo.HasCopyInfos)
                {
                    retPb = GCCopyInfo.CreateBuilder().MergeFrom(pinfo.CopyInfos);
                }
                else
                {
                    //First Fetch Login Info
                    var au  = GCCopyInfo.CreateBuilder();
                    var cin = CopyInfo.CreateBuilder();
                    cin.Id     = 101;
                    cin.IsPass = false;
                    au.AddCopyInfo(cin);
                    var msg = au.Build();
                    pinfo.CopyInfos = msg;
                    retPb           = GCCopyInfo.CreateBuilder().MergeFrom(msg);
                }
            }
            else if (className == "CGLoadVipLevelGiftReceiveInfo")
            {
                var au  = GCLoadVipLevelGiftReceiveInfo.CreateBuilder();
                var vip = ReceviedReward.CreateBuilder();
                vip.RewardId = 1;
                au.AddReceviedLevelRewards(vip);

                vip          = ReceviedReward.CreateBuilder();
                vip.RewardId = 2;
                au.AddReceviedLevelRewards(vip);

                vip          = ReceviedReward.CreateBuilder();
                vip.RewardId = 3;
                au.AddReceviedLevelRewards(vip);

                retPb = au;
            }
            else if (className == "CGLoadVipInfo")
            {
                var au = GCLoadVipInfo.CreateBuilder();
                au.VipType       = VipType.NONE_VIP;
                au.VipRemainTime = 0;
                au.VipLevel      = 4;
                au.VipExp        = 0;
                retPb            = au;
            }
            else if (className == "CGLoadTaskList")
            {
                var au   = GCLoadTaskList.CreateBuilder();
                var task = PlayerTask.CreateBuilder();
                task.TaskId       = 1;
                task.PlayerTaskId = 1;
                task.PlayerId     = 2;
                task.TaskState    = 5;
                task.Chain        = 6;
                au.AddPlayerTask(task);

                task              = PlayerTask.CreateBuilder();
                task.TaskId       = 2;
                task.PlayerTaskId = 1;
                task.PlayerId     = 2;
                task.TaskState    = 5;
                task.Chain        = 6;
                au.AddPlayerTask(task);

                task              = PlayerTask.CreateBuilder();
                task.TaskId       = 3;
                task.PlayerTaskId = 1;
                task.PlayerId     = 2;
                task.TaskState    = 5;
                task.Chain        = 6;
                au.AddPlayerTask(task);

                retPb = au;
            }
            else if (className == "CGLoadAchievements")
            {
                var au = GCLoadAchievements.CreateBuilder();
                var ac = Achievement.CreateBuilder();
                ac.AchievementId = 1000;
                au.AddAchievements(ac);

                ac = Achievement.CreateBuilder();
                ac.AchievementId = 1001;
                au.AddAchievements(ac);

                ac = Achievement.CreateBuilder();
                ac.AchievementId = 1002;
                au.AddAchievements(ac);

                ac = Achievement.CreateBuilder();
                ac.AchievementId = 1003;
                au.AddAchievements(ac);

                ac = Achievement.CreateBuilder();
                ac.AchievementId = 1004;
                au.AddAchievements(ac);
                retPb = au;
            }
            else if (className == "CGAuctionInfo")
            {
                var au = GCAuctionInfo.CreateBuilder();
                au.MaxSize  = 1;
                au.PageSize = 6;
                var item = AuctionItem.CreateBuilder();
                item.Id         = 11;
                item.BaseId     = 14;
                item.Type       = 1;
                item.SellCount  = 2;
                item.RemainTime = 60;
                item.TotalCost  = 88;
                au.AddAuctionItems(item);

                item            = AuctionItem.CreateBuilder();
                item.Id         = 119;
                item.BaseId     = 15;
                item.Type       = 1;
                item.SellCount  = 2;
                item.RemainTime = 609;
                item.TotalCost  = 889;
                au.AddAuctionItems(item);

                item            = AuctionItem.CreateBuilder();
                item.Id         = 118;
                item.BaseId     = 16;
                item.Type       = 1;
                item.SellCount  = 2;
                item.RemainTime = 608;
                item.TotalCost  = 888;
                au.AddAuctionItems(item);

                item            = AuctionItem.CreateBuilder();
                item.Id         = 117;
                item.BaseId     = 23;
                item.Type       = 1;
                item.SellCount  = 2;
                item.RemainTime = 607;
                item.TotalCost  = 887;
                au.AddAuctionItems(item);

                item            = AuctionItem.CreateBuilder();
                item.Id         = 116;
                item.BaseId     = 24;
                item.Type       = 1;
                item.SellCount  = 2;
                item.RemainTime = 605;
                item.TotalCost  = 886;
                au.AddAuctionItems(item);

                item            = AuctionItem.CreateBuilder();
                item.Id         = 115;
                item.BaseId     = 25;
                item.Type       = 1;
                item.SellCount  = 2;
                item.RemainTime = 605;
                item.TotalCost  = 88;
                au.AddAuctionItems(item);
                retPb = au;
            }
            else if (className == "CGUserDressEquip")
            {
                PlayerData.UserDressEquip(packet);
                findHandler = true;
            }
            else if (className == "CGAutoRegisterAccount")
            {
                var au = GCAutoRegisterAccount.CreateBuilder();
                au.Username = "******" + random.Next();
                retPb       = au;
            }
            else if (className == "CGRegisterAccount")
            {
                var inpb = packet.protoBody as CGRegisterAccount;
                ServerData.Instance.playerInfo.Username = inpb.Username;

                var au = GCRegisterAccount.CreateBuilder();
                retPb = au;
            }
            else if (className == "CGPlayerMove")
            {
                var au = GCPlayerMove.CreateBuilder();
                retPb = au;
            }
            else
            {
                var fullName    = packet.protoBody.GetType().FullName;
                var handlerName = fullName.Replace("ChuMeng", "ServerPacketHandler");

                var tp = Type.GetType(handlerName);
                if (tp == null)
                {
                    if (ServerPacketHandler.HoldCode.staticTypeMap.ContainsKey(handlerName))
                    {
                        tp = ServerPacketHandler.HoldCode.staticTypeMap [handlerName];
                    }
                }

                if (tp == null)
                {
                    Debug.LogError("PushMessage noHandler " + handlerName);
                }
                else
                {
                    findHandler = true;
                    var ph = (ServerPacketHandler.IPacketHandler)Activator.CreateInstance(tp);
                    ph.HandlePacket(packet);
                }
            }


            if (retPb != null)
            {
                SendPacket(retPb, flowId);
            }
            else
            {
                if (className != "CGHeartBeat" && !findHandler)
                {
                    Debug.LogError("DemoServer::not Handle Message " + className);
                }
            }
        }