Exemplo n.º 1
0
 /// <summary>
 /// 加载逻辑场景
 /// </summary>
 /// <param name="data"></param>
 private void LoadLogicScene(SceneInfoData data)
 {
     if (data != null)
     {
         CurrentScene.SetWhenOpening(data.SceneName, data.SceneType, data.Params);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 直接切换
        /// </summary>
        /// <param name="_sceneType"></param>
        public void ChangeSceneDirect(ScnType _sceneType)
        {
            UIManager.Instance.CloseUIAll();

            if (CurrentScene != null)
            {
                CurrentScene.Release();
                CurrentScene = null;
            }

            LastSceneType   = ChangeSceneType;
            ChangeSceneType = _sceneType;
            SceneInfoData sid       = GetSceneInfo(_sceneType);
            string        sceneName = GetSceneName(_sceneType);

            //change scene
            MonoHelper.Instance.StartCoroutine(AsyncLoadScene(sceneName, () =>
            {
                // 注册场景Module
                ModuleManager.Instance.RegisterModule(sid.SceneType);

                if (sceneOpenUIType != UIType.None)
                {
                    UIManager.Instance.OpenUICloseOthers(sceneOpenUIType, false, sceneOpenUIParams);
                    sceneOpenUIType = UIType.None;
                }
            }));
        }
Exemplo n.º 3
0
 public string GetSceneName(EnumSceneType sceneId)
 {
     if (IsRegister(sceneId))
     {
         SceneInfoData info = dicScneneInfo[sceneId];
         return(info.SceneName);
     }
     return("");
 }
Exemplo n.º 4
0
    public string GetName <T>() where T : BaseScene
    {
        SceneInfoData data = GetData <T>();

        if (data != null)
        {
            return(data.SceneName);
        }
        return(null);
    }
Exemplo n.º 5
0
        public BaseScene GetScene(EnumSceneType scnenId)
        {
            Debug.Log("Get  Scene: " + scnenId);
            SceneInfoData info = dicScneneInfo[scnenId];

            if (info == null || info.ScriptType == null)
            {
                return(null);
            }
            return(System.Activator.CreateInstance(info.ScriptType) as BaseScene);
        }
Exemplo n.º 6
0
    /// <summary>
    ///没有进度条的异步加载
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    private IEnumerator <AsyncOperation> AsyncLoadScene(SceneInfoData data)
    {
        AsyncOperation oper = SceneManager.LoadSceneAsync(data.SceneName);

        yield return(oper);

        if (oper.isDone)
        {
            CurrentScene = GetScene(data.SceneType);
            LoadLogicScene(data);
        }
    }
Exemplo n.º 7
0
 public void RegisterScene(EnumSceneType _sceneId, string _sceneName, Type _sceneType, params object[] _params)
 {
     if (null == _sceneType || _sceneType.BaseType != typeof(BaseScene))
     {
         throw new SingletonException("Register scene type must nor null and extends BaseScene !");
     }
     if (!dicSceneInfos.ContainsKey(_sceneId))
     {
         SceneInfoData info = new SceneInfoData(_sceneName, _sceneType, _params);
         dicSceneInfos.Add(_sceneId, info);
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// 关卡管理类注册
 /// </summary>
 /// <param name="_sceneID">关卡ID</param>
 /// <param name="_sceneName">关卡名</param>
 /// <param name="_sceneType">关卡管理类</param>
 /// <param name="_params">参数</param>
 private void RegisterScene(ScnType _sceneID, string _sceneName, Type _sceneType, params object[] _params)
 {
     if (_sceneType == null || _sceneType.BaseType != typeof(BaseScene))
     {
         throw new Exception("Register scene type must not null and extends BaseScene");
     }
     if (!dicSceneInfos.ContainsKey(_sceneID))
     {
         SceneInfoData sceneInfo = new SceneInfoData(_sceneName, _sceneType, _params);
         dicSceneInfos.Add(_sceneID, sceneInfo);
     }
 }
Exemplo n.º 9
0
        internal BaseScene GetBaseScene(ScnType _sceneType)
        {
            Debug.Log(" GetBaseScene  sceneId = " + _sceneType.ToString());
            SceneInfoData sceneInfo = GetSceneInfo(_sceneType);

            if (sceneInfo == null || sceneInfo.SceneType == null)
            {
                return(null);
            }
            BaseScene scene = System.Activator.CreateInstance(sceneInfo.SceneType) as BaseScene;

            return(scene);
        }
Exemplo n.º 10
0
        public BaseScene GetBaseScene(EnumSceneType _sceneType)
        {
            Debug.Log("GetBaseScene sceneId = " + _sceneType.ToString());
            SceneInfoData sceneInfo = GetSceneInfo(_sceneType);

            if (null == sceneInfo || null == sceneInfo.SceneType)
            {
                return(null);
            }
            BaseScene scene = System.Activator.CreateInstance(sceneInfo.SceneType) as BaseScene;

            return(scene);
        }
Exemplo n.º 11
0
        public void Register(EnumSceneType scnenId, Type ssriptType, string sceneName, params object[] sceneParams)
        {
            SceneInfoData info = new SceneInfoData(ssriptType, sceneName, sceneParams);

            if (IsRegister(scnenId))
            {
                dicScneneInfo[scnenId] = info;
            }
            else
            {
                dicScneneInfo.Add(scnenId, info);
            }
        }
Exemplo n.º 12
0
                public void RegisterScene(EnumSceneType _sceneID, string _sceneName, Type _sceneType, params System.Object[] _params)
        {
                         if (_sceneType  ==  null  ||  _sceneType.BaseType !=  typeof(BaseScene))
            {
                                  throw new Exception("Register scene type must not null and extends BaseScene");
                             
            }

                         if (dicSceneInfos.ContainsKey(_sceneID))
            {
                               SceneInfoData sceneInfo = new SceneInfoData(_sceneName, _sceneType, _params);
                               dicSceneInfos.Add(_sceneID, sceneInfo);

                          
            }
                   
        }
Exemplo n.º 13
0
    /// <summary>
    /// 注册场景,注意:不给参数场景名字就是类名,如果有参数第一个参数就是场景名字
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="_params"></param>
    public void Register <T>(params object[] _params) where T : BaseScene
    {
        if (dicInfo.ContainsKey(typeof(T)) == false)
        {
            SceneInfoData data;
            if (_params != null && _params.Length > 0)
            {
                data = new SceneInfoData(typeof(T), _params);
            }
            else
            {
                data = new SceneInfoData(typeof(T), typeof(T).Name);
            }

            dicInfo.Add(typeof(T), data);
        }
    }
Exemplo n.º 14
0
    /// <summary>
    /// 有进度条的异步加载
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    private IEnumerator <AsyncOperation> AsyncLoadOtherScene(SceneInfoData data)
    {
        string loadingName = GetName <LoadingScene>();

        AsyncOperation oper = SceneManager.LoadSceneAsync(loadingName);

        yield return(oper);


        //load场景加载完成
        if (oper.isDone)
        {
            UIManager.Instance.OpenPanel <LoadingPanel>();
            CurrentScene = GetScene <LoadingScene>();

            LoadLogicScene(data);
        }
    }
Exemplo n.º 15
0
    public BaseScene GetScene(Type sceneType)
    {
        SceneInfoData data = GetData(sceneType);

        if (data == null)
        {
            return(null);
        }

        GameObject go = GameObject.FindObjectOfType(data.SceneType) as GameObject;

        if (go == null)
        {
            go = new GameObject(data.SceneName, data.SceneType);
        }

        BaseScene bs = go.GetComponent(data.SceneType) as BaseScene;

        return(bs);
    }
Exemplo n.º 16
0
                internal BaseScene GetBaseScene(EnumSceneType _sceneType)
        {
                        Debug.Log("GetBaseScene sceneId = "   + _sceneType.ToString());

                        SceneInfoData sceneInfo = GetSceneInfo(_sceneType);

                        if (sceneInfo ==  null ||  sceneInfo.SceneType ==  null)
            {
                                return(null);

                           
            }

                        BaseScene scene = System.Activator.CreateInstance(sceneInfo.SceneType) as BaseScene;

                        return(scene);

                        //BaseScene scene = Game.Instance.GetBaseScene(Game.Instance.ChangeSceneId);
                        //Game.Instance.CurrentScene = scene;
                        //scene.Load();
                       
        }
Exemplo n.º 17
0
    /// <summary>
    /// 切换到指定场景
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="hasLoading"></param>
    /// <param name="args"></param>
    public void ChangeScene <T>(bool hasLoading, params object[] args) where T : BaseScene
    {
        UIManager.Instance.CloseOtherPanel();

        if (CurrentScene != null)
        {
            CurrentScene.Release();
            //CurrentScene = null;
        }
        LastSceneType = CurrentType;

        SceneInfoData data = GetData <T>();

        data.Params = args;
        if (hasLoading)
        {
            CoroutineController.Instance.StartCoroutine(AsyncLoadOtherScene(data));
        }
        else
        {
            CoroutineController.Instance.StartCoroutine(AsyncLoadScene(data));
        }
    }