using System; using System.Collections.Generic; using System.Text; using Thousandto.Cfg.Data; using Thousandto.Code.Center; using Thousandto.Code.Global; using Thousandto.Code.Logic.LocalPlayerBT; using Thousandto.Core.Asset; using Thousandto.Core.PostEffect; using UnityEngine; using FLogger = UnityEngine.Gonbest.MagicCube.FLogger; namespace Thousandto.Code.Logic { /// /// 游戏场景管理系统 /// public class GameSceneSystem { #region//私有变量 private GameScene _preLoadScene = null; private GameScene _activedScene = null; private int _mapID = -1; private float _timeScaleCounter = 0f; private int _sceneEnterCount = 0; private LoadingArgs _lastRequestLoadingArgs = null; private LoadingArgs _currentRequestLoadingArgs = null; private bool _isLoading = false; private float _frontUpdateTime = 0f; private int _hideCameraCounter = 0; //摄像机隐藏计数器,大于0表示摄像机需要隐藏 private int _showCameraCounter = 0; //摄像机显示计数器,大于0表示摄像机需要显示 private bool _isFirstEnterMap = true; //是否是第一次进游戏场景 #endregion #region//场景属性 //当前激活的场景 public GameScene ActivedScene { get { return _activedScene; } } public GameScene PreLoadScene { get { return _preLoadScene; } } #endregion #region//当前被激活场景的公共接口 //初始化 public void Initialize() { _hideCameraCounter = 0; _showCameraCounter = 0; GameCenter.RegFixEventHandle(LogicEventDefine.EID_EVENT_ADD_MAINCAMERA_HIDECOUNTER, OnAddCameraHideCounter); GameCenter.RegFixEventHandle(LogicEventDefine.EID_EVENT_DEC_MAINCAMERA_HIDECOUNTER, OnDecCameraHideCounter); GameCenter.RegFixEventHandle(LogicEventDefine.EID_EVENT_ADD_MAINCAMERA_SHOWCOUNTER, OnAddCameraShowCounter); GameCenter.RegFixEventHandle(LogicEventDefine.EID_EVENT_DEC_MAINCAMERA_SHOWCOUNTER, OnDecCameraShowCounter); GameCenter.RegFixEventHandle(LogicEventDefine.EID_EVENT_TIMELINEEVENT_START, OnTimelineStart); GameCenter.RegFixEventHandle(LogicEventDefine.EID_EVENT_TIMELINEEVENT_END, OnTimelineEnd); } //反初始化 public void Uninitialize() { GameCenter.UnRegFixEventHandle(LogicEventDefine.EID_EVENT_ADD_MAINCAMERA_HIDECOUNTER, OnAddCameraHideCounter); GameCenter.UnRegFixEventHandle(LogicEventDefine.EID_EVENT_DEC_MAINCAMERA_HIDECOUNTER, OnDecCameraHideCounter); GameCenter.UnRegFixEventHandle(LogicEventDefine.EID_EVENT_ADD_MAINCAMERA_SHOWCOUNTER, OnAddCameraShowCounter); GameCenter.UnRegFixEventHandle(LogicEventDefine.EID_EVENT_DEC_MAINCAMERA_SHOWCOUNTER, OnDecCameraShowCounter); GameCenter.UnRegFixEventHandle(LogicEventDefine.EID_EVENT_TIMELINEEVENT_START, OnTimelineStart); GameCenter.UnRegFixEventHandle(LogicEventDefine.EID_EVENT_TIMELINEEVENT_END, OnTimelineEnd); } //开始播放Timeline private void OnTimelineStart(object obj, object sender) { //var localPlayer = GetLocalPlayer(); //if(localPlayer != null) //{ // localPlayer.Action_Timeline(AnimClipNameDefine.NormalIdle); //} } //Timeline结束 private void OnTimelineEnd(object obj, object sender) { var localPlayer = GetLocalPlayer(); if (localPlayer != null) { localPlayer.Action_Idle(); } } private void OnAddCameraHideCounter(object o,object sender = null) { ++_hideCameraCounter; CheckCameraVisible(); } private void OnDecCameraHideCounter(object o,object sender = null) { --_hideCameraCounter; CheckCameraVisible(); } private void OnAddCameraShowCounter(object o,object sender = null) { ++_showCameraCounter; CheckCameraVisible(); } private void OnDecCameraShowCounter(object o,object sender = null) { --_showCameraCounter; CheckCameraVisible(); } private void CheckCameraVisible() { if (_activedScene == null || _activedScene.SceneCameraControl == null) return; if (_showCameraCounter > 0) { _activedScene.SceneCameraControl.gameObject.SetActive(true); } else { if (_hideCameraCounter > 0) { _activedScene.SceneCameraControl.gameObject.SetActive(false); PostEffectManager.Instance.StopRadiaBlur(); //停止径向模糊 PostEffectManager.Instance.StopAllCameraShake();//停止摄像机震动 } else { _activedScene.SceneCameraControl.gameObject.SetActive(true); } } } public void SetPreLoadScene(GameScene scene) { _preLoadScene = scene; } public void ReSetPreLoadScene() { if (_preLoadScene != null) _preLoadScene = null; } //设置当前激活的场景 public void SetActivedScene(GameScene activedScene) { ReSetPreLoadScene(); _frontUpdateTime = Time.realtimeSinceStartup; _activedScene = activedScene; } //获取当前场景 public GameScene GetActivedScene() { return _activedScene; } //获取当前的地图的数据 public DeclareMapsetting GetActivedMapSetting() { return DeclareMapsetting.Get(_mapID); } //获取当前地图的ID public int GetActivedMapID() { return _mapID; } //获取当前角色所在那个分线上 public int GetLineID() { if (_activedScene != null) { return _activedScene.LineID; } return -1; } //检查当前场景 -- 是否有效 public bool CheckActivedScene() { return _activedScene != null; } // 进入场景次数 public int SceneEnterCount { get { return _sceneEnterCount; } set { _sceneEnterCount = value; } } #endregion #region //关于场景的切换的处理,其中包括资源的清理等 //切换地图操作 public void StartChangeToMap(int mapID, int lineID, Vector2? position = null, int transType = 0, int transParam = 0) { //Debug.LogError("mapID"+mapID); DeclareMapsetting mapInfo = DeclareMapsetting.Get(mapID); if (mapInfo != null) { var scene = GameCenter.GameSceneSystem.ActivedScene; //换线逻辑 if (scene != null && scene.MapId == mapID) { scene.DoChangeLine(mapInfo, lineID, scene.LineID != lineID); //向服务器同步玩家坐标位置 if (position != null) { var lp = GameCenter.GameSceneSystem.GetLocalPlayer(); Vector3 pos = scene.GetTerrainPosition(position.Value.x, position.Value.y); lp.SetPosition(pos); } GameCenter.TaskController.ResumeForTransPort(); //} } //进入(离开)位面逻辑 else if (scene != null && scene.MapId != mapID && (string.Equals(scene.LevelName, mapInfo.LevelName) || string.Equals(scene.LevelName, mapInfo.LevelName2))) { if(mapInfo.Type == (int)MapTypeDef.PlanCopy || scene.Cfg.Type == (int)MapTypeDef.PlanCopy) { //是否是进出位面 if(mapInfo.Type == (int)MapTypeDef.PlanCopy) { //进入位面 GameCenter.TaskManager.EnterPlaneCopy(); GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_ENTET_PLANECOPY); } else { //退出位面 GameCenter.TaskManager.LeavePlaneCopy(); GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_EXIT_PLANECOPY); } } if(position != null) { var lp = GameCenter.GameSceneSystem.GetLocalPlayer(); if(lp != null && Vector2.SqrMagnitude(position.Value - lp.Position2d) <= 1f) { //误差1米内,使用当前位置 position = lp.Position2d; } } var levelName = string.Empty; if(string.Equals(scene.LevelName, mapInfo.LevelName)) { levelName = mapInfo.LevelName; } else if(string.Equals(scene.LevelName, mapInfo.LevelName2)) { levelName = mapInfo.LevelName2; } scene.DoEnterPlaneCopy(mapID, scene.MapId, ref _mapID, scene.Name, levelName, mapInfo.CameraName, mapInfo.CameraNameNight, lineID, position); } else if (_mapID != mapID) { LoadingArgs args = new LoadingArgs(); args.MapSetting = mapInfo; args.Position = position; args.LineID = lineID; args.transType = transType; args.transParam = transParam; if (scene != null) { args.FrontMapID = scene.MapId; } else { args.FrontMapID = 0; } FLogger.Log("Request:" + args.MapSetting.LevelName); if (!_isLoading) { _isLoading = true; _currentRequestLoadingArgs = args; _lastRequestLoadingArgs = null; //GameCenter.GameCaseSystem.GetCurrentTickCase().ChangeToState(GameStateId.SceneLoading, args); GameCenter.GameStateSystem.ChangeState((int)GameStateId.SceneLoading, args); } else { //当正在切换场景时,接收到另外场景切换请求时的处理. if (_currentRequestLoadingArgs.MapSetting != args.MapSetting) { _lastRequestLoadingArgs = args; FLogger.LogError("CurrentState is Loading ,New Loading Request Save To _lastRequestLoadingArgs!" + args.MapSetting.LevelName); } } } } else { UnityEngine.Debug.LogError("切换场景失败,找不到地图,返回到登陆界面。 id = " + mapID); GameCenter.GameStateSystem.ChangeState((int)GameStateId.Login); } _mapID = mapID; } //清除MapID信息 public void ClearMapID() { _mapID = -1; } /// /// 判断在进行Loading时,是否进行了其他的Loading请求 /// 比如在切换场景时,多人副本被房主开启等. /// public bool CheckNewLoading() { _isLoading = false; if (_lastRequestLoadingArgs != null) { var arg = _lastRequestLoadingArgs; _lastRequestLoadingArgs = null; if (ActivedScene != null) {//当多次切换的时候,如果ActiveScene不为空,那么表示他的FrontMapID肯定不为空 arg.FrontMapID = ActivedScene.MapId; } FLogger.LogError("CheckNewLoading is true!Find New Loading Request,Start New Loading Process!!", arg.MapSetting.LevelName); GameCenter.GameStateSystem.ChangeState((int)GameStateId.SceneLoading, arg); return true; } return false; } //设置持续化信息 public void SetImmortalInfo(bool isSetImmortal = true) { //1.清理场景的数据 if (_activedScene != null) { if (isSetImmortal) { GameCenter.ImmortalResSystem.ClearImmortalAll(); GameCenter.ImmortalResSystem.SetImmortalResouce(); } _activedScene.Unload(); _activedScene = null; } } //清空Prefab型资源 -- 这个在加载场景之前处理 public void SceneSweepPrefab() { //清理所有不用的PrefabPool对象 --- Prefab实例对象 SpawnPoolManager.ShareInstance.TrimUnusedPools(true); //针对特效粒子进行缓存池复位 //ParticleSystem.ResetPreMappedBufferMemory(); } //清空资源型资源 --- 这个在加载场景之后处理 public void SceneSweepAsset() { //3.清除资源型对象 GameCenter.AudioManager.Sweep(); #if !UNITY_EDITOR GameCenter.AnimManager.Sweep(); #endif GameCenter.TextureManager.Sweep(); GameCenter.VideoManager.Sweep(); //清理所有Prefab资源 -- 删除资源对象 PrefabAssetManager.SharedInstance.Sweep(); GameCenter.LuaSystem.Sweep(); } public void ReturnToLogin(bool isSwitchAccount = false,bool isToSelectPlayer = false) { //这里把场景正在加载中的数据进行复位 _isLoading = false; GameCenter.ChatSystem.ForceCacheLocalLeavelMsg(); GameCenter.ItemContianerSystem.Uninitialize(); PlayerBT.ChangeState(PlayerBDState.Default); GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_CLOSEREMAINTIME_EQUIP); int i = 0; i += (isSwitchAccount ? 1 : 0); i += (isToSelectPlayer ? 2 : 0); GameCenter.GameStateSystem.ChangeState((int)GameStateId.RetToLogin, i); _isFirstEnterMap = true; } public void ReturnToUpdate() { //这里把场景正在加载中的数据进行复位 _isLoading = false; GameCenter.ItemContianerSystem.Uninitialize(); GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_CLOSEREMAINTIME_EQUIP); GameCenter.GameStateSystem.ChangeState((int)GameStateId.RetToUpdate); } #endregion #region//场景中对象实体的操作,查询获取,移除,刷新 //获取当前角色 public LocalPlayer GetLocalPlayer() { return LocalPlayerRoot.LocalPlayer; } //获取当前角色等级 public int GetLocalPlayerLevel() { if(LocalPlayerRoot.LocalPlayer != null) { return LocalPlayerRoot.LocalPlayer.Level; } return -1; } //获取角色ID public ulong GetLocalPlayerID() { return LocalPlayerRoot.LocalPlayerID; } //获取主角飞剑 public LocalFlySword GetLocalFlySword() { var lp = GetLocalPlayer(); if (lp != null && _activedScene != null) { return _activedScene.Find(lp.PropMoudle.FlySwordUID); } return null; } //获取主角宠物 public LocalPet GetLocalPet() { var petList = _activedScene.FindAll(); if (petList != null && petList.Count > 0) { return petList[0]; } return null; } //获取当前角色战斗力 public long GetLocalPlayerFightPower() { if (LocalPlayerRoot.LocalPlayer != null) { return LocalPlayerRoot.LocalPlayer.FightPower; } return 0; } //查询场景中的实体 public T FindEntity(UInt64 code) where T : Entity { if (LocalPlayerRoot.LocalPlayer != null && LocalPlayerRoot.LocalPlayer.ID == code) { return LocalPlayerRoot.LocalPlayer as T; } if (_activedScene != null) { return _activedScene.Find(code); } return null; } //查询NPC public Npc FindNpc(UInt64 code) { if (_activedScene != null) { return _activedScene.Find(code); } return null; } //查询怪物 public Monster FindMonster(UInt64 code) { if (_activedScene != null) { return _activedScene.Find(code); } return null; } //查询宠物 public Pet FindPet(UInt64 code) { if (_activedScene != null) { return _activedScene.Find(code); } return null; } //查询玩家 public Player FindPlayer(UInt64 code) { if (_activedScene != null) { return _activedScene.Find(code); } return null; } //查找采集物 public Collection FindCollect(UInt64 code) { if (_activedScene != null) { return _activedScene.Find(code); } return null; } //查找其他玩家 public List FindRemotePlayers() { if (_activedScene != null) { return _activedScene.FindAll(); } return null; } //查询一个指定玩家 public RemotePlayer FindRemotePlayer(UInt64 code) { if (_activedScene != null) { return _activedScene.Find(code); } return null; } //查找NPC列表 public List FindNpcs() { if (_activedScene != null) { return _activedScene.FindAll(); } return null; } //查找怪物列表 public List FindMonsters() { if (_activedScene != null) { return _activedScene.FindAll(); } return null; } //查找采集物列表 public List FindCollects() { if (_activedScene != null) { return _activedScene.FindAll(); } return null; } //在场景查找所有的实体列表 public List FindEntityAll() where T : Entity { if (_activedScene != null) { return _activedScene.FindAll(); } return null; } //获取某个实体的数量 public int GetEntityCount() where T : Entity { if (_activedScene != null) { return _activedScene.GetCount(); } return 0; } //获取场景实体的容器 public EntityContainer GetEntityContainer() { if (_activedScene != null) { return _activedScene.Entities; } return null; } //根据id列表从场景中,移除多个实体 public void RemoveRemoteEntities(List idList) { if (_activedScene != null && _activedScene.Entities != null && idList != null) { //删除 for (int i = 0; i < idList.Count; ++i) { var e = _activedScene.Entities.Find(idList[i]); Character c = e as Character; if (c == null || !c.IsLocalPlayer()) { _activedScene.Entities.Remove(idList[i]); } } } } //根据id从场景中,移除一个实体 public void RemoveRemoteEntity(ulong id) { if (_activedScene != null && _activedScene.Entities != null) { var e = _activedScene.Entities.Find(id); Character c = e as Character; if (c == null || !c.IsLocalPlayer()) { _activedScene.Entities.Remove(id); } } } //刷新本地玩家的战斗属性 public void RefreshLocalPlayerBattleAttribute(MSG_Player.ResPlayerOnLineAttribute result) { if (_activedScene != null) { var lp = _activedScene.GetLocalPlayer(); if (lp != null) { for (int i = 0; i < result.attributeList.Count; ++i) { var prop = result.attributeList[i]; lp.PropMoudle.SetBattleProp((AllBattleProp)prop.type, (int)prop.value, false); } lp.PropMoudle.SetBattleProp(AllBattleProp.MaxHP, (long)result.maxHp, false); } } } //刷新本地玩家的战斗属性 public void RefreshLocalPlayerBattleAttribute(List attrList) { if (_activedScene != null && attrList != null && attrList.Count > 0) { var lp = _activedScene.GetLocalPlayer(); if (lp != null) { for (int i = 0; i < attrList.Count; ++i) { var prop = attrList[i]; lp.PropMoudle.SetBattleProp((AllBattleProp)prop.type, (int)prop.value); } } } } //刷新本地玩家信息 -- 返回本地新的本地玩家 public LocalPlayer RefreshLocalPlayer(LocalPlayerInitInfo info) { if (_activedScene != null) { var lp = _activedScene.GetLocalPlayer(); if (_activedScene.LoadLocalPlayer(info)) { lp = _activedScene.GetLocalPlayer(); //GameCenter.CameraControlUtil.FollowToCharacter(lp); GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_LOCAL_PLAYER_REFRESH, lp); } if( !GameExtentScript._showPlayerModel ) { GameExtentScript.SetModelActive( lp.ModelTransform, false ); } return lp; } return null; } //刷新远程玩家信息 -- 如果没有的话,就创建一个 public void RefreshRemotePlayer(RemotePlayerInitInfo info) { if (_activedScene != null) { var entity = _activedScene.Find(info.ID); if (entity == null) { var result = _activedScene.LoadRemotePlayer(info); if( result && !GameExtentScript._showPlayerModel ) { var root = _activedScene.Find( info.ID ).ModelTransform; GameExtentScript.SetModelActive( root, false ); } } else if (!entity.IsLocalPlayer()) { entity.SyncInfo(info); } } } //刷新NPC玩家信息 -- 如果没有的话,就创建一个 public void RefreshNpc( NpcInitInfo info ) { if( _activedScene != null ) { if( info.Cfg == null ) return; var entity = _activedScene.Find( info.ID ); if( entity == null ) { var result = _activedScene.LoadNpc( info ); if( result && !GameExtentScript._showNpcModel ) { var root = _activedScene.Find( info.ID ).ModelTransform; GameExtentScript.SetModelActive( root, false ); } } else { entity.SyncInfo( info ); } } } //刷新怪物信息 -- 如果没有的话,就创建一个 public void RefreshMonster(MonsterInitInfo info, bool checkBorn = true) { if (_activedScene != null) { if (info.Cfg == null) return; var entity = _activedScene.Find(info.ID); if (entity == null) { var result = _activedScene.LoadMonster( info ); if( result && !GameExtentScript._showMonsterModel ) { var root = _activedScene.Find( info.ID ).ModelTransform; GameExtentScript.SetModelActive( root, false ); } } else { entity.SyncInfo(info); } } } //public void RefreshBrokenObj(BrokenObjInitInfo info, bool checkBorn = true) //{ // if (_activedScene != null) // { // if (info.Cfg == null) // return; // FProfiler.Begin("GameSceneSystem.RefreshBrokenObj"); // var entity = _activedScene.Find(info.ID); // if (entity == null) // { // //_activedScene.LoadBrokenObj(info); // } // else // { // entity.SyncInfo(info); // } // FProfiler.End(); // } //} //刷新宠物信息 -- 如果没有的话,就创建一个 public void RefreshPet(PetInitInfo info) { if (_activedScene != null) { if (info.Cfg == null) return; var entity = _activedScene.Find(info.ID); if (entity == null) { var result = _activedScene.LoadPet(info); if(result && !GameExtentScript._showPlayerModel ) { var root = _activedScene.Find( info.ID ); GameExtentScript.SetModelActive( root.ModelTransform, false ); } } else { entity.SyncInfo(info); } } } //刷新助战宠物 public void RefreshAssistPet(AssistPetInitInfo info) { if (_activedScene != null) { if (info.Cfg == null) return; var entity = _activedScene.Find(info.ID); if (entity == null) { _activedScene.LoadAssistPet(info); } else { entity.SyncInfo(info); } } } public void RefreshFlySword(FlySwordInitInfo info) { if (_activedScene != null && info.ID > 0) { if (info.Cfg == null) return; var entity = _activedScene.Find(info.ID); if (entity == null) { var result = _activedScene.LoadFlySword(info); if (result && !GameExtentScript._showPlayerModel) { var root = _activedScene.Find(info.ID); GameExtentScript.SetModelActive(root.ModelTransform, false); } } else { entity.SyncInfo(info); } } } public void RefreshMarryChild(MarryChildInitInfo info) { if (_activedScene != null && info.ID > 0) { if (info.Cfg == null) return; var entity = _activedScene.Find(info.ID); if (entity == null) { var result = _activedScene.LoadMarryChild(info); if (result && !GameExtentScript._showPlayerModel) { var root = _activedScene.Find(info.ID); GameExtentScript.SetModelActive(root.ModelTransform, false); } } else { entity.SyncInfo(info); } } } //刷新锁定弹道对象 public void RefreshLockTrajectoryObj(LockTrajectoryObjInitInfo info) { if (_activedScene != null) { var entity = _activedScene.Find(info.ID); if (entity == null) { _activedScene.LoadLockTrajectoryObj(info); } else { entity.SyncInfo(info); } } } //刷新简单技能召唤物信息 public void RefreshSimpleSkillObject(SimpleSkillObjectInitInfo info) { if(_activedScene != null) { var entity = _activedScene.Find(info.ID); if(entity == null) { _activedScene.LoadSimpleSkillObject(info); } else { entity.SyncInfo(info); } } } //刷新技能对象信息 public void RefreshSkillObject(SkillObjectInitInfo info) { if (_activedScene != null) { var entity = _activedScene.Find(info.ID); if (entity == null) { _activedScene.LoadSkillObject(info); } else { entity.SyncInfo(info); } } } //刷新采集物信息 -- 如果没有的话,就创建一个 public void RefreshCollection(CollectionInitInfo info) { if (_activedScene != null) { var entity = _activedScene.Find(info.ID); if (entity == null) { _activedScene.LoadCollection(info); } else { entity.SyncInfo(info); } } } //刷新掉落物品信息 public void RefreshDropItem(DropItemInitInfo info) { if (_activedScene != null) { var entity = _activedScene.Find(info.ID); if (entity == null) { _activedScene.LoadDropItem(info); } else { entity.SyncInfo(info); } } } //刷新掉落金币信息 public void RefreshDropGold(DropGoldInitInfo info) { if (_activedScene != null) { var entity = _activedScene.Find(info.ID); if (entity == null) { _activedScene.LoadDropGold(info); } else { entity.SyncInfo(info); } } } //刷新地面buff public void RefreshGroundBuff(GroundBuffInitInfo info) { if (_activedScene != null && info.Cfg != null) { var entity = _activedScene.Find(info.ID); if (entity == null) { _activedScene.LoadGroundBuff(info); } else { entity.SyncInfo(info); } } } //刷新lua角色 public void RefreshLuaCharacter(LuaCharInitInfo info) { if (_activedScene != null && info.ID > 0) { var entity = _activedScene.Find(info.ID); if (entity == null) { _activedScene.LoadLuaCharacter(info); } else { entity.SyncInfo(info); } } } #endregion #region//场景心跳处理 //场景的心跳处理 public void Update(float deltaTime) { if (_activedScene != null) { _activedScene.Update(deltaTime); } if (_timeScaleCounter > 0f) { float dt = Time.realtimeSinceStartup - _frontUpdateTime; _frontUpdateTime = Time.realtimeSinceStartup; _timeScaleCounter -= dt; if (_timeScaleCounter <= 0f) { Time.timeScale = 1f; } } } #endregion #region//场景的一些其他物件的操作,例如:摄像机... //时间缩放效果,最多放大两倍 public void DoTimeScale(float scale, float scaleTime) { if (scale <= 0f || scale >= 2f || scaleTime <= 0f) return; _timeScaleCounter = scaleTime; Time.timeScale = scale; _frontUpdateTime = Time.realtimeSinceStartup; } #endregion #region//发送场景的的网络消息,包括:换线,等 //发送换线消息 public void SendSwitchLineMsg(int lineID) { if (_activedScene != null) { if (_activedScene.LineID != lineID) { MSG_Map.ReqSelectLine msg = new MSG_Map.ReqSelectLine(); msg.line = lineID; msg.Send(); } } } //发送请求线路信息消息 public void SendGetLineInfoMsg() { if (_activedScene != null) { MSG_Map.ReqGetLines msg = new MSG_Map.ReqGetLines(); msg.Send(); } } #endregion #region//开启和关闭背景音乐 //背景音乐 public void PlayBGMusic(int mapID = -1) { if (mapID < 0) mapID = _mapID; var map = DeclareMapsetting.Get(mapID); if (map != null) { AudioPlayer.PlayMusic(map.Music); } } //停止背景音乐 public void StopBGMusic(bool isStopNow = false) { AudioPlayer.Stop(AudioTypeCode.Music, isStopNow); } //第一次进游戏场景 public void OnFirstEnterMap() { if (_isFirstEnterMap) { _isFirstEnterMap = false; GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_FIRSTENTERMAP); } } #endregion #region//信息 public string Infomation() { var sb = new StringBuilder(); sb.AppendFormat("SceneEntities:{0}", _activedScene.Entities.GetCount()); sb.AppendLine(); sb.AppendFormat("RemoterPlayer:{0}", _activedScene.Entities.GetCount()); sb.AppendLine(); sb.AppendFormat("Monster:{0}", _activedScene.Entities.GetCount()); sb.AppendLine(); sb.AppendFormat("NPC:{0}", _activedScene.Entities.GetCount()); sb.AppendLine(); sb.AppendFormat("Collection:{0}", _activedScene.Entities.GetCount()); sb.AppendLine(); sb.AppendFormat("VFX:{0}", -999999/*GameCenter.VFXManager.ActiveCount*/); sb.AppendLine(); return sb.ToString(); } #endregion } }