예제 #1
0
 public void Copy(PlayerInfoForSS info)
 {
     char_idx         = info.char_idx;
     account_index    = info.account_index;
     spid             = info.spid;
     char_name        = info.char_name;
     char_type        = info.char_type;
     ws_id            = info.ws_id;
     ss_id            = info.ss_id;
     fs_id            = info.fs_id;
     pos_x            = info.pos_x;
     pos_y            = info.pos_y;
     scene_type_idx   = info.scene_type_idx;
     scene_obj_idx    = info.scene_obj_idx;
     flags            = info.flags;
     model_idx        = info.model_idx;
     job              = info.job;
     level            = info.level;
     exp              = info.exp;
     energy           = info.energy;
     gold             = info.gold;
     coin             = info.coin;
     hp               = info.hp;
     hp_max           = info.hp_max;
     hurt             = info.hurt;
     range            = info.range;
     run_speed        = info.run_speed;
     vip_grade        = info.vip_grade;
     vip_flags        = info.vip_flags;
     time_last_login  = info.time_last_login;
     time_last_logout = info.time_last_logout;
 }
예제 #2
0
        /// <summary>
        /// 保存数据
        /// </summary>
        /// <param name="info"></param>
        public static void SaveCharacterInfo(PlayerInfoForSS info)
        {
            string sql = ("update `character` set " +
                          "`char_name` = '" + info.char_name + "'," + // 名字
                          "`char_type` = '" + info.char_type + "'," + // 角色类型(男 or 女 )
                          "`w_id` = '" + info.w_id + "'," +           //
                          "`s_id` = '" + info.s_id + "'," +           //
                          "`db_id` = '" + info.db_id + "'," +         //
                          "`pos_x` = '" + info.pos_x + "'," +         //
                          "`pos_y` = '" + info.pos_y + "'," +         //
                          "`scene_type_idx` = '" + info.scene_type_idx + "'," +
                          "`scene_obj_idx` = '" + info.scene_obj_idx + "'," +
                          "`flags` = '" + info.flags + "'," +         // 特殊标记
                          "`model_idx` = '" + info.model_idx + "'," + // 模型ID
                          "`job` = '" + info.job + "'," +             // 职业
                          "`level` = '" + info.level + "'," +         // 角色等级
                          "`exp` = '" + info.exp + "'," +             // 当前经验
                          "`energy` = '" + info.energy + "'," +       // 能量
                          "`gold` = '" + info.gold + "'," +           // 金币(点卷)
                          "`coin` = '" + info.coin + "'," +           // 游戏币(铜币)
                          "`hp` = '" + info.hp + "'," +               // 生命
                          "`hp_max` = '" + info.hp_max + "'," +       // 生命上限
                          "`hurt` = '" + info.hurt + "'," +           // 伤害
                          "`range` = '" + info.range + "'," +         // 攻击范围
                          "`run_speed` = '" + info.run_speed + "'," + // vip等级
                          "`vip_grade` = '" + info.vip_grade + "'," +
                          "`vip_flags` = '" + info.vip_flags + "'," + // vip flags
                          "`time_last_login` = '" + info.time_last_login + "'," +
                          "`time_last_logout` = '" + info.time_last_logout + "'," +
                          "`last_update_time` = now() where `character`.char_index=" + info.char_idx
                          );

            DBManager.Instance.GetDB(eDBType.Game).Execute(sql);
        }
예제 #3
0
        /// <summary>
        /// 进入游戏
        /// </summary>
        private void OnEnterGame(PacketBase packet)
        {
            gs2ss.EnterGame msg        = packet as gs2ss.EnterGame;
            ClientUID       client_uid = msg.client_uid;
            InterServerID   server_uid = msg.server_uid;

            UnitManager.Instance.AddSession(client_uid);

            if (!UnitManager.Instance.HasUnit(msg.char_idx))
            {
                DBID db_id = new DBID();
                db_id.game_id = ServerConfig.GetDBByAccountIdx(msg.account_idx, eDBType.Game);
                PlayerInfoForSS ss_data = CommonObjectPools.Spawn <PlayerInfoForSS>();
                SQLCharHandle.QueryCharacterInfo(msg.char_idx, db_id, ss_data, is_load =>
                {
                    if (is_load && UnitManager.Instance.HadSession(client_uid))
                    {//读取玩数据,有可能已经退出
                        //创建玩家
                        Player player     = new Player();
                        player.client_uid = client_uid;
                        player.LoadData(ss_data);
                        UnitManager.Instance.AddUnit(player);

                        //告诉gs成功进入游戏
                        ss2gs.EnterGame rep_gs_msg = PacketPools.Get(ss2gs.msg.ENTER_GAME) as ss2gs.EnterGame;
                        rep_gs_msg.server_uid      = server_uid;
                        rep_gs_msg.client_uid      = client_uid;
                        rep_gs_msg.char_idx        = ss_data.char_idx;
                        ServerNetManager.Instance.Send(server_uid.gs_uid, rep_gs_msg);

                        //告诉ws
                        ss2ws.LoginClient rep_ws_msg = PacketPools.Get(ss2ws.msg.LOGIN_CLIENT) as ss2ws.LoginClient;
                        rep_ws_msg.server_uid        = server_uid;
                        rep_ws_msg.client_uid        = client_uid;
                        rep_ws_msg.data.Copy(ss_data);
                        ServerNetManager.Instance.Send2WS(rep_ws_msg);

                        //告诉gl
                        ss2gl.LoginClient rep_gl_msg = PacketPools.Get(ss2gl.msg.LOGIN_CLIENT) as ss2gl.LoginClient;
                        rep_gl_msg.server_uid        = server_uid;
                        rep_gl_msg.data.Copy(ss_data);
                        ServerNetManager.Instance.Send2GL(rep_gl_msg);

                        //告诉客户端角色基础信息
                        ss2c.CharacterInfo rep_msg = PacketPools.Get(ss2c.msg.CHARACTER_INFO) as ss2c.CharacterInfo;
                        rep_msg.data.Copy(ss_data);
                        ServerNetManager.Instance.SendProxy(client_uid, rep_msg, false);

                        //初始化内部逻辑
                        player.OnFirstEnter();
                    }
                    CommonObjectPools.Despawn(ss_data);
                });
            }
        }
예제 #4
0
        /// <summary>
        /// 查询角色信息
        /// </summary>
        /// <param name="info"></param>
        /// <param name="callback"></param>
        public static void QueryCharacterInfo(long char_idx, PlayerInfoForSS data, Action <bool> callback)
        {
            bool   ret = false;
            string sql = "call SP_CHARACTER_BASE(" + char_idx + ")";

            DBManager.Instance.GetDB(eDBType.Game).Query(sql, (reader) =>
            {
                if (reader.HasRows && reader.Read())
                {
                    int idx               = 0;
                    data.char_idx         = reader.GetInt64(idx++);
                    data.account_index    = reader.GetInt64(idx++);
                    data.spid             = reader.GetUInt16(idx++);
                    data.char_name        = reader.GetString(idx++);
                    data.char_type        = reader.GetByte(idx++);
                    data.w_id             = reader.GetUInt16(idx++);
                    data.s_id             = reader.GetUInt16(idx++);
                    data.db_id            = reader.GetUInt16(idx++);
                    data.pos_x            = reader.GetInt32(idx++);
                    data.pos_y            = reader.GetInt32(idx++);
                    data.pos_x            = MathUtils.RandRange(-40, 40);
                    data.pos_y            = MathUtils.RandRange(-40, 40);
                    data.scene_type_idx   = reader.GetUInt32(idx++);
                    data.scene_obj_idx    = reader.GetInt64(idx++);
                    data.flags            = reader.GetUInt32(idx++);
                    data.model_idx        = reader.GetUInt32(idx++);
                    data.job              = reader.GetByte(idx++);
                    data.level            = reader.GetUInt16(idx++);
                    data.exp              = reader.GetUInt32(idx++);
                    data.energy           = reader.GetUInt32(idx++);
                    data.gold             = reader.GetUInt32(idx++);
                    data.coin             = reader.GetUInt32(idx++);
                    data.hp               = reader.GetUInt32(idx++);
                    data.hp_max           = reader.GetUInt32(idx++);
                    data.hurt             = reader.GetUInt32(idx++);
                    data.range            = reader.GetUInt32(idx++);
                    data.run_speed        = reader.GetUInt32(idx++);
                    data.vip_grade        = reader.GetUInt32(idx++);
                    data.vip_flags        = reader.GetUInt32(idx++);
                    data.time_last_login  = reader.GetInt64(idx++);
                    data.time_last_logout = reader.GetInt64(idx++);
                    ret = true;
                }
                else
                {
                    Log.Warning("查询角色失败:" + char_idx);
                }
                callback(ret);
            });
        }
예제 #5
0
 /// <summary>
 /// 从PlayerInfoForSS复制数据
 /// </summary>
 public void Copy(PlayerInfoForSS info)
 {
     char_idx  = info.char_idx;
     spid      = info.spid;
     char_name = info.char_name;
     char_type = info.char_type;
     ws_id     = info.ws_id;
     flags     = info.flags;
     model_idx = info.model_idx;
     job       = info.job;
     level     = info.level;
     exp       = info.exp;
     gold      = info.gold;
     coin      = info.coin;
     vip_grade = info.vip_grade;
 }
예제 #6
0
        /// <summary>
        /// 加载数据
        /// </summary>
        public override void LoadData(object info)
        {
            base.LoadData(info);

            PlayerInfoForSS data = (PlayerInfoForSS)info;

            m_account_idx = data.account_index;
            m_spid        = data.spid;
            m_obj_type    = 0;
            m_obj_idx     = data.char_idx;
            m_pos.Set(data.pos_x, data.pos_y);
            m_scene_obj_idx  = data.scene_obj_idx;
            m_scene_type_idx = data.scene_type_idx;

            m_db_id.game_id   = ServerConfig.GetDBByAccountIdx(m_account_idx, eDBType.Game);
            m_db_id.center_id = ServerConfig.GetDBByAccountIdx(m_account_idx, eDBType.Center);
            m_db_id.log_id    = ServerConfig.GetDBByAccountIdx(m_account_idx, eDBType.Log);

            player_attr.player_info.Copy(data);
            m_unit_attr.SetAttribInteger(eUnitModType.UMT_time_last_login, Time.second_time, false, false, false, false, false);
        }
예제 #7
0
        public uint   vip_flags;    // vip flags

        public void Copy(PlayerInfoForSS info)
        {
            char_idx  = info.char_idx;
            char_name = info.char_name;
            char_type = info.char_type;
            flags     = info.flags;
            model_idx = info.model_idx;
            job       = info.job;
            level     = info.level;
            exp       = info.exp;
            energy    = info.energy;
            gold      = info.gold;
            coin      = info.coin;
            hp        = info.hp;
            hp_max    = info.hp_max;
            hurt      = info.hurt;
            range     = info.range;
            run_speed = info.run_speed;
            vip_grade = info.vip_grade;
            vip_flags = info.vip_flags;
        }
예제 #8
0
 public PlayerCache()
 {
     m_ss_data = CommonObjectPools.Spawn <PlayerInfoForSS>();
 }