Ejemplo n.º 1
0
    IEnumerator QuitApplication_Coroutine(float delay)
    {
        // disable input
        InputManager.IsEnabled = false;

        // start fade-in
        MFGuiFader.FadeIn(delay);

        // wait for a while
        yield return(new WaitForSeconds(delay * 0.9f));

        // disable all cameras now
        foreach (Camera camera in Camera.allCameras)
        {
            camera.enabled = false;
            camera.gameObject.SetActive(false);
        }

        // finish fade-in
        yield return(new WaitForSeconds(delay * 0.1f));

        // wait a little longer
        yield return(new WaitForSeconds(0.1f));

        // it's safe to quit now
        Application.Quit();
    }
Ejemplo n.º 2
0
    IEnumerator FadeInOutAndCameraPlayEnd(float delay)
    {
        yield return(new WaitForSeconds(delay));

        MFGuiFader.FadeIn(0.3f);
        yield return(new WaitForSeconds(0.5f));

        MFGuiFader.FadeOut();
    }
Ejemplo n.º 3
0
    IEnumerator FadeInOutAndCameraPlay(string animName)
    {
        MFGuiFader.FadeIn(0.1f);
        yield return(new WaitForSeconds(0.2f));

        ParentAnimation[animName].blendMode = AnimationBlendMode.Blend;
        ParentAnimation.CrossFade(animName, 0.5f);

        DisabledTime = Time.timeSinceLevelLoad + ParentAnimation[animName].length;

        StartCoroutine(FadeInOutAndCameraPlayEnd(ParentAnimation[animName].length - 0.5f));

        yield return(new WaitForSeconds(0.1f));

        MFGuiFader.FadeOut();
    }
Ejemplo n.º 4
0
    IEnumerator LoadScene(string scene, bool mission)
    {
        IsLoading = true;

        string sceneLower = scene.ToLower();

        if (sceneLower.StartsWith("mp_"))
        {
            scene = sceneLower;
        }

        // save user settings
        SaveSettings();

        yield return(new WaitForEndOfFrame());

        yield return(new WaitForEndOfFrame());        // waiting for 2 frames is necessary here!!!

        // display loading screen
        {
            // fade to black
            MFGuiFader.FadeIn(MFGuiFader.NORMAL);
            while (MFGuiFader.Fading == true)
            {
                yield return(new WaitForEndOfFrame());
            }

            // do some cleaning and display loading screen
            ClearInstances();
            if (AppType == E_AppType.DedicatedServer)
            {
                ApplicationDZ.LoadLevel("Empty");
            }
            else
            {
                ApplicationDZ.LoadLevel(LoadingScreen);
            }

            // prepare fade-out
            MFGuiFader.FadeOut(MFGuiFader.NORMAL);
            MFGuiFader.Paused = true;

            // wait two frame
            // this causes much nicer initial delta time for fading
            yield return(new WaitForEndOfFrame());

            yield return(new WaitForEndOfFrame());

            // finish fade-out
            MFGuiFader.Paused = false;
            while (MFGuiFader.Fading == true)
            {
                yield return(new WaitForEndOfFrame());
            }
        }

        // apply graphic settings
        if (DeviceInfo.PerformanceGrade != (DeviceInfo.Performance)GuiOptions.graphicDetail)
        {
            DeviceInfo.Initialize((DeviceInfo.Performance)GuiOptions.graphicDetail);
        }

        // load scene
        {
            // do another cleaning and load scene
            ClearInstances();
            yield return(new WaitForEndOfFrame());

            yield return(new WaitForEndOfFrame());            // waiting for 2 frames is necessary here!!!

            yield return(Resources.UnloadUnusedAssets());

            yield return(new WaitForEndOfFrame());

            ApplicationDZ.LoadLevel(scene);

            // prepare fade-out
            MFGuiFader.FadeOut(MFGuiFader.SLOW);
            MFGuiFader.Paused = true;

            // waint two frames so game has time to initialize
            yield return(new WaitForEndOfFrame());

            yield return(new WaitForEndOfFrame());
            //yield return Resources.UnloadUnusedAssets();
        }

        if (mission)
        {
            if (Client.Instance)
            {
                Client.Instance.OnMissionLoaded(scene);
            }
#if !DEADZONE_CLIENT
            if (Server.Instance)
            {
                Server.Instance.OnMissionLoaded(scene);
            }
#endif
        }
        System.GC.Collect();

        // clear input buffers
        InputManager.FlushInput();

        // loading finished
        IsLoading        = false;
        DownloadingLevel = null;

        // wait one frame
        // this causes much nicer initial delta time for fading
        yield return(new WaitForEndOfFrame());

        // finish fade-out
        MFGuiFader.Paused = false;
        while (MFGuiFader.Fading == true)
        {
            yield return(new WaitForEndOfFrame());
        }
    }