private void Init(long unit_idx) { PlayerInfoForClient info = PlayerDataMgr.Instance.main_player_info; Unit unit = UnitManager.Instance.GetUnitByIdx(unit_idx); if (unit != null) { if (unit is Player) { Player player = unit as Player; this.m_txt_name.Text = player.char_name; this.m_com_sex.SelectedIndex = player.char_type == (byte)eSexType.BOY ? 0 : 1; this.m_txt_lv.Text = player.level.ToString(); } } }
/// <summary> /// 场景切换 /// </summary> private void OnEnterScene(PacketBase packet) { ss2c.EnterScene msg = packet as ss2c.EnterScene; UnitManager.Instance.RemoveAll(); //玩家信息 PlayerInfoForClient char_info = PlayerDataMgr.Instance.main_player_info; PlayerAOIInfo player_info = CommonObjectPools.Spawn <PlayerAOIInfo>(); player_info.char_name = char_info.char_name; player_info.char_type = char_info.char_type; player_info.pos_x = msg.pos.x; player_info.pos_y = msg.pos.y; player_info.flags = char_info.flags; player_info.model_idx = char_info.model_idx; player_info.job = char_info.job; player_info.level = char_info.level; player_info.exp = char_info.exp; player_info.energy = char_info.energy; player_info.gold = char_info.gold; player_info.coin = char_info.coin; player_info.hp = char_info.hp; player_info.hp_max = char_info.hp_max; player_info.hurt = char_info.hurt; player_info.range = char_info.range; player_info.run_speed = char_info.run_speed; player_info.vip_grade = char_info.vip_grade; player_info.vip_flags = char_info.vip_flags; //创建玩家对象 Player player = new Player(); player.obj_idx = char_info.char_idx; player.Setup(); player.LoadData(player_info); UnitManager.Instance.AddUnit(player); EventController.TriggerEvent(ClientEventID.SHOW_STATUS, eFormStatusType.Scene, "当前场景:" + msg.scene_type); EventController.TriggerEvent(ClientEventID.SHOW_STATUS, eFormStatusType.Log, "进入场景:" + msg.scene_type); }
/// <summary> /// 角色基础信息 /// </summary> /// <param name="packet"></param> private void OnCharacterInfo(PacketBase packet) { ss2c.CharacterInfo msg = packet as ss2c.CharacterInfo; m_unit_info = msg.data; }