/*************************************************************************************************
     *  Function:   IEnumerator _end_scene()
     *  Description: Coroutine that ends scene. Does transport effect and fades out scene then loads
     *              next scene.
     ************************************************************************************************/
    IEnumerator _end_scene()
    {
        GameObject transport = Instantiate(transport_effect, player.transform.position, Quaternion.identity) as GameObject;

        player.SetActive(false);
        float transport_duration = transport.GetComponent <ParticleSystem> ().duration;

        yield return(new WaitForSeconds(transport_duration + 1f));

        yield return(Scene_Effects.fade_to_black(1f));

        yield return(new WaitForSeconds(1f));           //pause on black before loading next scene

                #if UNITY_EDITOR
        int    current_level_index = 0;
        string current_level_name  = SceneManager.GetActiveScene().name;
        for (int i = 0; i < scene_manager.scene_names.Length; i++)
        {
            if (scene_manager.scene_names[i] == current_level_name)
            {
                current_level_index = i;
                break;
            }
        }

        SceneManager.LoadScene(scene_manager.scene_names[(current_level_index + 1) % scene_manager.scene_names.Length]);
                #else
        int loaded_level = SceneManager.GetActiveScene().buildIndex;
        SceneManager.LoadScene(SceneManager.sceneCount % (loaded_level + 1));
                #endif
    }
Пример #2
0
 /*****************************************************************************************
  * Function:    void OnDestroy()
  * Description: Sets script instance to null when instance of script is destroyed.
  ******************************************************************************************/
 void OnDestroy()
 {
     if (!is_duplicate)              //Ensures that instance is only set to null if there are truly no instances of this script in the scene.
     {
         instance = null;
     }
 }
    /*************************************************************************************************
    *  Function:    IEnumerator start_scene()
    *  Description: Function called at start of scene. Sets the player's sprite renderer to clear
    *               so it can't be seen, removes user's ability to control player, fades in scene
    *               from current fader color (set as black in Awake()), and then starts the
    *               fade_in_player coroutine to fade the player's sprite in and return user control.
    *************************************************************************************************/
    IEnumerator start_scene()
    {
        player_controller.disable_control();

        if (do_player_fade)
        {
            player_renderer.color = new Color(1f, 1f, 1f, 0f);
        }

        if (do_scene_fade)
        {
            Scene_Effects.fade_to_clear(1f);

            while (Scene_Effects.fader.color.a > 0.4)
            {
                yield return(null);
            }
        }

        if (do_player_fade)
        {
            yield return(Scene_Effects.fade_in_sprite(player_renderer, 2f));
        }

        if (do_initial_focus)
        {
            yield return(main_cam_script.focus(focus_target.transform, 0.8f, 5f, 1f));
        }

        player_controller.enable_control();
    }
Пример #4
0
    static public Scene_Effects instance = null; //Used to make sure that only one instance of this script exists in the scene at any given time.

    /*****************************************************************************************
     * Function:    void Awake()
     * Description: Called at creation of script. Ensures that only one instance of this script
     *             can exist in the scene at any given time. Makes function call to initialize
     *             screen fader properties if this is the single instance of the script.
     ******************************************************************************************/
    void Awake()
    {
        //Can only have one instance of Scene_Effects script.
        if (instance == null)
        {
            instance = this;
            init_fader();
        }
        else if (instance != this)
        {
            is_duplicate = true;
            Destroy(this);
        }
    }