private void EventSceneLoadCompleted(int mapId) { // 每个场景都会有默认的界面显示 // 默认打开的界面 // Loading 场景,这里mapid == 0,不处理 if (mapId <= 0) { return; } ResourceWorld refMap = ResourceAll.GetInstance().MapMgr.GetReference(mapId); if (refMap == null || refMap.UiRes == (int)UiType.None) { return; } UiType uiType = Util.ChangeToEnum <UiType>(refMap.UiRes); if (uiType != UiType.None) { OpenUi(uiType); } }
void OnSceneLoaded(Scene scene, LoadSceneMode mode) { Debug.Log("OnSceneLoaded: " + scene.name + " LoadSceneMode:" + mode); // AsyncLoaderScene if (scene.name.Equals(AsyncLoader.SceneLoader)) { var scrpts = Camera.main.gameObject.GetComponent <AsyncLoader>(); if (scrpts == null) { Camera.main.gameObject.AddComponent <AsyncLoader>(); } return; } _isLoadedMap = true; int mapId = AsyncLoaderCache.GetInstance().GetMapId(); if (mapId <= 0) { return; } _currentWorld = new World(ResourceAll.GetInstance().MapMgr.GetReference(mapId)); // 触发一个场景加载完毕的事件 EventDispatcher.GetInstance().Broadcasting <int>(eEventType.SceneLoadCompleted, mapId); // 初始化角色位置 if (_mainPlayer != null && Camera.main.gameObject != null) { // 增加一个相机跟随组件 CameraFollowBehaviour cTrack = Camera.main.gameObject.GetComponent <CameraFollowBehaviour>(); if (cTrack == null) { cTrack = Camera.main.gameObject.AddComponent <CameraFollowBehaviour>(); } if (_mainPlayer.GetGameObject() != null) { cTrack.Target = _mainPlayer.GetGameObject().GetComponent <Transform>(); } } // 场景加载完成之后,处理缓存的协议 HandlerCacheMsg(); }
private void MsgEnterWorld(Google.Protobuf.IMessage msg) { Proto.EnterWorld protoEnter = msg as Proto.EnterWorld; if (protoEnter == null) { return; } GameLogger.GetInstance().Debug($"Enter world. world id:{protoEnter.WorldId}"); ResourceWorld refMap = ResourceAll.GetInstance().MapMgr.GetReference((int)protoEnter.WorldId); if (refMap == null) { return; } LoadScene(refMap.AbPath, refMap.ResName, (int)protoEnter.WorldId); }
public void Init() { ResourceAll.GetInstance().Init(); }