Пример #1
0
        public void OnSceneLoadStarted()
        {
            StateCtrl.ChangeGameState(GameState.LOADING);

            gameManagerCanvas.Activate(true);
            gameManagerCamera.gameObject.SetActive(true);
        }
Пример #2
0
        public void OnLevelEnd(LevelResults result)
        {
            InputCtrl.isInputsLocked = true;
            StateCtrl.ChangeGameState(GameState.ENDMENU);
            if (result == LevelResults.VICTORY)
            {
                Database.levelsCompletionStatue[SceneCtrl.CurrentLevelNo] = true; // complete current level, unlock next level.
            }
            Database.Save(Database.LevelsFile);

            StartCoroutine(OnLevelEndCor(result));
        }
Пример #3
0
        private void Awake()
        {
            // Only one instance of the GameManager can exist.
            if (Cur == null)
            {
                Cur = this;
            }
            else
            {
                Destroy(gameObject);
            }

            // Get all components of this game object.
            if (Database == null)
            {
                Database = GetComponent <Database>();
            }
            if (EventCtrl == null)
            {
                EventCtrl = GetComponent <EventCtrl>();
            }
            if (AudioCtrl == null)
            {
                AudioCtrl = GetComponent <AudioCtrl>();
            }
            if (StateCtrl == null)
            {
                StateCtrl = GetComponent <StateCtrl>();
            }
            if (SceneCtrl == null)
            {
                SceneCtrl = GetComponent <SceneCtrl>();
            }
            if (InputCtrl == null)
            {
                InputCtrl = GetComponent <InputCtrl>();
            }
            if (SettingCtrl == null)
            {
                SettingCtrl = GetComponent <SettingCtrl>();
            }

            // If open scene count is more than 1, unload all scenes and load the GameManager scene.
            #if UNITY_EDITOR
            if (SceneManager.sceneCount > 1)
            {
                Debug.Log("RESTARTING: Game Manager!");
                SceneManager.LoadScene(SceneCtrl.gameManagerSceneData.BuildIndex, LoadSceneMode.Single);
                return;
            }
            #endif

            PauseFrameRate();
            StateCtrl.ChangeGameState(GameState.LOADING);

            // Create levels dictionary to write saved file data in it.
            Database.CreateLevelsDictionary();

            // Create save files` directory.
            Storage.CreateGameDirectories();
            // Load the saved data at the start of the game.
            Database.Load(Database.LevelsFile);
            Database.Load(Database.OptionsFile);
        }
Пример #4
0
 public void OnPausePanelClosed()
 {
     StateCtrl.ChangeGameState(GameState.PLAYLEVEL);
     UnpauseFrameRate();
 }
Пример #5
0
 public void OnPausePanelOpened()
 {
     StateCtrl.ChangeGameState(GameState.PAUSEMENU);
     PauseFrameRate();
 }