Пример #1
0
        //发送玩家数据信息到dbserver 保存到数据库
        //play 玩家对象
        //isExit 是否是退出游戏 -
        public void SaveRoleData(PlayerObject play, bool isExit = false)
        {
            if (!this.IsConnect())
            {
                UserEngine.Instance().AddCachePlay(play);
                Log.Instance().WriteLog("保存玩家数据失败,dbserver未连接,已加入到数据库缓冲存储区");
                return;
            }
            //人物基本属性
            SaveRoleData_Attr data = new SaveRoleData_Attr();

            GameStruct.PlayerAttribute attr = play.GetBaseAttr();

            data.accountid  = attr.account_id;
            data.IsExit     = isExit;
            data.name       = play.GetName();
            data.lookface   = attr.lookface;
            data.hair       = attr.hair;
            data.level      = (byte)attr.level;
            data.exp        = attr.exp;
            data.life       = attr.life;
            data.mana       = attr.mana;
            data.profession = attr.profession;
            data.pk         = attr.pk;
            data.gold       = attr.gold;
            data.gamegold   = attr.gamegold;
            data.stronggold = attr.stronggold;
            data.godlevel   = attr.godlevel;
            data.maxeudemon = attr.maxeudemon;
            if (play.GetGameMap() == null)
            {
                data.mapid = 1000;
                data.x     = 145;
                data.y     = 413;
            }
            else
            {
                data.mapid = play.GetGameMap().GetMapInfo().id;
                data.x     = play.GetCurrentX();
                data.y     = play.GetCurrentY();
            }

            data.hotkey  = play.GetHotKeyInfo();
            data.guanjue = attr.guanjue;
            GetDBClient().SendData(data.GetBuffer());
            //保存道具信息
            play.GetItemSystem().DB_Save();
            //保存技能信息
            play.GetMagicSystem().DB_Save();
            //保存幻兽信息
            play.GetEudemonSystem().DB_Save();
            //好友信息
            play.GetFriendSystem().DB_Save();
        }
Пример #2
0
        public void AddTempPlayObject(GameBase.Network.Internal.RoleInfo info)
        {
            TempPlayObject temp = new TempPlayObject();
            PlayerObject   play = new PlayerObject();

            temp.play      = play;
            temp.key       = info.mKey;
            temp.key2      = info.mKey1;
            temp.isRole    = info.isRole;
            temp.accountid = info.accountid;
            //基本属性
            m_DicTempPlayObject[play.GetGameID()] = temp;

            if (temp.isRole)
            {
                play.SetName(info.name);
                GameStruct.PlayerAttribute attr = play.GetBaseAttr();
                attr.account_id = info.accountid;
                attr.player_id  = info.playerid;
                attr.mana       = info.mana;
                attr.lookface   = info.lookface;
                attr.hair       = info.hair;
                attr.profession = info.profession;
                attr.level      = info.lv;
                attr.exp        = (int)info.exp;
                attr.life       = info.life;
                attr.pk         = info.pk;
                attr.gold       = info.gold;
                attr.gamegold   = info.gamegold;
                attr.stronggold = info.stronggold;
                attr.mapid      = (uint)info.mapid;
                attr.guanjue    = info.guanjue;
                attr.sAccount   = info.sAccount;
                attr.godlevel   = (byte)info.godlevel;
                attr.maxeudemon = info.maxeudemon;
                play.SetHotKeyInfo(info.hotkey);
                play.CalcSex();
                play.SetPoint(info.x, info.y);

                //官爵信息
                GameStruct.GUANGJUELEVEL gjlevel = GuanJueManager.Instance().GetLevel(play);
                play.SetGuanJue(gjlevel);
                //初始化军团信息
                play.GetLegionSystem().Init();
            }
        }