public static void LoadSceneAsync(SceneEnumName sceneEnumName)
    {
        SceneNames container = Resources.Load <SceneNames>("ScriptObjects/Scenes/NamedScenes");
        string     scene     = container.GetSceneName(sceneEnumName);

        OnLoadSceneAsync?.Invoke(scene);
    }
Exemple #2
0
 public void InitializeFlowManager(SceneNames initialScene)
 {
     currentScene    = initialScene;
     currentFlow     = CreateFlow(initialScene);
     flowInitialized = true;
     currentFlow.InitializeFlow();
 }
    public static void LoadScene(SceneEnumName sceneEnumName)
    {
        SceneNames container = Resources.Load <SceneNames>("ScriptObjects/Scenes/NamedScenes");
        string     scene     = container.GetSceneName(sceneEnumName);

        SceneManager.LoadScene(scene);
    }
Exemple #4
0
    public bool HandleEvent(IEvent @event)
    {
        //Debug.LogWarning("change scene event");

        var sceneChangeEvent = @event as SceneChangeEvent;
        if (sceneChangeEvent == null)
        {
            Debug.LogError("SceneChangeEvent is null");
            return true;
        }

        var data = @event.GetData() as string;
        if (data == null)
        {
            Debug.LogError("data is null");
            return true;
        }

        try
        {
            this.currentScene = (SceneNames)Enum.Parse(typeof(SceneNames), data, ignoreCase: true);
            //Debug.LogWarning("change scene to " + this.currentScene );
        }
        catch
        {
            //Debug.Log("unable to parse");
            // do nothing
        }

        return true;
    }
    private IEnumerator Co_LoadScene(SceneNames sceneName)
    {
        if (isLoadingScene)
        {
            yield break;
        }
        isLoadingScene = true;
        ToggleLoadingScreen(true);
        yield return(new WaitForSeconds(1));

        //SceneManager.UnloadSceneAsync(scenes[activeScene]);
        AsyncOperation asOpLoader = SceneManager.LoadSceneAsync(scenes[sceneName], LoadSceneMode.Single);

        asOpLoader.completed += operation =>
        {
            activeScene = sceneName;
            SceneManager.SetActiveScene(SceneManager.GetSceneByName(scenes[sceneName]));
            isLoadingScene = false;
        };
        yield return(new WaitForSeconds(1));

        ToggleLoadingScreen(false);

        yield return(0);
    }
 /// <summary>
 /// Triggers a stateChange for the Application
 /// </summary>
 /// <param name="newScene"></param>
 public void TriggerStateChange(SceneNames newScene)
 {
     if (_OnSceneChange != null)
     {
         _OnSceneChange(newScene);
     }
 }
Exemple #7
0
    private int GetLoadingLevelIndex(string prompt)
    {
        switch (prompt)
        {
        case "Floor0":
            currentScene = SceneNames.Floor0;
            return(0);

        case "Floor1":
            currentScene = SceneNames.Floor1;
            return(1);

        case "Floor2":
            currentScene = SceneNames.Floor2;
            return(2);

        case "Floor3":
            currentScene = SceneNames.Floor3;
            return(3);

        case "FinalScene":
            currentScene = SceneNames.FinalScene;
            return(4);

        case "MainMenu":
            return(-1);

        default:
            return(-2);
        }
    }
    public bool HandleEvent(IEvent @event)
    {
        var sceneChangeEvent = @event as SceneChangeEvent;
        if (sceneChangeEvent == null)
        {
            return true;
        }

        var data = @event.GetData() as string;
        if (data == null)
        {
            return true;
        }

        try
        {
            this.currentScene = (SceneNames)Enum.Parse(typeof(SceneNames), data, ignoreCase: true);
        }
        catch
        {
            // do nothing
        }

        return true;
    }
Exemple #9
0
        public void SwitchScene(SceneNames scn, bool reinit = true)
        {
            Scene = scn;
            if (reinit)
            {
                switch (scn)
                {
                case SceneNames.INTRO: logoScene.Init(); break;

                case SceneNames.MENU: menuScene.Init(); break;

                case SceneNames.NEWGAME: newScene.Init(); break;

                case SceneNames.OVERWRITE: overScene.Init(); break;

                case SceneNames.LOADGAME: loadScene.Init(); break;

                case SceneNames.INVALID: invalidScene.Init(); break;

                case SceneNames.HIGHSCORE: highscoreScene.Init(); break;

                case SceneNames.EXIT: exitScene.Init(); break;

                case SceneNames.INGAME: ingameScene.Init(); break;

                case SceneNames.PAUSE: pauseSceene.Init(); break;
                }
            }
            PlayMusic();
        }
Exemple #10
0
    private void Awake()
    {
        // Create Init if it doesn't exist --> singleton
        if (Instance == null)
        {
            Instance = this;
        }
        else if (Instance == this)
        {
            Destroy(gameObject);
        }
        // Don't delete when switching scenes
        DontDestroyOnLoad(gameObject);

        // initialize the game strings instances
        SceneNames = new SceneNames();
        Tags       = new Tags();

        // initialize the unit selection manager instance and add it to the Init game object
        _unitSelectionManager = gameObject.AddComponent <UnitSelectionManager>();

        // initialize the player instance
        // PlayerData = gameObject.AddComponent<PlayerData>();

        // initialize camera controller
        _cameraController = gameObject.AddComponent <CameraController>();

        // finally, set up the game with the player progress
        SetUpGame();
    }
 public void ChangeFlows(SceneNames _flowToLoad)
 {
     flowInitialized = false;
     currentFlow.CloseFlow();
     currentFlow = CreateFlow(_flowToLoad);
     SceneManager.sceneLoaded += SceneLoaded;
 }
Exemple #12
0
 public void FillSceneNames()
 {
     SceneNames.Clear();
     foreach (var newScene in editorService.GetAllContentNamesByType(ContentType.Scene))
     {
         SceneNames.Add(newScene);
     }
 }
 public void LoadScene(SceneNames sceneName)
 {
     if (isLoadingScene)
     {
         return;
     }
     StartCoroutine(Co_LoadScene(sceneName));
 }
    private void UIViewState__OnSceneChange(SceneNames newScene)
    {
        bool isActive = (newScene == scene);

        Debug.Log("isSceneActive" + isActive);

        gameObject.SetActive(isActive);
    }
 public void InitializeFlowManager(SceneNames initialScene)
 {
     currentScene    = initialScene;
     currentFlow     = CreateFlow(initialScene);
     flowInitialized = true;
     currentFlow.InitializeFlow();
     FloorManager.Instance.Initialize();
     PlayerManager.Instance.Initialize();
 }
 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 #17
0
    /// <summary>
    /// Method that starts a coroutine to load the next scene.
    /// </summary>
    /// <param name="scene">Next scene to load</param>
    private void SetLoadingScene(SceneNames scene)
    {
        loadingScreen.gameObject.SetActive(true);

        if (loadSceneCoroutine == null)
        {
            loadSceneCoroutine = StartCoroutine(
                LoadNewScene(scene));
        }
    }
Exemple #18
0
    //Initialize FlowManager
    public void Initialize(SceneNames scene)
    {
        //Initialize first scene
        currentScene = scene;

        //Create Flow for the right scene
        currentFlow     = CreateFlow(scene);
        flowInitialized = true;
        currentFlow.InitializeFlow();
    }
Exemple #19
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 void DrawNewRecord()
    {
        float bestTime = SaveData.GetFloat("Stage" + SceneNames.GetStageNam(SceneManager.GetActiveScene().name) + "-" + SceneNames.GetFloorNam(SceneManager.GetActiveScene().name) + "ClearTime");

        //比較
        if (bestTime > time)
        {
            newRecord.gameObject.SetActive(true);
            StartCoroutine(NewRecordFade());
        }
    }
    // Use this for initialization
    void Start()
    {
        stageNameText.text       = FloorNameList.FLOOR_NAME[SceneNames.GetStageNam(SceneManager.GetActiveScene().name) - 1][SceneNames.GetFloorNam(SceneManager.GetActiveScene().name) - 1];
        stageNameTextShadow.text = FloorNameList.FLOOR_NAME[SceneNames.GetStageNam(SceneManager.GetActiveScene().name) - 1][SceneNames.GetFloorNam(SceneManager.GetActiveScene().name) - 1];

        towerImage.sprite      = towerImageSprite[SceneNames.GetStageNam(SceneManager.GetActiveScene().name) - 1];
        towerFloorImage.sprite = towerFloorImageSprite[SceneNames.GetStageNam(SceneManager.GetActiveScene().name) - 1];

        floorImage.sprite = floorImageSprite[SceneNames.GetFloorNam(SceneManager.GetActiveScene().name) - 1];
        baseY             = siroImage.rectTransform.localPosition.y;
        setTowerNam(0);
    }
    /// <summary>
    /// クリアタイムのセーブ
    /// </summary>
    public void SaveClearTime()
    {
        //元データ取り出し
        float bestTime = SaveData.GetFloat("Stage" + SceneNames.GetStageNam(SceneManager.GetActiveScene().name) + "-" + SceneNames.GetFloorNam(SceneManager.GetActiveScene().name) + "ClearTime");

        //比較
        if (bestTime > time)
        {
            //セーブ
            SaveData.SaveFloat("Stage" + SceneNames.GetStageNam(SceneManager.GetActiveScene().name) + "-" + SceneNames.GetFloorNam(SceneManager.GetActiveScene().name) + "ClearTime", time);
        }
    }
Exemple #23
0
    public static void InitializeModules(Balance balance, Timers timers, Localization localization, SceneNames sceneNames)
    {
        Balance      = balance;
        Timers       = timers;
        Localization = localization;
        SceneNames   = sceneNames;

        TSVReader   = new TSVReader();
        Pathfinding = new SimplePathfinding();

        Localization.Initialize();
    }
Exemple #24
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());
    }
Exemple #25
0
    /// <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;
    }
Exemple #26
0
    /// <summary>
    /// If the player is in vicinity of the door, another room is loaded and the current room is unloaded, bringing the player avatar to a new room.
    /// </summary>
    public void Enter()
    {
        if (this.isRandomDestination)
        {
            if (PedagogicalComponent_v2.Instance.CurrentTopic() == SceneTopic.NONE)
            {
                this.goingTo = SceneNames.BETA_TESTING_PRE_BOSS;
            }
            else
            {
                this.goingTo = SceneNames.RandomSceneName();

                if (GameController_v7.Instance.RoomCountCheck())
                {
                    this.goingTo = SceneNames.BETA_TESTING_RANDOM_END;
                }
            }
        }

        Debug.Log("Player Went In " + goingTo + " " + doorNumber);

//		spawnPointManager.UpdatePreviousScene (SceneManager.GetActiveScene ().name, this.doorNumber);
        GameController_v7.Instance.UpdatePreviousScene(SceneManager.GetActiveScene().name, this.doorNumber);
        GameController_v7.Instance.GetObjectStateManager().RecordPlayerStats();
        //		objectStateManager.RecordPlayerStats ();
        Parameters parameters = new Parameters();

        parameters.PutExtra("IS_HARD_SAVE", false);
        EventBroadcaster.Instance.PostEvent(EventNames.SAVE_DATA, parameters);
//		EventManager.RemoveHintOnTrigger ();
        EventBroadcaster.Instance.PostEvent(EventNames.REMOVE_HINT);
        EventManager.ResetTriggerSceneTitle();
                #if UNITY_ANDROID
//			EventManager.EnableBothButtons ();
                #endif
        //Load Scene Connected to this entrance.
        LoadingScreen loadingScreen = FindObjectOfType <LoadingScreen>();
        if (loadingScreen != null)
        {
            loadingScreen.LoadScene(goingTo, false);
        }
        else
        {
            Instantiate(loadingScreenPrefab);
        }
//			SceneManager.LoadScene (goingTo);
    }
Exemple #27
0
    private Flow CreateFlow(SceneNames flowToLoad)
    {
        Flow toRet = null;

        //Check the name of the scene to create the new flow
        switch (flowToLoad)
        {
        case SceneNames.MainMenu:
            toRet = new MainMenuFlow();
            break;

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

        default:
            Debug.Log("Unhandled switch " + flowToLoad);
            break;
        }
        return(toRet);
    }
    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 #29
0
    private Flow CreateFlow(SceneNames flowToLoad)
    {
        Flow toRet = null;

        //Check the name of the scene to create the new flow
        switch (flowToLoad)
        {
        case SceneNames.Lobby:
            toRet = new Flow();
            break;

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

        default:
            toRet = new GameFlow();
            break;
        }
        return(toRet);
    }
Exemple #30
0
    public void LoadLevelAsync(string sceneName)
    {
        int requestedIndex = GetLoadingLevelIndex(sceneName);

        if (requestedIndex >= 0)
        {
            TitleScreen.SetActive(false);
            isLoading = true;
            LoadingScreens[requestedIndex].SetActive(true);
            StartCoroutine(LoadAsynchronously(sceneName));
        }
        else if (requestedIndex == -1)
        {
            SceneManager.LoadScene("MainMenu");
            currentScene = SceneNames.MainMenu;
            TitleScreen.SetActive(true);
        }

        else
        {
            Debug.Log("Invalid scene name requested.");
        }
    }
Exemple #31
0
    void Start()
    {
        SceneNames sceneNames = new SceneNames();

        levelsScenesName = sceneNames.levelsScenesName;
        // levelsScenesName[0]="Tutorial_scene";
        // levelsScenesName[1]="SampleScene";

        Player = GameObject.Find("Player");
        GameObject canvas = GameObject.Find("Canvas");

        if (canvas != null)
        {
            GamePausedScreen = canvas.transform.GetChild(0).gameObject;
        }

        sceneActive = SceneManager.GetActiveScene();


        if (!sceneActive.name.Equals("titlescreen"))
        {
            StartCoroutine(TransitionAnimationIn());
        }
    }
Exemple #32
0
    public void ChangeScene(SceneNames scene)
    {
        string nameScene = "";

        switch (scene)
        {
        case SceneNames.MAIN_GAME:
            nameScene = "MainGame";
            break;

        case SceneNames.DIE_MENU_SCENE:
            nameScene = "DieScene";
            break;

        case SceneNames.SCOREBOARD:
            nameScene = "Scoreboard";
            break;
        }
        Debug.Log(nameScene);
        if (nameScene != "")
        {
            SceneManager.LoadScene(nameScene);
        }
    }
 /// <summary>
 /// Stores the running State
 /// </summary>
 /// <param name="newScene"></param>
 private void AppllicationSceneController__OnSceneChange(SceneNames newScene)
 {
     _model.RunningScene = newScene;
 }