Exemple #1
0
            public override void OnStateEnter()
            {
                base.OnStateEnter();

                LoadUnloadScenesSignal.Load(new[] { ProjectScenes.Game }, SignalBus).Done
                (
                    () => { StartupModel.LoadingProgress.Value = StartupModel.ELoadingProgress.GamePlay; }
                );
            }
Exemple #2
0
            public override void OnStateEnter()
            {
                base.OnStateEnter();

                LoadUnloadScenesSignal.Load(ProjectScenes.Hud, SignalBus).Done
                (
                    () => { StartupModel.LoadingProgress.Value = StartupModel.ELoadingProgress.LoadGamePlay; },
                    exception => { }
                );
            }
 private void OnPlayClicked()
 {
     LoadUnloadScenesSignal.Load(Mediator.SignalBus, Scenes.GamePlay).Done
     (
         () => { Mediator._bootstrapModel.LoadingProgress.Value = BootstrapModel.ELoadingProgress.GamePlay; },
         exception =>
     {
         UnityEngine.Debug.LogError("Exception: " + exception.ToString());
     }
     );
 }
            public override void OnStateEnter()
            {
                base.OnStateEnter();

                LoadUnloadScenesSignal.Load(SignalBus, new[] { Scenes.MainHub }).Done
                (
                    () =>
                {
                    BootstrapModel.LoadingProgress.Value = BootstrapModel.ELoadingProgress.MainHub;
                }
                );
            }
Exemple #5
0
            public override void OnStateEnter()
            {
                base.OnStateEnter();

                LoadUnloadScenesSignal.Load(Mediator.SignalBus, Scenes.Hud).Done
                (
                    () =>
                {
                    BootstrapModel.LoadingProgress.Value = model.scene.BootstrapModel.ELoadingProgress.HudLoaded;
                },
                    exception =>
                {
                    Debug.LogError("Exception: " + exception.ToString());
                }
                );
            }
        //First loads an optional array of scenes, then
        //unloads a separate optional array of scenes.
        //Each call to load/unload is added into a
        //promise chain. When complete, the last promise
        //fires an optional OnComplete delegate.
        public void Execute(LoadUnloadScenesSignal loadUnloadParams)
        {
            IPromise lastPromise = null;

            //Load scenes
            if (loadUnloadParams.LoadScenes != null)
            {
                foreach (var sceneName in loadUnloadParams.LoadScenes)
                {
                    var name = sceneName;
                    lastPromise = lastPromise != null?lastPromise.Then(() => _sceneLoader.LoadScene(name)) : _sceneLoader.LoadScene(sceneName);
                }
            }

            //Unload scenes
            if (loadUnloadParams.UnloadScenes != null)
            {
                foreach (var sceneName in loadUnloadParams.UnloadScenes)
                {
                    var name = sceneName;
                    lastPromise = lastPromise != null?lastPromise.Then(() => _sceneLoader.UnloadScene(name)) : _sceneLoader.UnloadScene(sceneName);
                }
            }

            //Add promise to resolve OnComplete
            if (lastPromise != null)
            {
                lastPromise.Done(
                    () =>
                {
                    Debug.Log($"{this} , scene loading/unloading completed!");

                    loadUnloadParams.OnComplete?.Resolve();
                },
                    exception =>
                {
                    loadUnloadParams.OnComplete?.Reject(exception);
                }
                    );
            }
            else
            {
                Debug.Log($"{this} , no scenes loaded/unloaded!");

                loadUnloadParams.OnComplete?.Resolve();
            }
        }
Exemple #7
0
            public override void OnStateEnter()
            {
                base.OnStateEnter();

                LoadUnloadScenesSignal.Load(SignalBus, Scenes.Popup).Done
                (
                    () =>
                {
                    // Testing Popup
                    #if UNITY_EDITOR && DEBUG
                    //ShowYesNoPopup();
                    #endif

                    BootstrapModel.LoadingProgress.Value = model.scene.BootstrapModel.ELoadingProgress.PopupLoaded;
                },
                    exception =>
                {
                    UnityEngine.Debug.LogError(exception);
                }
                );
            }
Exemple #8
0
            public override void OnStateEnter()
            {
                base.OnStateEnter();

                LoadUnloadScenesSignal.Load(ProjectScenes.Popup, SignalBus).Done
                (
                    () =>
                {
                    StartupModel.LoadingProgress.Value = StartupModel.ELoadingProgress.LoadStaticData;

                    // Testing Popup

                    /*
                     #if UNITY_EDITOR && DEBUG
                     * Mediator.ShowPopup(YesNoPopupConfig.GetYesNoPopupConfig
                     *                ("Start Game?", "Going to Start Game"))
                     * .Done((result) =>
                     * {
                     *  YesNoPopupResult popupResult = (YesNoPopupResult)result;
                     *  if (popupResult.Yes)
                     *  {
                     *      StartupModel.LoadingProgress.Value = StartupModel.ELoadingProgress.LoadStaticData;
                     *      UnityEngine.Debug.Log("Yes Button Clicked.");
                     *      // Success.
                     *  }
                     *  else if(popupResult.No)
                     *  {
                     *      UnityEngine.Debug.Log("No Button Clicked.");
                     *  }
                     * });
                     #endif
                     */
                },
                    exception => { }
                );
            }
Exemple #9
0
        //First loads an optional array of scenes, then
        //unloads a separate optional array of scenes.
        //Each call to load/unload is added into a
        //promise chain. When complete, the last promise
        //fires an optional OnComplete delegate.
        public void Execute(LoadUnloadScenesSignal loadUnloadParams)
        {
            IPromise lastPromise = null;

            //Load scenes
            if (loadUnloadParams.LoadScenes != null)
            {
                for (int i = 0; i < loadUnloadParams.LoadScenes.Length; i++)
                {
                    string sceneName = loadUnloadParams.LoadScenes[i];
                    if (lastPromise != null)
                    {
                        lastPromise = lastPromise.Then(() => _sceneLoader.LoadScene(sceneName));
                    }
                    else
                    {
                        lastPromise = _sceneLoader.LoadScene(sceneName);
                    }
                }
            }

            //Unload scenes
            if (loadUnloadParams.UnloadScenes != null)
            {
                for (int i = 0; i < loadUnloadParams.UnloadScenes.Length; i++)
                {
                    string sceneName = loadUnloadParams.UnloadScenes[i];
                    if (lastPromise != null)
                    {
                        lastPromise = lastPromise.Then(() => _sceneLoader.UnloadScene(sceneName));
                    }
                    else
                    {
                        lastPromise = _sceneLoader.UnloadScene(sceneName);
                    }
                }
            }

            //Add promise to resolve OnComplete
            if (lastPromise != null)
            {
                lastPromise.Done(
                    () =>
                {
                    Debug.Log(string.Format("{0} , scene loading/unloading completed!", this));

                    loadUnloadParams.OnComplete?.Resolve();
                },
                    exception =>
                {
                    loadUnloadParams.OnComplete?.Reject(exception);
                }
                    );
            }
            else
            {
                Debug.Log(string.Format("{0} , no scenes loaded/unloaded!", this));

                loadUnloadParams.OnComplete?.Resolve();
            }
        }