Example #1
0
 //屏幕中间公告
 public void SceneNotice(String text)
 {
     NetMsg.MsgNotice notice = new NetMsg.MsgNotice();
     notice.Create(null, null);
     byte[] buff = notice.GetSceneNoticeBuff(text);
     UserEngine.Instance().BrocatBuffer(buff);
 }
Example #2
0
        public void ProcessDBNetMsg()
        {
            if (!mbConnect && System.Environment.TickCount - mnReconnectTick > 5000)//五秒重连
            {
                mTcpDBClient.ReConnect();
                mnReconnectTick = System.Environment.TickCount;
            }
            byte[] buff = null;
            lock (_lock)
            {
                buff = mDBPacket.GetData();
            }

            if (buff == null)
            {
                return;
            }
            PackIn inpack = new PackIn(buff);
            ushort param  = inpack.ReadUInt16();

            switch (param)
            {
            case GameBase.Network.Internal.Define.ROLEINFO:
            {
                GameBase.Network.Internal.RoleInfo roleinfo = new GameBase.Network.Internal.RoleInfo(buff);
                //判断是否有缓存数据-
                PlayerObject cacheplay = UserEngine.Instance().GetCachePlay(roleinfo.sAccount);
                if (cacheplay != null)
                {
                    Log.Instance().WriteLog("检测到角色缓存数据,保存中!" + cacheplay.GetName());
                    UserEngine.Instance().RemoveCachePlay(cacheplay);
                    cacheplay.ExitGame();
                    return;
                }
                UserEngine.Instance().AddTempPlayObject(roleinfo);

                //回发给dbserver 表示收到了角色信息- 让他通知loginserver 发数据给玩家连接mapserver
                GameBase.Network.Internal.RoleInfo_Ret ret = new GameBase.Network.Internal.RoleInfo_Ret();
                ret.gameid    = roleinfo.gameid;
                ret.key       = roleinfo.mKey;
                ret.key2      = roleinfo.mKey1;
                ret.accountid = roleinfo.accountid;
                mTcpDBClient.SendData(ret.GetBuffer());
                Log.Instance().WriteLog("收到临时角色信息:" + roleinfo.sAccount + " id:" + roleinfo.accountid.ToString());
                break;
            }

            case GameBase.Network.Internal.Define.QUERYROLENAME_RET:
            {
                QueryRoleName_Ret ret = new QueryRoleName_Ret();
                ret.Create(buff);
                TempPlayObject temp = UserEngine.Instance().GetTempPlayObj(ret.gameid);
                if (temp == null)
                {
                    Log.Instance().WriteLog("找到玩家对象..在--ProcessDBNetMsg code:2");
                    break;
                }

                NetMsg.MsgNotice notice = new NetMsg.MsgNotice();
                notice.Create(null, temp.play.GetGamePackKeyEx());
                temp.play.SendData(notice.GetQueryNameBuff(!ret.tag));

                break;
            }

            case GameBase.Network.Internal.Define.CREATEROLE_RET:
            {
                CreateRole_Ret ret = new CreateRole_Ret();
                ret.Create(buff);
                TempPlayObject temp = UserEngine.Instance().GetTempPlayObj(ret.gameid);
                if (temp == null)
                {
                    Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:3");
                    break;
                }


                UserEngine.Instance().RemoveTempPlayObject(ret.gameid);         //从临时列表出移除--
                //进入游戏
                temp.play.GetBaseAttr().account_id = temp.accountid;
                temp.play.GetBaseAttr().player_id  = ret.playerid;
                temp.play.EnterGame(null, true);
                break;
            }

            case GameBase.Network.Internal.Define.ADDROLEDATA_ITEM_RET:
            {
                GameBase.Network.Internal.AddRoleData_Item_Ret ret = new GameBase.Network.Internal.AddRoleData_Item_Ret();
                ret.Create(buff);
                PlayerObject play = UserEngine.Instance().FindPlayerObjectToID(ret.gameid);
                if (play == null)
                {
                    Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:4");
                    break;
                }
                play.GetItemSystem().AwardItem_Ret(ret.sordid, ret.id);
                break;
            }

            case GameBase.Network.Internal.Define.LOADROLEDATA_ITEM:
            {
                GameBase.Network.Internal.ROLEDATA_ITEM item = new GameBase.Network.Internal.ROLEDATA_ITEM();
                item.Create(buff);
                TempPlayObject play = UserEngine.Instance().GetTempPlayObj(item.key, item.key2);
                if (play == null)
                {
                    Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:5");
                    break;
                }
                for (int i = 0; i < item.mListItem.Count; i++)
                {
                    play.play.GetItemSystem().AddItemInfo(item.mListItem[i]);
                }
                break;
            }

            case GameBase.Network.Internal.Define.LOADROLEDATA_MAGIC:
            {
                GameBase.Network.Internal.RoleData_Magic magic = new GameBase.Network.Internal.RoleData_Magic();
                magic.Create(buff);
                TempPlayObject play = UserEngine.Instance().GetTempPlayObj(magic.key, magic.key2);
                if (play == null)
                {
                    Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:6");
                    break;
                }
                for (int i = 0; i < magic.mListMagic.Count; i++)
                {
                    GameBase.Network.Internal.MagicInfo info = magic.mListMagic[i];
                    play.play.GetMagicSystem().AddMagicInfo(info);
                }

                break;
            }

            case GameBase.Network.Internal.Define.KICKGAMEPLAY:
            {
                GameBase.Network.Internal.KickGamePlay kickplay = new GameBase.Network.Internal.KickGamePlay();
                kickplay.Create(buff);
                PlayerObject play = UserEngine.Instance().FindPlayerObjectToAccountId(kickplay.accountid);
                if (play != null)
                {
                    SessionManager.Instance().RemoveSession(play.GetGameSession().m_Socket);
                    play.Kick();
                }
                break;
            }

            case GameBase.Network.Internal.Define.LOADROLEDATA_EUDEMON:
            {
                GameBase.Network.Internal.ROLEDATE_EUDEMON eudemon = new GameBase.Network.Internal.ROLEDATE_EUDEMON();
                eudemon.Create(buff);

                TempPlayObject play = UserEngine.Instance().GetTempPlayObj(eudemon.key, eudemon.key2);
                if (play == null)
                {
                    //只是为了下断点后延迟问题解决方案
                    PlayerObject _play = UserEngine.Instance().FindPlayerObjectToPlayerId(eudemon.playerid);
                    if (_play == null)
                    {
                        Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:6");
                    }
                    else
                    {
                        _play.GetEudemonSystem().DB_Load(eudemon);
                        _play.GetEudemonSystem().SendAllEudemonInfo();
                    }

                    break;
                }
                else
                {
                    play.play.GetEudemonSystem().DB_Load(eudemon);
                }


                break;
            }

            case GameBase.Network.Internal.Define.LOADROLEDATA_FRIEND:
            {
                GameBase.Network.Internal.ROLEDATA_FRIEND friend = new GameBase.Network.Internal.ROLEDATA_FRIEND();
                friend.Create(buff);
                TempPlayObject play = UserEngine.Instance().GetTempPlayObj(friend.key, friend.key2);
                if (play == null)
                {
                    //只是为了下断点后延迟问题解决方案
                    PlayerObject _play = UserEngine.Instance().FindPlayerObjectToPlayerId(friend.playerid);
                    if (_play == null)
                    {
                        Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:7");
                    }
                    else
                    {
                        _play.GetFriendSystem().DB_Load(friend);
                        _play.GetFriendSystem().SendAllFriendInfo();
                    }

                    break;
                }
                else
                {
                    play.play.GetFriendSystem().DB_Load(friend);
                }

                break;
            }

            case GameBase.Network.Internal.Define.GUANJUEDATA:     //爵位数据
            {
                GameBase.Network.Internal.GUANJUEINFO juewei = new GameBase.Network.Internal.GUANJUEINFO();
                juewei.Create(buff);
                GuanJueManager.Instance().DB_Load(juewei);
                break;
            }

            case GameBase.Network.Internal.Define.LOADLEGION:     //军团数据
            {
                GameBase.Network.Internal.LEGIONINFO info = new GameBase.Network.Internal.LEGIONINFO();
                info.Create(buff);
                LegionManager.Instance().DB_Load(info);
                break;
            }

            case GameBase.Network.Internal.Define.CREATELEGION_RET:    //创建军团返回数据
            {
                GameBase.Network.Internal.CreateLegion_Ret info = new GameBase.Network.Internal.CreateLegion_Ret();
                info.Create(buff);
                LegionManager.Instance().CreateLegion_Ret(info);
                break;
            }

            case GameBase.Network.Internal.Define.LOADPAYRECINFO:     //充值数据
            {
                GameBase.Network.Internal.PackPayRecInfo info = new GameBase.Network.Internal.PackPayRecInfo();
                info.Creaet(buff);
                PayManager.Instance().DB_Load(info);
                break;
            }
            }
        }
Example #3
0
 //屏幕中间公告
 public void SceneNotice(String text)
 {
     NetMsg.MsgNotice notice = new NetMsg.MsgNotice();
     notice.Create(null, null);
     byte[] buff = notice.GetSceneNoticeBuff(text);
     UserEngine.Instance().BrocatBuffer(buff);
 }
Example #4
0
        public void ProcessNetMsg()
        {
            foreach (GameSession session in m_DicSession.Values)
                {
                    if (session == null || session.m_GamePack == null) continue;
                    byte[] retdata = session.m_GamePack.GetData();
                    if (retdata != null)
                    {
                        GameBase.Network.PackIn packin = new GameBase.Network.PackIn(retdata);
                        PlayerObject play = UserEngine.Instance().FindPlayerObjectToID(session.gameid);
                        ushort tag = packin.ReadUInt16();
                        if (play != null)
                        {
                            play.ProcessNetMsg(tag, retdata);
                            continue;
                        }
                        //第一次的封包一定是更新key哒..
                        if (play == null && tag != PacketProtoco.C_UPDATEKEY && tag != PacketProtoco.C_QUERYCREATEROLENAME
                            && tag != PacketProtoco.C_CREATEROLE) continue;

                        switch (tag)
                        {
                            case PacketProtoco.C_UPDATEKEY:
                                {

                                    int key = packin.ReadInt32();
                                    int key2 = packin.ReadInt32();
                                    TempPlayObject tempplay = UserEngine.Instance().GetTempPlayObj(key, key2);
                                    if (tempplay == null) return; //没有经过loginsserver进入的非法封包
                                    tempplay.play.SetGameSession(session);
                                    session.GetGamePackKeyEx().SunUpdateKey(key, key2);
                                    NetMsg.MsgNotice msgNotice;
                                    //没有角色就创建角色
                                    if (!tempplay.isRole)
                                    {
                                        msgNotice = new NetMsg.MsgNotice();
                                        msgNotice.Create(null, session.GetGamePackKeyEx());
                                        session.SendData(msgNotice.GetCreateRoleBuff());
                                        return;
                                    }
                                    //有角色就进游戏
                                    UserEngine.Instance().RemoveTempPlayObject(tempplay.play.GetGameID());
                                    tempplay.play.EnterGame(session);
                                    break;
                                }
                            case PacketProtoco.C_QUERYCREATEROLENAME:   //创建角色名查询
                                {
                                    NetMsg.MsgQueryCreateRoleName info = new NetMsg.MsgQueryCreateRoleName();
                                    info.Create(retdata, null);
                                    int key  = 0,key2 = 0;
                                    session.GetGamePackKeyEx().GetKey(ref key,ref key2);
                                    TempPlayObject temp = UserEngine.Instance().GetTempPlayObj(key,key2);
                                    if(temp == null)
                                    {
                                        Log.Instance().WriteLog("找到玩家对象-在ProcessNetMsg code:1");
                                        break;
                                    }

                                    //发给dbserver 查询
                                    GameBase.Network.Internal.QueryRoleName query = new GameBase.Network.Internal.QueryRoleName();
                                    query.gameid = temp.play.GetGameID();
                                    query.name = info.GetName();

                                    DBServer.Instance().GetDBClient().SendData(query.GetBuffer());

                                    //NetMsg.MsgNotice notice = new NetMsg.MsgNotice();
                                    //notice.Create(null, session.GetGamePackKeyEx());
                                    //session.SendData(notice.GetQueryNameBuff());
                                    break;
                                }
                            case PacketProtoco.C_CREATEROLE:    //创建角色
                                {

                                    int key = 0, key2 = 0;
                                    session.GetGamePackKeyEx().GetKey(ref key, ref key2);
                                    TempPlayObject temp = UserEngine.Instance().GetTempPlayObj(key, key2);
                                    if (temp == null)
                                    {
                                        Log.Instance().WriteLog("找到玩家对象-在ProcessNetMsg code:2");
                                        break;
                                    }
                                    NetMsg.MsgCreateRoleInfo info = new NetMsg.MsgCreateRoleInfo();
                                    info.Create(retdata, null);
                                    if (info.GetName().Length <= 0)
                                    {
                                        Log.Instance().WriteLog("角色名称为空!!");
                                        break;
                                    }
                                    PlayerObject _play = temp.play;
                                    _play.SetGameSession(session);

                                    _play.SetName(info.GetName());
                                    _play.GetBaseAttr().profession = (byte)info.profession;
                                    _play.GetBaseAttr().lookface = info.lookface;

                                    //发给dbserver
                                    GameBase.Network.Internal.CreateRole create = new GameBase.Network.Internal.CreateRole();
                                    create.accountid = temp.accountid;
                                    create.lookface = info.lookface;
                                    create.name = info.GetName();
                                    create.profession = (byte)info.profession;
                                    create.gameid = temp.play.GetGameID();
                                    DBServer.Instance().GetDBClient().SendData(create.GetBuffer());
                                   //测试游戏
                                    //play = new PlayerObject();
                                    //play.mapid = 1000;
                                    //play.mPoint.x = 400;
                                    //play.mPoint.y = 440;
                                    //session.gameid = play.GetGameID();
                                    //MapManager.Instance().GetGameMapToID(play.mapid).AddObject(play, session);
                                    //UserEngine.Instance().AddPlayerObject(play);

                                    ////公告信息
                                    //NetMsg.MsgNotice msgNotice = new NetMsg.MsgNotice();
                                    //msgNotice.Create(null, session.GetGamePackKeyEx());
                                    //session.SendData(msgNotice.GetStartGameBuff());
                                    //byte[] roledata = {238, 3, 64, 66, 15, 0, 241, 73, 2, 0, 101,
                                    //      0, 0, 0, 60, 1, 0, 0, 0, 0, 0, 0, 81, 118,
                                    //      203, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                    //      31, 1, 0, 0, 73, 0, 0, 0, 30, 0, 100, 0, 99,
                                    //      0, 102, 0, 0, 0, 202, 3, 222, 3, 134, 7, 0, 0,
                                    //      0, 0, 0, 0, 0, 0, 0, 0, 255, 10, 0, 0, 1, 0, 0,
                                    //      0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 12, 0, 0,
                                    //      0, 0, 0, 0, 0, 0, 0, 20, 0, 4, 0, 0, 0, 0, 0, 0, 0,
                                    //      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                    //      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                    //      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                    //      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                    //      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 105,
                                    //      0, 0, 0, 92, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                    //      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                                    //      0, 0, 0, 0, 2, 8, 102, 101, 111, 119, 102, 113, 101, 119, 2,
                                    //      206, 222, 0, 0, 0 };
                                    ////session.GetGamePackKeyEx().EncodePacket(ref roledata, roledata.Length);
                                    ////session.SendData(roledata);
                                    ////
                                    //NetMsg.MsgSelfRoleInfo rolemsg = new NetMsg.MsgSelfRoleInfo();
                                    //rolemsg.Create(roledata, session.GetGamePackKeyEx());
                                    //rolemsg.roletype = 140001;
                                    //rolemsg.roleid = play.GetTypeId();
                                    //rolemsg.name = "测试角色" + play.GetTypeId().ToString();
                                    //play.Name = rolemsg.name;
                                    //session.SendData(rolemsg.GetBuffer());

                                    ////测试增加装备 测试装备
                                    //NetMsg.MsgItemInfo item = new NetMsg.MsgItemInfo();
                                    //item.Create(null, session.GetGamePackKeyEx());
                                    //item.postion = NetMsg.MsgItemInfo.ITEMPOSITION_ARMOR;
                                    //item.id = 112434;
                                    //item.item_id = 135114;
                                    //item.amount = item.amount_limit = 1;
                                    //session.SendData(item.GetBuffer());
                                    ////测试武器
                                    //item = new NetMsg.MsgItemInfo();
                                    //item.Create(null, session.GetGamePackKeyEx());
                                    //item.postion = NetMsg.MsgItemInfo.ITEMPOSITION_WEAPONR;
                                    //item.id = 112435;
                                    //item.item_id = 440244;
                                    //item.amount = item.amount_limit = 1;
                                    //session.SendData(item.GetBuffer());

                                    //NetMsg.MsgUpdateSP sp = new NetMsg.MsgUpdateSP();
                                    //sp.Create(null, session.GetGamePackKeyEx());
                                    //sp.role_id = play.GetTypeId();
                                    //sp.value = 37;
                                    //sp.sp = 100;
                                    //session.SendData(sp.GetBuffer());

                                    //sp = new NetMsg.MsgUpdateSP();
                                    //sp.Create(null, session.GetGamePackKeyEx());
                                    //sp.role_id = play.GetTypeId();
                                    //session.SendData(sp.GetBuffer());

                                    ////测试新增技能
                                    //ushort[] skill = { 3011 };//, 3002, 1010, 3005, 3009, 8003
                                    //for (int i = 0; i < skill.Length; i++)
                                    //{
                                    //    NetMsg.MsgMagicInfo magicinfo = new NetMsg.MsgMagicInfo();
                                    //    magicinfo.Create(null, session.GetGamePackKeyEx());
                                    //    magicinfo.id = play.GetTypeId();
                                    //    magicinfo.magicid = skill[i];
                                    //    magicinfo.level = 2;
                                    //    session.SendData(magicinfo.GetBuffer());
                                    //}

                                    ////进入地图
                                    //NetMsg.MsgMapInfo mapinfo = new NetMsg.MsgMapInfo();
                                    //mapinfo.Create(null, session.GetGamePackKeyEx());
                                    //mapinfo.Init(play.mapid, play.mPoint.x, play.mPoint.y);
                                    //session.SendData(mapinfo.GetBuffer());

                                    ////刷新可视列表;

                                    //play.RefreshVisibleObject();
                                    //GameStruct.Action act = new GameStruct.Action(GameStruct.Action.MOVE);
                                    //play.PushAction(act);
                                    break;
                                }
                        }

                }

            }
        }
Example #5
0
        public void ProcessDBNetMsg()
        {
            if (!mbConnect && System.Environment.TickCount - mnReconnectTick > 5000)//五秒重连
            {
                mTcpDBClient.ReConnect();
                mnReconnectTick = System.Environment.TickCount;
            }
            byte[] buff = null;
            lock (_lock)
            {
                buff = mDBPacket.GetData();
            }

            if (buff == null) return;
            PackIn inpack = new PackIn(buff);
            ushort param = inpack.ReadUInt16();
            switch (param)
            {
                case GameBase.Network.Internal.Define.ROLEINFO:
                    {
                        GameBase.Network.Internal.RoleInfo roleinfo = new GameBase.Network.Internal.RoleInfo(buff);
                        //判断是否有缓存数据-
                        PlayerObject cacheplay = UserEngine.Instance().GetCachePlay(roleinfo.sAccount);
                        if (cacheplay != null)
                        {
                            Log.Instance().WriteLog("检测到角色缓存数据,保存中!" + cacheplay.GetName());
                            UserEngine.Instance().RemoveCachePlay(cacheplay);
                            cacheplay.ExitGame();
                            return;
                        }
                        UserEngine.Instance().AddTempPlayObject(roleinfo);

                        //回发给dbserver 表示收到了角色信息- 让他通知loginserver 发数据给玩家连接mapserver
                        GameBase.Network.Internal.RoleInfo_Ret ret = new GameBase.Network.Internal.RoleInfo_Ret();
                        ret.gameid = roleinfo.gameid;
                        ret.key = roleinfo.mKey;
                        ret.key2 = roleinfo.mKey1;
                        ret.accountid = roleinfo.accountid;
                        mTcpDBClient.SendData(ret.GetBuffer());
                        Log.Instance().WriteLog("收到临时角色信息:" + roleinfo.sAccount+" id:"+roleinfo.accountid.ToString());
                        break;
                    }
                case GameBase.Network.Internal.Define.QUERYROLENAME_RET:
                    {
                        QueryRoleName_Ret ret = new QueryRoleName_Ret();
                        ret.Create(buff);
                        TempPlayObject temp = UserEngine.Instance().GetTempPlayObj(ret.gameid);
                        if (temp == null)
                        {
                            Log.Instance().WriteLog("找到玩家对象..在--ProcessDBNetMsg code:2");
                            break;
                        }

                        NetMsg.MsgNotice notice = new NetMsg.MsgNotice();
                        notice.Create(null, temp.play.GetGamePackKeyEx());
                        temp.play.SendData(notice.GetQueryNameBuff(!ret.tag));

                        break;
                    }
                case GameBase.Network.Internal.Define.CREATEROLE_RET:
                    {

                        CreateRole_Ret ret = new CreateRole_Ret();
                        ret.Create(buff);
                        TempPlayObject temp = UserEngine.Instance().GetTempPlayObj(ret.gameid);
                        if (temp == null)
                        {
                            Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:3");
                            break;
                        }

                        UserEngine.Instance().RemoveTempPlayObject(ret.gameid); //从临时列表出移除--
                        //进入游戏
                        temp.play.GetBaseAttr().account_id = temp.accountid;
                        temp.play.GetBaseAttr().player_id = ret.playerid;
                        temp.play.EnterGame(null,true);
                        break;
                    }
                case GameBase.Network.Internal.Define.ADDROLEDATA_ITEM_RET:
                    {
                        GameBase.Network.Internal.AddRoleData_Item_Ret ret = new GameBase.Network.Internal.AddRoleData_Item_Ret();
                        ret.Create(buff);
                        PlayerObject play = UserEngine.Instance().FindPlayerObjectToID(ret.gameid);
                        if (play == null)
                        {
                            Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:4");
                            break;
                        }
                        play.GetItemSystem().AwardItem_Ret(ret.sordid, ret.id);
                        break;
                    }
                case GameBase.Network.Internal.Define.LOADROLEDATA_ITEM:
                    {
                        GameBase.Network.Internal.ROLEDATA_ITEM item = new GameBase.Network.Internal.ROLEDATA_ITEM();
                        item.Create(buff);
                        TempPlayObject play = UserEngine.Instance().GetTempPlayObj(item.key,item.key2);
                        if (play == null)
                        {
                            Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:5");
                            break;
                        }
                        for (int i = 0; i < item.mListItem.Count; i++)
                        {
                            play.play.GetItemSystem().AddItemInfo(item.mListItem[i]);
                        }
                         break;
                    }
                case GameBase.Network.Internal.Define.LOADROLEDATA_MAGIC:
                    {
                        GameBase.Network.Internal.RoleData_Magic magic = new GameBase.Network.Internal.RoleData_Magic();
                        magic.Create(buff);
                        TempPlayObject play = UserEngine.Instance().GetTempPlayObj(magic.key, magic.key2);
                        if (play == null)
                        {
                            Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:6");
                            break;
                        }
                        for(int i = 0;i < magic.mListMagic.Count;i++)
                        {
                            GameBase.Network.Internal.MagicInfo info = magic.mListMagic[i];
                            play.play.GetMagicSystem().AddMagicInfo(info);
                        }

                        break;
                    }
                case GameBase.Network.Internal.Define.KICKGAMEPLAY:
                    {
                        GameBase.Network.Internal.KickGamePlay kickplay = new GameBase.Network.Internal.KickGamePlay();
                        kickplay.Create(buff);
                        PlayerObject play = UserEngine.Instance().FindPlayerObjectToAccountId(kickplay.accountid);
                        if (play != null)
                        {
                            SessionManager.Instance().RemoveSession(play.GetGameSession().m_Socket);
                            play.Kick();
                        }
                        break;
                    }
                case GameBase.Network.Internal.Define.LOADROLEDATA_EUDEMON:
                    {
                        GameBase.Network.Internal.ROLEDATE_EUDEMON eudemon = new GameBase.Network.Internal.ROLEDATE_EUDEMON();
                        eudemon.Create(buff);

                        TempPlayObject play = UserEngine.Instance().GetTempPlayObj(eudemon.key, eudemon.key2);
                        if (play == null)
                        {
                            //只是为了下断点后延迟问题解决方案
                            PlayerObject _play = UserEngine.Instance().FindPlayerObjectToPlayerId(eudemon.playerid);
                            if (_play == null)
                            {
                                Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:6");
                            }
                            else
                            {
                                _play.GetEudemonSystem().DB_Load(eudemon);
                                _play.GetEudemonSystem().SendAllEudemonInfo();
                            }

                            break;
                        }
                        else
                        {
                            play.play.GetEudemonSystem().DB_Load(eudemon);
                        }

                        break;
                    }
                case GameBase.Network.Internal.Define.LOADROLEDATA_FRIEND:
                    {
                        GameBase.Network.Internal.ROLEDATA_FRIEND friend = new GameBase.Network.Internal.ROLEDATA_FRIEND();
                        friend.Create(buff);
                        TempPlayObject play = UserEngine.Instance().GetTempPlayObj(friend.key, friend.key2);
                        if (play == null)
                        {
                            //只是为了下断点后延迟问题解决方案
                            PlayerObject _play = UserEngine.Instance().FindPlayerObjectToPlayerId(friend.playerid);
                            if (_play == null)
                            {
                                Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:7");
                            }
                            else
                            {

                                _play.GetFriendSystem().DB_Load(friend);
                                _play.GetFriendSystem().SendAllFriendInfo();
                            }

                            break;
                        }
                        else
                        {
                            play.play.GetFriendSystem().DB_Load(friend);
                        }

                        break;
                    }
                case GameBase.Network.Internal.Define.GUANJUEDATA: //爵位数据
                    {
                        GameBase.Network.Internal.GUANJUEINFO juewei = new GameBase.Network.Internal.GUANJUEINFO();
                        juewei.Create(buff);
                        GuanJueManager.Instance().DB_Load(juewei);
                        break;
                    }
                case GameBase.Network.Internal.Define.LOADLEGION: //军团数据
                    {
                        GameBase.Network.Internal.LEGIONINFO info = new GameBase.Network.Internal.LEGIONINFO();
                        info.Create(buff);
                        LegionManager.Instance().DB_Load(info);
                        break;
                    }
                case GameBase.Network.Internal.Define.CREATELEGION_RET://创建军团返回数据
                    {
                        GameBase.Network.Internal.CreateLegion_Ret info = new GameBase.Network.Internal.CreateLegion_Ret();
                        info.Create(buff);
                        LegionManager.Instance().CreateLegion_Ret(info);
                        break;
                    }
                case GameBase.Network.Internal.Define.LOADPAYRECINFO: //充值数据
                    {
                        GameBase.Network.Internal.PackPayRecInfo info = new GameBase.Network.Internal.PackPayRecInfo();
                        info.Creaet(buff);
                        PayManager.Instance().DB_Load(info);
                        break;
                    }
            }
        }
Example #6
0
        public void ProcessNetMsg()
        {
            foreach (GameSession session in m_DicSession.Values)
            {
                if (session == null || session.m_GamePack == null)
                {
                    continue;
                }
                byte[] retdata = session.m_GamePack.GetData();
                if (retdata != null)
                {
                    GameBase.Network.PackIn packin = new GameBase.Network.PackIn(retdata);
                    PlayerObject            play   = UserEngine.Instance().FindPlayerObjectToID(session.gameid);
                    ushort tag = packin.ReadUInt16();
                    if (play != null)
                    {
                        play.ProcessNetMsg(tag, retdata);
                        continue;
                    }
                    //第一次的封包一定是更新key哒..
                    if (play == null && tag != PacketProtoco.C_UPDATEKEY && tag != PacketProtoco.C_QUERYCREATEROLENAME &&
                        tag != PacketProtoco.C_CREATEROLE)
                    {
                        continue;
                    }

                    switch (tag)
                    {
                    case PacketProtoco.C_UPDATEKEY:
                    {
                        int            key      = packin.ReadInt32();
                        int            key2     = packin.ReadInt32();
                        TempPlayObject tempplay = UserEngine.Instance().GetTempPlayObj(key, key2);
                        if (tempplay == null)
                        {
                            return;                               //没有经过loginsserver进入的非法封包
                        }
                        tempplay.play.SetGameSession(session);
                        session.GetGamePackKeyEx().SunUpdateKey(key, key2);
                        NetMsg.MsgNotice msgNotice;
                        //没有角色就创建角色
                        if (!tempplay.isRole)
                        {
                            msgNotice = new NetMsg.MsgNotice();
                            msgNotice.Create(null, session.GetGamePackKeyEx());
                            session.SendData(msgNotice.GetCreateRoleBuff());
                            return;
                        }
                        //有角色就进游戏
                        UserEngine.Instance().RemoveTempPlayObject(tempplay.play.GetGameID());
                        tempplay.play.EnterGame(session);
                        break;
                    }

                    case PacketProtoco.C_QUERYCREATEROLENAME:           //创建角色名查询
                    {
                        NetMsg.MsgQueryCreateRoleName info = new NetMsg.MsgQueryCreateRoleName();
                        info.Create(retdata, null);
                        int key = 0, key2 = 0;
                        session.GetGamePackKeyEx().GetKey(ref key, ref key2);
                        TempPlayObject temp = UserEngine.Instance().GetTempPlayObj(key, key2);
                        if (temp == null)
                        {
                            Log.Instance().WriteLog("找到玩家对象-在ProcessNetMsg code:1");
                            break;
                        }

                        //发给dbserver 查询
                        GameBase.Network.Internal.QueryRoleName query = new GameBase.Network.Internal.QueryRoleName();
                        query.gameid = temp.play.GetGameID();
                        query.name   = info.GetName();

                        DBServer.Instance().GetDBClient().SendData(query.GetBuffer());

                        //NetMsg.MsgNotice notice = new NetMsg.MsgNotice();
                        //notice.Create(null, session.GetGamePackKeyEx());
                        //session.SendData(notice.GetQueryNameBuff());
                        break;
                    }

                    case PacketProtoco.C_CREATEROLE:            //创建角色
                    {
                        int key = 0, key2 = 0;
                        session.GetGamePackKeyEx().GetKey(ref key, ref key2);
                        TempPlayObject temp = UserEngine.Instance().GetTempPlayObj(key, key2);
                        if (temp == null)
                        {
                            Log.Instance().WriteLog("找到玩家对象-在ProcessNetMsg code:2");
                            break;
                        }
                        NetMsg.MsgCreateRoleInfo info = new NetMsg.MsgCreateRoleInfo();
                        info.Create(retdata, null);
                        if (info.GetName().Length <= 0)
                        {
                            Log.Instance().WriteLog("角色名称为空!!");
                            break;
                        }
                        PlayerObject _play = temp.play;
                        _play.SetGameSession(session);

                        _play.SetName(info.GetName());
                        _play.GetBaseAttr().profession = (byte)info.profession;
                        _play.GetBaseAttr().lookface   = info.lookface;


                        //发给dbserver
                        GameBase.Network.Internal.CreateRole create = new GameBase.Network.Internal.CreateRole();
                        create.accountid  = temp.accountid;
                        create.lookface   = info.lookface;
                        create.name       = info.GetName();
                        create.profession = (byte)info.profession;
                        create.gameid     = temp.play.GetGameID();
                        DBServer.Instance().GetDBClient().SendData(create.GetBuffer());
                        //测试游戏
                        //play = new PlayerObject();
                        //play.mapid = 1000;
                        //play.mPoint.x = 400;
                        //play.mPoint.y = 440;
                        //session.gameid = play.GetGameID();
                        //MapManager.Instance().GetGameMapToID(play.mapid).AddObject(play, session);
                        //UserEngine.Instance().AddPlayerObject(play);

                        ////公告信息
                        //NetMsg.MsgNotice msgNotice = new NetMsg.MsgNotice();
                        //msgNotice.Create(null, session.GetGamePackKeyEx());
                        //session.SendData(msgNotice.GetStartGameBuff());
                        //byte[] roledata = {238, 3, 64, 66, 15, 0, 241, 73, 2, 0, 101,
                        //      0, 0, 0, 60, 1, 0, 0, 0, 0, 0, 0, 81, 118,
                        //      203, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                        //      31, 1, 0, 0, 73, 0, 0, 0, 30, 0, 100, 0, 99,
                        //      0, 102, 0, 0, 0, 202, 3, 222, 3, 134, 7, 0, 0,
                        //      0, 0, 0, 0, 0, 0, 0, 0, 255, 10, 0, 0, 1, 0, 0,
                        //      0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 12, 0, 0,
                        //      0, 0, 0, 0, 0, 0, 0, 20, 0, 4, 0, 0, 0, 0, 0, 0, 0,
                        //      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                        //      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                        //      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                        //      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                        //      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 105,
                        //      0, 0, 0, 92, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                        //      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                        //      0, 0, 0, 0, 2, 8, 102, 101, 111, 119, 102, 113, 101, 119, 2,
                        //      206, 222, 0, 0, 0 };
                        ////session.GetGamePackKeyEx().EncodePacket(ref roledata, roledata.Length);
                        ////session.SendData(roledata);
                        ////
                        //NetMsg.MsgSelfRoleInfo rolemsg = new NetMsg.MsgSelfRoleInfo();
                        //rolemsg.Create(roledata, session.GetGamePackKeyEx());
                        //rolemsg.roletype = 140001;
                        //rolemsg.roleid = play.GetTypeId();
                        //rolemsg.name = "测试角色" + play.GetTypeId().ToString();
                        //play.Name = rolemsg.name;
                        //session.SendData(rolemsg.GetBuffer());


                        ////测试增加装备 测试装备
                        //NetMsg.MsgItemInfo item = new NetMsg.MsgItemInfo();
                        //item.Create(null, session.GetGamePackKeyEx());
                        //item.postion = NetMsg.MsgItemInfo.ITEMPOSITION_ARMOR;
                        //item.id = 112434;
                        //item.item_id = 135114;
                        //item.amount = item.amount_limit = 1;
                        //session.SendData(item.GetBuffer());
                        ////测试武器
                        //item = new NetMsg.MsgItemInfo();
                        //item.Create(null, session.GetGamePackKeyEx());
                        //item.postion = NetMsg.MsgItemInfo.ITEMPOSITION_WEAPONR;
                        //item.id = 112435;
                        //item.item_id = 440244;
                        //item.amount = item.amount_limit = 1;
                        //session.SendData(item.GetBuffer());



                        //NetMsg.MsgUpdateSP sp = new NetMsg.MsgUpdateSP();
                        //sp.Create(null, session.GetGamePackKeyEx());
                        //sp.role_id = play.GetTypeId();
                        //sp.value = 37;
                        //sp.sp = 100;
                        //session.SendData(sp.GetBuffer());

                        //sp = new NetMsg.MsgUpdateSP();
                        //sp.Create(null, session.GetGamePackKeyEx());
                        //sp.role_id = play.GetTypeId();
                        //session.SendData(sp.GetBuffer());


                        ////测试新增技能
                        //ushort[] skill = { 3011 };//, 3002, 1010, 3005, 3009, 8003
                        //for (int i = 0; i < skill.Length; i++)
                        //{
                        //    NetMsg.MsgMagicInfo magicinfo = new NetMsg.MsgMagicInfo();
                        //    magicinfo.Create(null, session.GetGamePackKeyEx());
                        //    magicinfo.id = play.GetTypeId();
                        //    magicinfo.magicid = skill[i];
                        //    magicinfo.level = 2;
                        //    session.SendData(magicinfo.GetBuffer());
                        //}



                        ////进入地图
                        //NetMsg.MsgMapInfo mapinfo = new NetMsg.MsgMapInfo();
                        //mapinfo.Create(null, session.GetGamePackKeyEx());
                        //mapinfo.Init(play.mapid, play.mPoint.x, play.mPoint.y);
                        //session.SendData(mapinfo.GetBuffer());



                        ////刷新可视列表;

                        //play.RefreshVisibleObject();
                        //GameStruct.Action act = new GameStruct.Action(GameStruct.Action.MOVE);
                        //play.PushAction(act);
                        break;
                    }
                    }
                }
            }
        }
Example #7
0
        //private void AutoAttack()
        //{
        //    return;
        //    //if (GetTargetObj() == null) return;
        //    //if (GetTargetObj().IsDie())
        //    //{
        //    //    SetTargetObj(null);
        //    //    return;
        //    //}
        //    //if (System.Environment.TickCount - lastattacktime > attack_speed)
        //    //{
        //    //    uint injured = 10;
        //    //    //targetObject.Injured(this, injured,2);
        //    //    lastattacktime = System.Environment.TickCount;
        //    //}
        //}
        //进入游戏 参数1: 是否是创建角色第一次进入游戏
        public void EnterGame(GameBase.Network.GameSession _session, bool isFirst = false)
        {
            if (_session != null)
            {
                this.SetGameSession(_session);
            }
            if (this.GetGameSession() == null)
            {
                Log.Instance().WriteLog("玩家进入游戏EnterGame,会话对象为空!!");
                return;
            }
            this.CalcAttribute();//计算属性-
            this.GetGameSession().gameid = this.GetGameID();
            //加入到全局用户列表
            UserEngine.Instance().AddPlayerObject(this);
            PlayerObject pay = this;
            //公告信息
            NetMsg.MsgNotice msgNotice = new NetMsg.MsgNotice();
            msgNotice.Create(null, GetGamePackKeyEx());
            ////玩家个人信息

            // byte[] selfdata = {  238, 3, 64, 66, 15, 0, 17, 152, 2, 0, 101, 0, 0, 0, 125, 61, 2, 0, 0, 0, 0, 0, 133, 133, 207, 231, 1, 0, 0, 0, 14, 166, 0, 0, 0, 0, 0, 0, 231, 29, 0, 0, 180, 1, 0, 0, 31, 0, 100, 0, 74, 2, 0, 0, 0, 0, 46, 25, 46, 25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 112, 20, 0, 1, 1, 5, 0, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 21, 10, 0, 0, 84, 154, 126, 156, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 87, 25, 0, 0, 0, 0, 0, 0, 54, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 4, 0, 0, 91, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 6, 97, 118, 49, 51, 49, 52, 2, 206, 222, 0, 0, 0 };
            // this.GetGamePackKeyEx().EncodePacket(ref selfdata, selfdata.Length);
            // this.SendData(selfdata);
            //
            NetMsg.MsgSelfRoleInfo rolemsg = new NetMsg.MsgSelfRoleInfo();
            //rolemsg.Create(selfdata, this.GetGamePackKeyEx());
            rolemsg.Create(null, this.GetGamePackKeyEx());
            rolemsg.roleid = this.GetTypeId();
            rolemsg.lookface = this.GetBaseAttr().lookface;

            rolemsg.profession = this.GetBaseAttr().profession;
            rolemsg.name = this.GetName();
            //一登录进满血
            this.GetBaseAttr().life = this.GetBaseAttr().life_max;
            rolemsg.life = (ushort)this.GetBaseAttr().life;
            rolemsg.maxlife = (ushort)this.GetBaseAttr().life_max;
            rolemsg.manna = (ushort)this.GetBaseAttr().mana_max;
            rolemsg.maxpetcall = this.GetBaseAttr().maxeudemon;
            //一登录进满蓝

            rolemsg.level = this.GetBaseAttr().level;
            rolemsg.gold = (uint)this.GetBaseAttr().gold;
            rolemsg.godlevel = this.GetBaseAttr().godlevel;
            rolemsg.gamegold = (uint)this.GetBaseAttr().gamegold;
               // rolemsg.maxpetcall = (ushort)GameBase.Config.Define.MAX_CALL_EUDEMON;//最大召唤宠物数量
            rolemsg.hair = (uint)this.GetBaseAttr().hair;
            //第一次进入游戏
            if (isFirst)
            {
                this.SendData(msgNotice.GetStartGameBuff());
                //个人信息
                //偷懒,一参加角色神等级20级 2016.1.21 封包协议号没分析全的结果
                //2016.2.1 神力等级归0
                rolemsg.godlevel = 0;
                session.SendData(rolemsg.GetBuffer());

                SendRoleOtherSystemInfo();
                ScripteManager.Instance().ExecuteAction(GameBase.Config.Define.FIRSTSCRIPTID, this);

                return;
            }

            GameMap map = MapManager.Instance().GetGameMapToID(this.GetBaseAttr().mapid);
            if (map == null)
            {
                Log.Instance().WriteLog("非法玩家,非法坐标.." + this.GetName() + " 地图id:" + this.GetBaseAttr().mapid.ToString()
                    +"已修正到回卡诺萨城");
                //重新回到卡诺萨城
                this.GetBaseAttr().mapid = 1000;
                this.SetPoint(145, 413);
                map = MapManager.Instance().GetGameMapToID(this.GetBaseAttr().mapid);
               // return;
            }

            MapManager.Instance().GetGameMapToID(this.GetBaseAttr().mapid).AddObject(this, GetGameSession());
            //发送爵位公告
            this.SendJueweiNotice();
            ////加入到正式列表
            //公告信息
            session.SendData(msgNotice.GetStartGameBuff());
            // session.GetGamePackKeyEx().EncodePacket(ref data, data.Length);
            session.SendData(rolemsg.GetBuffer());
            //session.SendData(data);
            SendRoleOtherSystemInfo();

            //测试增加装备 测试装备
            //NetMsg.MsgItemInfo item = new NetMsg.MsgItemInfo();
            //item.Create(null, session.GetGamePackKeyEx());
            //item.postion = NetMsg.MsgItemInfo.ITEMPOSITION_ARMOR;
            //item.id = 112434;
            //item.item_id = 135114;
            //item.amount = item.amount_limit = 1;
            //session.SendData(item.GetBuffer());
            //测试武器
            //item = new NetMsg.MsgItemInfo();
            //item.Create(null, session.GetGamePackKeyEx());
            //item.postion = NetMsg.MsgItemInfo.ITEMPOSITION_WEAPONR;
            //item.id = 112435;
            //item.item_id = 440244;
            //item.amount = item.amount_limit = 1;
            //session.SendData(item.GetBuffer());

            //item = new NetMsg.MsgItemInfo();
            //item.Create(null, session.GetGamePackKeyEx());
            //item.postion = NetMsg.MsgItemInfo.ITEMPOSITION_BACKPACK;
            //item.id = 112436;
            //item.item_id = 440244;
            //item.amount = item.amount_limit = 1;
            //session.SendData(item.GetBuffer());

            //NetMsg.MsgUpdateSP sp = new NetMsg.MsgUpdateSP();
            //sp.Create(null, session.GetGamePackKeyEx());
            //sp.role_id = this.GetTypeId();
            //sp.value = 37;
            //sp.sp = 100;
            //session.SendData(sp.GetBuffer());

            //sp = new NetMsg.MsgUpdateSP();
            //sp.Create(null, session.GetGamePackKeyEx());
            //sp.role_id = this.GetTypeId();
            //session.SendData(sp.GetBuffer());

            //进入地图
            NetMsg.MsgMapInfo mapinfo = new NetMsg.MsgMapInfo();
            mapinfo.Create(null, session.GetGamePackKeyEx());
            mapinfo.Init(this.GetBaseAttr().mapid, this.GetCurrentX(), this.GetCurrentY(), NetMsg.MsgMapInfo.ENTERMAP);
            session.SendData(mapinfo.GetBuffer());

            //初始化一些信息
            this.ChangeAttribute(UserAttribute.LOOKFACE, GetLookFace());
            //刷新可视列表;
            GameStruct.Action act = new GameStruct.Action(GameStruct.Action.MOVE);
            this.PushAction(act);

            ScriptTimerManager.Instance().PlayerEnterGame(this.GetBaseAttr().player_id);
            //发送天气信息
            this.GetGameMap().SendWeatherInfo(this);

            //
             //   this.MsgBox("QQ群号:306929937");
        }
Example #8
0
 //聊天框公告
 public void ChatNotice(String text)
 {
     NetMsg.MsgNotice notice = new NetMsg.MsgNotice();
     notice.Create(null, GetGamePackKeyEx());
     byte[] buff = notice.GetChatNoticeBuff(text);
     this.SendData(buff);
 }