예제 #1
0
 protected override bool NeedsScreenshotForPhase(SMTransitionState state)
 {
     if (state == SMTransitionState.In)
     {
         return(false);
     }
     return(base.NeedsScreenshotForPhase(state));
 }
예제 #2
0
    /// <summary>
    /// This method actually does the transition. It is run in a coroutine and therefore needs to do
    /// yield returns to play an animation or do another progress over time. When this method returns
    /// the transition is expected to be finished.
    /// </summary>
    /// <returns>
    /// A <see cref="IEnumerator"/> for showing the transition status. Use yield return statements to keep
    /// the transition running, otherwise simply end the method to stop the transition.
    /// </returns>
    protected virtual IEnumerator DoTransition()
    {
        state = SMTransitionState.Out;
        Prepare();
        float time = 0;

        while (Process(time))
        {
            time += Time.deltaTime;
            // wait for the next frame
            yield return(0);
        }

        // wait another frame...
        yield return(0);

        state = SMTransitionState.Hold;
        DontDestroyOnLoad(gameObject);

        // wait another frame...
        yield return(0);

        IEnumerator loadLevel = DoLoadLevel();

        while (loadLevel.MoveNext())
        {
            yield return(loadLevel.Current);
        }
        System.GC.Collect();
        Resources.UnloadUnusedAssets();
        SceneLoaded(screenId);

        // wait another frame...
        yield return(0);

        state = SMTransitionState.In;
        Prepare();
        time = 0;

        while (Process(time))
        {
            time += Time.deltaTime;
            // wait for the next frame
            yield return(0);
        }

        // wait another frame...
        yield return(0);

        state = SMTransitionState.None;
        Destroy(gameObject);
    }
예제 #3
0
    void LoadSceneFile()
    {
        Resources.UnloadUnusedAssets();

        state = SMTransitionState.Prepare;
        string path          = "Map/" + screenId;
        bool   resourcesLoad = true;// screenId.Contains(MapId.MapLogin) ? true : false;

        //if (screenId.Contains(MapId.MapCity) ||
        //    screenId.Contains(MapId.MapSplash)    )
        //{
        //    resourcesLoad = true;
        //}

        // @TODO δÀ´ÒƳý //
        if (screenId.Contains(MapId.Map_DargonTower))
        {
            path = "Content/Map/" + MapId.Map_DargonTower;
            //List<int> idHS = new List<int>() {9003, 6005, 4004, 5001, 5011, 5004, 11140001 };
            //for(int i = 0; i < idHS.Count - 1; i++)
            //{
            //    Debug.Log("Prepare unit for guider " + idHS[i]);
            //    LevelManager.Instance.PrepareUnit(idHS[i], null, null);
            //}
            //LevelManager.Instance.PrepareUnit(11140001, "Prefabs/Weapon/1400", null);
            //resourcesLoad = true;
        }


        if (resourcesLoad)
        {
            ResManager.Instance.LoadAsync <GameObject>(path, resourcesLoad, false, (res) =>
            {
                StartCoroutine(DoTransition());
            });
        }
        else
        {
            //TODO ///
            //  UDPServers.Instance.Exit();
            //ResManager.Instance.LoadAsync<GameObject>(path, resourcesLoad, false, (res) =>
            ResManager.Instance.LoadSceneAsync <GameObject>(path, resourcesLoad, false, (res) =>
            {
                StartCoroutine(DoTransition());
            });
        }
    }
예제 #4
0
    protected virtual IEnumerator DoTransition()
    {
        DontDestroyOnLoad(gameObject);
        if (inAction != null)
        {
            inAction();
        }

        state = SMTransitionState.Out;
        Prepare();
        float time = 0;

        while (Process(time))
        {
            time += DeltaTime;
            yield return(0);
        }

        if (holdAction != null)
        {
            holdAction();
        }

        state = SMTransitionState.In;
        Prepare();
        time = 0;
        while (Process(time))
        {
            time += DeltaTime;
            yield return(0);
        }

        yield return(0);

        Destroy(gameObject);
    }
예제 #5
0
        /// <summary>
        /// This method actually does the transition. It is run in a coroutine and therefore needs to do
        /// yield returns to play an animation or do another progress over time. When this method returns
        /// the transition is expected to be finished.
        /// </summary>
        /// <returns>
        /// A <see cref="IEnumerator"/> for showing the transition status. Use yield return statements to keep
        /// the transition running, otherwise simply end the method to stop the transition.
        /// </returns>
        protected virtual IEnumerator DoTransition()
        {
            // make sure the transition doesn't get lost when switching the level.
            DontDestroyOnLoad(gameObject);

            if (prefetchLevel)
            {
                state = SMTransitionState.Prefetch;
                SendMessage("SMBeforeTransitionPrefetch", this, SendMessageOptions.DontRequireReceiver);
                yield return(0); // wait one frame

                SendMessage("SMOnTransitionPrefetch", this, SendMessageOptions.DontRequireReceiver);

                if (Loader != null)
                {
                    while (Loader.MoveNext())
                    {
                        yield return(0);
                    }
                }
            }

            state = SMTransitionState.Out;
            SendMessage("SMBeforeTransitionOut", this, SendMessageOptions.DontRequireReceiver);
            Prepare();
            SendMessage("SMOnTransitionOut", this, SendMessageOptions.DontRequireReceiver);
            float time = 0;

            while (Process(time))
            {
                time += DeltaTime;
                // wait for the next frame
                yield return(0);
            }

            SendMessage("SMAfterTransitionOut", this, SendMessageOptions.DontRequireReceiver);
            // wait another frame...
            yield return(0);

            state = SMTransitionState.Hold;
            SendMessage("SMBeforeTransitionHold", this, SendMessageOptions.DontRequireReceiver);
            SendMessage("SMOnTransitionHold", this, SendMessageOptions.DontRequireReceiver);

            // wait another frame...
            yield return(0);


            if (!prefetchLevel && Loader != null)
            {
                // level is not prefetched, load it right now.
                while (Loader.MoveNext())
                {
                    yield return(0);
                }
            }

            SendMessage("SMAfterTransitionHold", this, SendMessageOptions.DontRequireReceiver);
            // wait another frame...
            yield return(0);

            state = SMTransitionState.In;
            SendMessage("SMBeforeTransitionIn", this, SendMessageOptions.DontRequireReceiver);
            Prepare();
            SendMessage("SMOnTransitionIn", this, SendMessageOptions.DontRequireReceiver);
            time = 0;

            while (Process(time))
            {
                time += DeltaTime;
                // wait for the next frame
                yield return(0);
            }

            sceneStageMgr.OnCompleted();
            SendMessage("SMAfterTransitionIn", this, SendMessageOptions.DontRequireReceiver);
            // wait another frame...
            yield return(0);

            Destroy(gameObject);
        }
예제 #6
0
    protected virtual IEnumerator doTransition()
    {
        //通知开始加载
        EventManager.Send(SceneEvents.EVENT_SCENE_TRANS_OUT_START, willLoadSceneID);
        m_state = SMTransitionState.Out;

        //------------ state Out ------------
        //设定一个当前经过的时间,该时间会在进度中,不断累加一个帧的时间
        float time = 0f;

        //帧进度
        while (Process(time))
        {
            time += Time.deltaTime;
            //如果time没有到特效的总时间(duration)则返回false
            yield return(0);
        }
        //------------ state Hold -------------
        //用于手动销毁旧场景对象
        EventManager.Send(SceneEvents.EVENT_SCENE_TRANS_LOADING, willLoadSceneID);

        m_loadProgress = 0f;
        m_state        = SMTransitionState.Hold;

        //防止销毁自己
        DontDestroyOnLoad(gameObject);

        yield return(0);

        //异步加载关卡场景
        AsyncOperation ao = Application.LoadLevelAsync(willLoadSceneID);

        ao.allowSceneActivation = false;//设置为false 后,进度只会到0.9,ao.isDone一直为false
        while (ao.progress < 0.9f)
        {
            if (onLoadProcess != null)
            {
                onLoadProcess((int)ao.progress * 100);
            }
            yield return(new WaitForEndOfFrame());
        }

        if (onLoadProcess != null)
        {
            onLoadProcess(100);
        }
        yield return(new WaitForEndOfFrame());

        //激活场景
        ao.allowSceneActivation = true;

        //GC
        Log.info("SceneManager 清理闲置资源");
        Resources.UnloadUnusedAssets();
        System.GC.Collect();
        yield return(0);

        while (SceneManager.waitForInit)
        {
            yield return(0);
        }

        //------------ state In ------------
        EventManager.Send(SceneEvents.EVENT_SCENE_TRANS_IN_START, willLoadSceneID);

        m_state = SMTransitionState.In;

        time = 0;
        while (Process(time))
        {
            time += Time.deltaTime;
            yield return(0);
        }

        SceneManager.instance.isRunning = false;
        DOTween.Clear(true);
        yield return(0);

        //结束
        SceneManager.instance.currentScene = willLoadSceneID;
        EventManager.Send(SceneEvents.EVENT_SCENE_TRANS_END, willLoadSceneID);
        onLoadProcess = null;
        Destroy(gameObject);
    }
 /// <summary>
 /// Function called before actually taking a screenshot for the given phase. Can be used to optimize
 /// rendering times on mobile platforms. If this returns false, no screenshot will be taken in the
 /// given phase.
 /// </summary>
 protected virtual bool NeedsScreenshotForPhase(SMTransitionState state)
 {
     return(true);
 }
예제 #8
0
    /// <summary>
    /// This method actually does the transition. It is run in a coroutine and therefore needs to do
    /// yield returns to play an animation or do another progress over time. When this method returns
    /// the transition is expected to be finished.
    /// </summary>
    /// <returns>
    /// A <see cref="IEnumerator"/> for showing the transition status. Use yield return statements to keep
    /// the transition running, otherwise simply end the method to stop the transition.
    /// </returns>
    protected virtual IEnumerator DoTransition()
    {
        // make sure the transition doesn't get lost when switching the level.
        DontDestroyOnLoad(gameObject);
#if !UNITY_3_5
        AsyncOperation asyncOperation = null;
        if (prefetchLevel)
        {
            state = SMTransitionState.Prefetch;
            SendMessage("SMBeforeTransitionPrefetch", this, SendMessageOptions.DontRequireReceiver);
            yield return(0);            // wait one frame

            SendMessage("SMOnTransitionPrefetch", this, SendMessageOptions.DontRequireReceiver);

            var loadLevel = DoLoadLevel();
            while (loadLevel.MoveNext())
            {
                var current = loadLevel.Current;
                if (asyncOperation == null)                   // try to find the actual level loading operation
                {
                    asyncOperation = current as AsyncOperation;
                    if (asyncOperation != null)
                    {
                        // hold on level switch until the transition is in hold state.
                        asyncOperation.allowSceneActivation = false;
                    }
                }
                yield return(0);
            }
        }
#endif
        state = SMTransitionState.Out;
        SendMessage("SMBeforeTransitionOut", this, SendMessageOptions.DontRequireReceiver);
        Prepare();
        SendMessage("SMOnTransitionOut", this, SendMessageOptions.DontRequireReceiver);
        float time = 0;

        while (Process(time))
        {
            time += DeltaTime;
            // wait for the next frame
            yield return(0);
        }

        SendMessage("SMAfterTransitionOut", this, SendMessageOptions.DontRequireReceiver);
        // wait another frame...
        yield return(0);

        state = SMTransitionState.Hold;
        SendMessage("SMBeforeTransitionHold", this, SendMessageOptions.DontRequireReceiver);
        SendMessage("SMOnTransitionHold", this, SendMessageOptions.DontRequireReceiver);

        // wait another frame...
        yield return(0);

#if !UNITY_3_5
        if (!prefetchLevel)
        {
#endif
        // level is not prefetched, load it right now.
        var loadLevel = DoLoadLevel();
        while (loadLevel.MoveNext())
        {
            yield return(loadLevel.Current);
        }
#if !UNITY_3_5
    }

    else
    {
        if (asyncOperation != null)                   // this should always be true, but you never know...
        // level was prefetched, so activate level switch now.
        {
            asyncOperation.allowSceneActivation = true;
        }
    }
#endif

        SendMessage("SMAfterTransitionHold", this, SendMessageOptions.DontRequireReceiver);
        // wait another frame...
        yield return(0);

        state = SMTransitionState.In;
        SendMessage("SMBeforeTransitionIn", this, SendMessageOptions.DontRequireReceiver);
        Prepare();
        SendMessage("SMOnTransitionIn", this, SendMessageOptions.DontRequireReceiver);
        time = 0;

        while (Process(time))
        {
            time += DeltaTime;
            // wait for the next frame
            yield return(0);
        }

        SendMessage("SMAfterTransitionIn", this, SendMessageOptions.DontRequireReceiver);
        // wait another frame...
        yield return(0);

        Destroy(gameObject);
    }
예제 #9
0
 protected override bool NeedsScreenshotForPhase(SMTransitionState state)
 {
     return(mode == Mode.AnimateLevelContents);
 }