Пример #1
0
        private void SetupSaveSlotScreen()
        {
            for (int i = 0; i < slotTexts.Length; i++)
            {
                int slot = i; // to conserve the slot index in the OnClick attribute.

                if (SaveLoadManager.CheckSlot(i))
                {
                    // Load data of the slot.
                    PlayerProgress progress = SaveLoadManager.LoadPlayerProgress(slot);

                    // Update treasures found.
                    treasuresParent[i].SetActive(progress.treasuresFound.Count > 0);
                    // foreach treasure... display it.

                    // Update slot information.
                    slotTexts[i].text = "Slot " + (slot + 1).ToString() + " - " + 0 + "%"; // TODO load completion percent.

                    moreInformationTexts[i].text = "Time : " + GetTimeFormated(progress.timePlayed);

                    moreInformationTexts[i].gameObject.SetActive(true);
                }

                else
                {
                    treasuresParent[i].SetActive(false);
                    moreInformationTexts[i].gameObject.SetActive(false);

                    // Update slot information.
                    slotTexts[i].text = "Slot " + (slot + 1).ToString() + " - empty";
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Load save slot selected.
        /// </summary>
        public void LoadPlayerProgress(int selectedSlot)
        {
            saveSlotSelected = selectedSlot;

            playerProgress = SaveLoadManager.LoadPlayerProgress(saveSlotSelected);

            LoadWorldMap();
        }
Пример #3
0
        // Delegate method triggered when a new scene is loaded.
        private void NewSceneLoaded(Scene arg0, LoadSceneMode arg1)
        {
            // Reset time scale if game was paused.
            Time.timeScale = 1.0f;

            // Reset information about the loaded scene.
            isMainMenu = false;
            mainMenu   = null;

            isWorldMap = false;
            worldmap   = null;

            levelMgr = null;

            AudioClip musicToPlay = null;

            // Setup transition manager of the current scene.
            ui = GameObject.FindGameObjectWithTag("UI");
            if (ui)
            {
                transitionManager = ui.transform.Find("TransitionPanel").GetComponent <TransitionManager>();
            }

            // Load main menu :
            if (arg0.buildIndex == mainMenuIndex)
            {
                // Here we can create new game or load existing game, we can also change settings...
                isMainMenu = true;

                mainMenu    = GameObject.Find("MainMenuUI").GetComponent <MainMenuManager>();
                musicToPlay = audioMgr.mainMenuMusic;
            }

            // Load world map :
            else if (arg0.buildIndex == worldMapIndex)
            {
                // Here we can move on the world map and enter in a level or access to an another world.

                isWorldMap = true;

                if (playerProgress != null)
                {
                    currentWorldIndex = playerProgress.currentWorldIndex;
                }

                // for debug only.
                else
                {
                    // Load first save.
                    playerProgress    = SaveLoadManager.LoadPlayerProgress(saveSlotSelected);
                    currentWorldIndex = playerProgress.currentWorldIndex;
                }

                worldmap = GameObject.Find("WorldMap").GetComponent <WorldMapManager>();
                StartCoroutine(worldmap.SetupMap(playerProgress));

                musicToPlay = audioMgr.worldMapMusic;
            }

            // Load a level :
            else
            {
                // Try to get the level manager of this level.
                GameObject levelManager = GameObject.FindGameObjectWithTag("LevelManager");
                if (levelManager)
                {
                    levelMgr = levelManager.GetComponent <LevelManager>();
                    levelMgr.StartCoroutine(levelMgr.DisplayLevelIntro(arg0.name));

                    musicToPlay = levelMgr.data.levelMusic;
                }
            }

            if (audioMgr)
            {
                audioMgr.PlayMusic(musicToPlay);
            }
            else
            {
                Debug.LogWarning("No audio manager found in this level.");
            }
        }