Пример #1
0
 protected virtual void Update()
 {
     if (_queuedPhase != null && _changingState == false)
     {
         _changingState = true;
         GM_Phase newPhase = _queuedPhase;
         _queuedPhase = null;
         StartCoroutine(SetActivePhase(newPhase));
     }
 }
Пример #2
0
 public virtual IEnumerator Exit(GM_Phase newPhase)
 {
     yield return(null);
 }
Пример #3
0
 public virtual IEnumerator Enter(GM_Phase oldPhase)
 {
     yield return(null);
 }
Пример #4
0
        IEnumerator SetActivePhase(GM_Phase newPhase)
        {
            Debug.Log("set active phase 1 : " + newPhase.GetType().ToString());


            UN_CameraFade.ClearAll();
            bool readyToSwitch1 = false;

            UN_CameraFade.FadeToBlack(() => { readyToSwitch1 = true; }, 2.0f);      //### PJS TO DO : remove time

            IEnumerator it;

            _previousPhase = _curPhase;
            if (_previousPhase != null)
            {
                it = _previousPhase.Exit(newPhase);
                while (it.MoveNext())
                {
                    yield return(null);
                }

                UN.SetActive(_previousPhase, false);
            }

            // wait for fade to black to be done
            while (readyToSwitch1 == false)
            {
                yield return(null);
            }

            _curPhase = newPhase;
            UN.SetActive(newPhase, true);
            it = newPhase.Enter(_previousPhase);
            while (it.MoveNext())
            {
                yield return(null);
            }

            string newSceneName = newPhase.SceneName;

            if (!string.IsNullOrEmpty(newSceneName) && newSceneName != SceneManager.GetActiveScene().name)
            {
                AsyncOperation loadingOp = SceneManager.LoadSceneAsync(newSceneName);
                if (loadingOp != null)
                {
                    while (loadingOp.isDone == false)
                    {
                        yield return(null);
                    }

                    Events.SendGlobal(new SceneChangedEvent()
                    {
                        Name = _curPhase.SceneName
                    });
                }
            }

            Events.SendGlobal(new GM_GamePhaseChangedEvent()
            {
                NewPhase = _curPhase == null ? null : _curPhase.GetType(),
                OldPhase = _previousPhase == null ? null : _previousPhase.GetType()
            });

            {
                bool readyToSwitch2 = false;
                UN_CameraFade.FadeToTransparent(() => { readyToSwitch2 = true; }, 2.0f);    //### pjs todo fix time
                while (readyToSwitch2 == false)
                {
                    yield return(null);
                }
            }
            _changingState = false;

            Debug.Log("set active phase 2 : " + newPhase.GetType().ToString());
        }
Пример #5
0
 public void QueuePhase <T>() where T : GM_Phase
 {
     Debug.Log("Queing phase: " + typeof(T).GetType().ToString());
     _queuedPhase = GetPhase <T>();
 }
Пример #6
0
 public void QueuePhase(GM_Phase p)
 {
     Dbg.Assert(_queuedPhase == null);
     Dbg.Assert(p != null);
     _queuedPhase = p;
 }
Пример #7
0
 protected void AddPhase(GM_Phase phase)
 {
     _phases.Add(phase);
 }