public void LoadGame() { Debug.Log("--[ Loading game ]--"); GameData data = _saveSystem.Load(); // Loads highscores and sets them to the scoreboard HighscoreList.LoadHighscores(data); LoadPlayerName(); Settings.Instance.Load(); Debug.Log("--[ Game loaded ]--"); }
private void Start() { _eventSystem = FindObjectOfType <EventSystem>(); _stateManager = FindObjectOfType <StateManager>(); _confirmation = GetComponentInChildren <ConfirmationDialog>(); _highscoreList = GameManager.Instance.HighscoreList; _cursor = FindObjectOfType <MouseCursorController>(); _heatMap = FindObjectOfType <HeatMap>(); _kantelePanel = FindObjectOfType <KanteleHeroPanel>(); _collSpawner = FindObjectOfType <CollectableSpawner>(); // Allows the cursor to select the current menu's // default selected button when it is hidden _cursor.SelectMenuButtonAction = SelectDefaultSelectedMenuButton; // Hides the scoreboard by default _highscoreList.Visible = false; // Registers to listen to the GameOver event. // When the GameOver event is triggered, the first // button in the game over menu is highlighted _stateManager.GameOver += HighlightGameOverMenuButton; //// Registers to listen to the PauseMenuActivated event. //// Makes the scoreboard visible and doesn't allow //// hiding it in the pause menu //_stateManager.PauseMenuActivated += PauseMenuEntered; //// Registers to listen to the PauseMenuDeactivated event. //// Changes the scoreboard's visibility to what it //// was before accessing the pause menu //_stateManager.PauseMenuDeactivated += PauseMenuExited; // Registers to listen to the ScreenStateChanged event. _stateManager.ScreenStateChanged += OnScreenStateChanged; OnScreenStateChanged(ScreenStateType.MainMenu); L10n.LanguageLoaded += OnLanguageLoaded; OnLanguageLoaded(); #if UNITY_EDITOR _debugEnabled = true; #else _debugEnabled = false; #endif }
//private void InitFade() //{ // fade = FindObjectOfType<FadeToColor>(); // if (fade == null) // { // Debug.LogError("Could not find a FadeToColor " + // "object in the scene."); // } //} //private void ResetFade() //{ // if (fade != null) // { // fade = null; // } //} //public bool ClearFade //{ // get // { // return (fade == null || fade.FadedIn); // } //} /// <summary> /// Gets highscore data and stores it to a data object. /// </summary> /// <param name="saveMessage">A printed message</param> public void SaveGame(string saveMessage = "Saving game") { // Default save message if (saveMessage.Length == 0) { saveMessage = "Saving game"; } // Prints the save message Debug.Log("--[ " + saveMessage + " ]--"); GameData data = new GameData(); // Gets highscores and stores them to the data HighscoreList.FetchHighscoreData(data); _saveSystem.Save(data); // Prints a save success message Debug.Log("--[ Saved ]--"); }
private void Init() { // Initializes the highscore list _highscoreList = FindObjectOfType <HighscoreList>(); if (_highscoreList == null) { Debug.LogError("HighscoreList object not found in the scene."); } // Initializes localization InitLocalization(); // Initializes the save system and loads data _saveSystem = new SaveSystem(new JSONPersistence(SavePath)); LoadGame(); // Initializes states _stateManager = FindObjectOfType <StateManager>(); if (_stateManager != null) { _stateManager.Init(); } else { Debug.LogError("StateManager object not found in the scene."); } _playfield = FindObjectOfType <Playfield>(); if (_playfield == null) { Debug.LogError("Playfield object not found in the scene."); } _collectableSpawner = FindObjectOfType <CollectableSpawner>(); _cameraCtrl = FindObjectOfType <CameraController>(); DontDestroyOnLoad(gameObject); }
private void Start() { _highscores = GameManager.Instance.HighscoreList; ResetScore(); }