示例#1
0
 public void LoadNext()
 {
     TransitionUtil.RunFadeToAndBack(
         new Color(0, 0, 0, 0),
         new Color(0, 0, 0, 1),
         2,
         2,
         2,
         () => { SceneManager.LoadScene(nextScene); },
         () => {}
         );
 }
示例#2
0
    public static void RunFadeToAndBack(Color fromColor, Color toColor, float timeTo, float timeDelay, float timeBack, Action onToReached, Action onFinish)
    {
        GameObject gameObject = GameObject.Instantiate(Resources.Load <GameObject>("FullScreenFade"));

        GameObject.DontDestroyOnLoad(gameObject);
        FullScreenFade fullScreenFade = gameObject.GetComponent <FullScreenFade>();

        fullScreenFade.image.color = fromColor;

        Action <float> withFadeValue = (lerp) =>
        {
            fullScreenFade.image.color = Color.Lerp(fromColor, toColor, lerp);
        };

        onFinish += () => GameObject.Destroy(gameObject);
        fullScreenFade.StartCoroutine(TransitionUtil.TransitionToAndBack(timeTo, timeDelay, timeBack, withFadeValue, onToReached, onFinish));
    }
    IEnumerator Run()
    {
        while (!Inventory.GetInstance().HasItem(ItemType.MetalStake))
        {
            yield return(null);
        }

        bool allEnemiesDead = false;

        while (!allEnemiesDead)
        {
            yield return(null);

            allEnemiesDead = !FindObjectsOfType <Enemy>().Any(e => !e.isDead());
        }

        DontDestroyOnLoad(gameObject);

        string nxtScene = nextScene;

        yield return(new WaitForSeconds(4));

        yield return(TransitionUtil.TransitionTo(0, 1, 8, SetBlackImageOpacity));

        HUD.Hide();

        yield return(TransitionUtil.TransitionTo(0, 1, 2, SetTextOpacity));

        yield return(new WaitForSeconds(2));

        yield return(TransitionUtil.TransitionTo(1, 0, 4, FadeMusicAndSetTextOpacity));

        yield return(new WaitForSeconds(2));

        SceneManager.LoadScene(nxtScene);
        yield return(TransitionUtil.TransitionTo(1, 0, 2, SetBlackImageOpacity));

        Destroy(gameObject);
    }