Exemple #1
0
    /// <summary>
    /// await で待つ場合
    /// </summary>
    public static async Task AddptiveLoadAsync(SceneNames sceneNames)
    {
        // 遷移エフェクト

        await SceneManager.LoadSceneAsync(sceneNames.ToString(), LoadSceneMode.Additive);

        SceneManager.SetActiveScene(SceneManager.GetSceneByName(sceneNames.ToString()));

        // 遷移エフェクト
    }
 public static int GetOffset(SceneNames value)
 {
     var type = value.GetType();
     var field = type.GetField(value.ToString(), BindingFlags.Static | BindingFlags.Public);
     var attributes = field.GetCustomAttributes(typeof(CameraXOffsetAttribute), false);
     var attribute = attributes[0] as CameraXOffsetAttribute;
     var offset = attribute.Offset;
     return offset;
 }
Exemple #3
0
    //Change the currentFlow
    public void ChangeFlows(SceneNames flowToLoad)
    {
        flowInitialized = false;
        //Close the currentFlow
        currentFlow.CloseFlow();
        //Create new flow
        currentFlow = CreateFlow(flowToLoad);


        //Add the function to the event
        SceneManager.sceneLoaded += OnSceneLoaded;
        SceneManager.LoadSceneAsync(flowToLoad.ToString());
    }
    /// <summary>
    /// Coroutine that loads a new scene.
    /// </summary>
    /// <param name="scene">Scene to load.</param>
    /// <returns>Returns null.</returns>
    private IEnumerator LoadNewScene(SceneNames scene)
    {
        YieldInstruction waitForFrame = new WaitForEndOfFrame();
        AsyncOperation   sceneToLoad  =
            SceneManager.LoadSceneAsync(scene.ToString());

        // After the progress reaches 1, the scene loads
        while (sceneToLoad.progress < 1)
        {
            yield return(waitForFrame);
        }

        loadSceneCoroutine = null;
    }
    private Flow CreateFlow(SceneNames _flowToLoad)
    {
        Flow toRet;

        switch (_flowToLoad)
        {
        case SceneNames.MainMenu:
            toRet = new MainMenuFlow();
            break;

        case SceneNames.MainScene:
            toRet = new GameFlow();
            break;

        default:
            toRet = new GameFlow();
            Debug.LogError("Unhandled Switch: " + _flowToLoad.ToString());
            break;
        }
        return(toRet);
    }
Exemple #6
0
 public void LoadScene(SceneNames sceneName)
 {
     SceneManager.LoadScene(sceneName.ToString());
 }
Exemple #7
0
    public static async Task CloseScene(SceneNames sceneNames)
    {
        await SceneManager.UnloadSceneAsync(sceneNames.ToString());

        // 遷移エフェクト
    }
    public void ChangeScene(int i)
    {
        SceneNames scene = (SceneNames)i;

        SceneManager.LoadScene(scene.ToString());
    }
 public void Execute(SceneNames sceneName)
 {
     SceneManager.LoadScene(sceneName.ToString());
     Debug.Log("Loaded " + sceneName + " scene");
 }
Exemple #10
0
    /// <summary>
    /// OnTriggerEnter of SceneChange
    /// When leaving room 3, writes player's position to a file
    /// When the player collides with this collider, it loads a new scene
    /// </summary>
    /// <param name="other">Collider the SceneChange collided with</param>
    private void OnTriggerEnter(Collider other)
    {
        // Saves room3 last position before entering a new room
        if (SceneManager.GetActiveScene().name.Equals("Room3") ||
            SceneManager.GetActiveScene().name.Equals("Room7"))
        {
            using (StreamWriter sw = File.CreateText(FilePath.lastScenePath))
            {
                sw.WriteLine($"In{goToScene}");
            }
        }

        // On collision with player, loads new scene
        if (other.CompareTag("Player"))
        {
            // If file exists
            if (File.Exists(FilePath.watchedCutscenes))
            {
                bool   watchedCutscene    = false;
                string watchedCutsceneStr = null;

                // Reads everyline and compares if the line is the same as goTo
                using (StreamReader sr = File.OpenText(FilePath.watchedCutscenes))
                {
                    while ((watchedCutsceneStr = sr.ReadLine()) != null)
                    {
                        // If goToScene already happened, sets watchedCutscene
                        //  to true
                        if (watchedCutsceneStr == goToScene.ToString())
                        {
                            watchedCutscene = true;
                        }
                    }
                }
                // After reading the file

                // If goToScene was watched, loads elseGoToScreen
                if (watchedCutscene)
                {
                    OnChangedScene(elseGoToScene);
                }

                // Else, if the goToScene wasn't watched, loads the normal
                //  cutscene order and writes its name on the file
                else
                {
                    File.AppendAllText(FilePath.watchedCutscenes,
                                       $"\n{goToScene}");

                    OnChangedScene(GoToScene);
                }
            }

            // If the file doesn't exist, creates a new file
            else
            {
                File.AppendAllText(FilePath.watchedCutscenes, $"{goToScene}");

                OnChangedScene(GoToScene);
            }
        }
    }
Exemple #11
0
 public static string GetString(this SceneNames sceneNames)
 {
     return(sceneNames.ToString());
 }