private void nextMiniGame()
    {
        this.currentTask = this.GetCurrentTask();
        if (this.currentTask != null)
        {
            this.currentType = this.currentTask.getType();
            switch (this.currentType)
            {
            case MiniGameEnum.ORGANIZE:
                this.infoMiniGame.setMiniGameInfo("ORGANIZE", "Your desk is a mess! Put each object in the box with the same object's color!!");
                break;

            case MiniGameEnum.STAMP:
                this.infoMiniGame.setMiniGameInfo("STAMP", "Stamp all the documents before the time runs out!!");
                break;

            case MiniGameEnum.CALCULATE:
                this.infoMiniGame.setMiniGameInfo("CALCULATE", "Your calculator is broken! Chose the correct answer according to the operation on your calculator!");
                break;

            case MiniGameEnum.REST:
                break;
            }
            this.showInfoMiniGame();
            this.infoMiniGame.startInfoMiniGame();
        }
        else
        {
            this.timeController.stopTimer();
            this.victory.gameObject.SetActive(true);
        }
    }
Пример #2
0
        void SetContent()
        {
            //if (AppConstants.VerboseLogging) Debug.Log(AppManager.I.NavigationManager.IsLoadingMinigame + " > " + AppManager.I.NavigationManager.CurrentMiniGameData);
            bool isLoadingMinigame = AppManager.I.NavigationManager.IsLoadingMinigame;

            Logo.gameObject.SetActive(!isLoadingMinigame);
            if (isLoadingMinigame)
            {
                MiniGameData mgData = AppManager.I.NavigationManager.CurrentMiniGameData;
                Icon.sprite = AppManager.I.AssetManager.GetMainIcon(mgData);
                Sprite badgeSprite = AppManager.I.AssetManager.GetBadgeIcon(mgData);
                if (badgeSprite == null)
                {
                    Badge.gameObject.SetActive(false);
                }
                else
                {
                    Badge.gameObject.SetActive(true);
                    BadgeIcon.sprite = badgeSprite;
                }
            }
            else
            {
                Badge.gameObject.SetActive(isLoadingMinigame);
                Icon.sprite = defIcon;
            }
        }
        void SetContent()
        {
            if (AppConstants.VerboseLogging)
            {
                Debug.Log(NavigationManager.I.IsLoadingMinigame + " > " + NavigationManager.I.CurrentScene);
            }
            bool isLoadingMinigame = NavigationManager.I.IsLoadingMinigame;

            Logo.gameObject.SetActive(!isLoadingMinigame);
            if (isLoadingMinigame)
            {
                MiniGameData mgData = AppManager.I.CurrentMinigame;
                Icon.sprite = Resources.Load <Sprite>(mgData.GetIconResourcePath());
                Sprite badgeSprite = Resources.Load <Sprite>(mgData.GetBadgeIconResourcePath());
                if (badgeSprite == null)
                {
                    Badge.gameObject.SetActive(false);
                }
                else
                {
                    Badge.gameObject.SetActive(true);
                    BadgeIcon.sprite = badgeSprite;
                }
            }
            else
            {
                Badge.gameObject.SetActive(isLoadingMinigame);
                Icon.sprite = defIcon;
            }
        }
Пример #4
0
        /// <summary>
        /// Prepare all context needed and starts the game.
        /// </summary>
        /// <param name="_gameCode">The game code.</param>
        /// <param name="_gameConfiguration">The game configuration.</param>
        public void StartGame(MiniGameCode _gameCode, GameConfiguration _gameConfiguration)
        {
            if (AppConstants.VerboseLogging)
            {
                Debug.Log("StartGame " + _gameCode.ToString());
            }

            MiniGameData       miniGameData      = AppManager.I.DB.GetMiniGameDataByCode(_gameCode);
            IQuestionBuilder   rules             = null;
            IGameConfiguration currentGameConfig = null;

            currentGameConfig = GetGameConfigurationForMiniGameCode(_gameCode);

            // game difficulty
            currentGameConfig.Difficulty = _gameConfiguration.Difficulty;
            // rule setted in config and used by AI to create correct game data
            rules = currentGameConfig.SetupBuilder();
            // question packs (game data)
            currentGameConfig.Questions = new FindRightLetterQuestionProvider(AppManager.I.GameLauncher.RetrieveQuestionPacks(rules), miniGameData.Description);

            // Save current game code to appmanager currentminigame
            AppManager.I.CurrentMinigame = miniGameData;
            // Comunicate to LogManager that start new single minigame play session.
            currentGameConfig.Context.GetLogManager().InitGameplayLogSession(_gameCode);

            // Call game start
            //NavigationManager.I.GoToNextScene();
            NavigationManager.I.GoToScene(miniGameData.Scene);
        }
Пример #5
0
        void ResetAndLayout()
        {
            // Reset
            if (mainBubble == null)
            {
                mainBubble = this.GetComponentInChildren <GamesSelectorBubble>();
            }
            foreach (GamesSelectorBubble bubble in bubbles)
            {
                if (bubble != mainBubble)
                {
                    Destroy(bubble.gameObject);
                }
            }
            bubbles.Clear();

            // Layout
            const float bubblesDist = 0.1f;
            int         totBubbles  = games.Count;
            float       bubbleW     = mainBubble.Main.GetComponent <Renderer>().bounds.size.x;
            float       area        = totBubbles * bubbleW + (totBubbles - 1) * bubblesDist;
            float       startX      = -area * 0.5f + bubbleW * 0.5f;

            //if (!LanguageSwitcher.LearningRTL) startX *= -1;

            for (int i = 0; i < totBubbles; ++i)
            {
                int iRTL = LanguageSwitcher.LearningRTL ? totBubbles - i - 1 : i;

                MiniGameData        mgData = games[iRTL];
                GamesSelectorBubble bubble = i == 0 ? mainBubble : (GamesSelectorBubble)Instantiate(mainBubble, this.transform);
                bubble.Setup(AppManager.I.AssetManager.GetMainIcon(mgData), AppManager.I.AssetManager.GetBadgeIcon(mgData), startX + (bubbleW + bubblesDist) * i);
                bubbles.Add(bubble);
            }
        }
Пример #6
0
        void ResetAndLayout()
        {
            // Reset
            if (mainBubble == null)
            {
                mainBubble = this.GetComponentInChildren <GamesSelectorBubble>();
            }
            foreach (GamesSelectorBubble bubble in bubbles)
            {
                if (bubble != mainBubble)
                {
                    Destroy(bubble.gameObject);
                }
            }
            bubbles.Clear();

            // Layout
            const float bubblesDist = 0.1f;
            int         totBubbles  = games.Count;
            float       bubbleW     = mainBubble.Main.GetComponent <Renderer>().bounds.size.x;
            float       area        = totBubbles * bubbleW + (totBubbles - 1) * bubblesDist;
            float       startX      = -area * 0.5f + bubbleW * 0.5f;

            for (int i = 0; i < totBubbles; ++i)
            {
                MiniGameData        mgData = games[i];
                GamesSelectorBubble bubble = i == 0 ? mainBubble : (GamesSelectorBubble)Instantiate(mainBubble, this.transform);
                bubble.Setup(mgData.GetIconResourcePath(), mgData.GetBadgeIconResourcePath(), startX + (bubbleW + bubblesDist) * i);
                bubbles.Add(bubble);
            }
        }
Пример #7
0
        public void EndsessionResult_Show(int _totMinigamesStars)
        {
            GameResultUI.HideEndgameResult();

            MiniGameData d0 = new MiniGameData()
            {
                Main = MiniGameCode.Maze_lettername.ToString(), Variation = "letters"
            };
            MiniGameData d1 = new MiniGameData()
            {
                Main = MiniGameCode.DancingDots_lettername.ToString(), Variation = "alphabet"
            };
            MiniGameData d2 = new MiniGameData()
            {
                Main = MiniGameCode.MakeFriends_letterinword.ToString(), Variation = "counting"
            };
            List <EndsessionResultData> res = new List <EndsessionResultData>()
            {
                new EndsessionResultData(2, d0),
                new EndsessionResultData(0, d1),
                new EndsessionResultData(3, d2),
            };

            for (int i = 0; i < 3; ++i)
            {
                int num = Mathf.Min(3, _totMinigamesStars);
                _totMinigamesStars -= num;
                res[i].Stars        = num;
            }
            int rndUnlocked = UnityEngine.Random.Range(0, 3);

            Debug.Log("ShowEndsessionResult > " + rndUnlocked);
            GameResultUI.ShowEndsessionResult(res, rndUnlocked);
        }
Пример #8
0
	private string GetRandomMiniGame ()
	{
		int index = UnityEngine.Random.Range ( 0,this.miniGames.Count-1 );
		CurrentMiniGame = this.miniGames [index];
		CurrentGameIndex = index;
		return CurrentMiniGame.miniGameName;
	}
Пример #9
0
	private string GetNextMiniGame ()
	{
		string miniGameName = this.miniGames [miniGamesView].miniGameName;
		CurrentMiniGame = this.miniGames [miniGamesView];
		CurrentGameIndex = miniGamesView;
		miniGamesView++;
		return miniGameName;
	}
Пример #10
0
    private string GetRandomMiniGame()
    {
        int index = UnityEngine.Random.Range(0, this.miniGames.Count - 1);

        CurrentMiniGame  = this.miniGames [index];
        CurrentGameIndex = index;
        return(CurrentMiniGame.miniGameName);
    }
Пример #11
0
        public void DetailMiniGame(MiniGameInfo selectedGameInfo)
        {
            if (selectedGameInfo == null)
            {
                currentMiniGame  = null;
                ArabicText.text  = "";
                EnglishText.text = "";
                //ScoreText.text = "";
                MiniGameLogoImage.enabled  = false;
                MiniGameBadgeImage.enabled = false;
                LaunchGameButton.gameObject.SetActive(false);
                DetailPanel.SetActive(false);
                return;
            }

            DetailPanel.SetActive(true);
            currentMiniGame = selectedGameInfo.data;
            VariationsContainer.BroadcastMessage("Select", selectedGameInfo, SendMessageOptions.DontRequireReceiver);

            AudioManager.I.PlayDialogue(selectedGameInfo.data.GetTitleSoundFilename());

            ArabicText.text  = selectedGameInfo.data.Title_Ar;
            EnglishText.text = selectedGameInfo.data.Title_En;

            //var Output = "";
            //Output += "Score: " + selectedGameInfo.score;
            //Output += "\nPlayed: ";
            //ScoreText.text = Output;

            // Launch button
            if (!AppManager.I.NavigationManager.PrevSceneIsReservedArea() &&
                (selectedGameInfo.unlocked || AppManager.I.Player.IsDemoUser))
            {
                LaunchGameButton.gameObject.SetActive(true);
                LaunchGameButton.interactable = true;
            }
            else
            {
                LaunchGameButton.gameObject.SetActive(false);
                LaunchGameButton.interactable = false;
            }

            // Set icon
            var icoPath   = currentMiniGame.GetIconResourcePath();
            var badgePath = currentMiniGame.GetBadgeIconResourcePath();

            MiniGameLogoImage.sprite  = Resources.Load <Sprite>(icoPath);
            MiniGameLogoImage.enabled = true;
            if (badgePath != "")
            {
                MiniGameBadgeImage.enabled = true;
                MiniGameBadgeImage.sprite  = Resources.Load <Sprite>(badgePath);
            }
            else
            {
                MiniGameBadgeImage.enabled = false;
            }
        }
Пример #12
0
    private string GetNextMiniGame()
    {
        string miniGameName = this.miniGames [miniGamesView].miniGameName;

        CurrentMiniGame  = this.miniGames [miniGamesView];
        CurrentGameIndex = miniGamesView;
        miniGamesView++;
        return(miniGameName);
    }
Пример #13
0
        // TODO refactor: scene names should match AppScene so that this can be removed
        public static string GetSceneName(AppScene scene, MiniGameData minigameData = null)
        {
            switch (scene)
            {
            case AppScene.Bootstrap:
                return("app_Bootstrap");

            case AppScene.Home:
                return("app_Home");

            case AppScene.AnturaSpace:
                return("app_AnturaSpace");

            case AppScene.Book:
                return("app_Book");

            case AppScene.Map:
                return("app_Map");

            case AppScene.Mood:
                return("app_Mood");

            case AppScene.GameSelector:
                return("app_GamesSelector");

            case AppScene.Intro:
                return("app_Intro");

            case AppScene.MiniGame:
                return(minigameData.Scene);

            case AppScene.PlayerCreation:
                return("app_PlayerCreation");

            case AppScene.PlaySessionResult:
                return("app_PlaySessionResult");

            case AppScene.Rewards:
                return("app_Rewards");

            case AppScene.ReservedArea:
                return("app_ReservedArea");

            case AppScene.Ending:
                return("app_Ending");

            case AppScene.DailyReward:
                return("app_DailyReward");

            case AppScene.Kiosk:
                return("app_Kiosk");

            default:
                return("");
            }
        }
Пример #14
0
    public static void SaveMiniGameData(int miniGameState, int playerIndex, int tileNum)
    {
        BinaryFormatter formatter    = new BinaryFormatter();
        string          path         = Application.persistentDataPath + "/MiniGameData.fun";
        FileStream      stream       = new FileStream(path, FileMode.Create);
        MiniGameData    miniGameData = new MiniGameData(miniGameState, playerIndex, tileNum);

        formatter.Serialize(stream, miniGameData);
        stream.Close();
    }
Пример #15
0
        public void DetailMiniGame(MiniGameInfo info)
        {
            if (info == null)
            {
                currentMiniGame            = null;
                ScoreText.text             = "";
                MiniGameLogoImage.enabled  = false;
                MiniGameBadgeImage.enabled = false;
                LaunchGameButton.gameObject.SetActive(false);
                return;
            }

            currentMiniGame = info.data;
            AudioManager.I.PlayDialog(info.data.GetTitleSoundFilename());

            var Output = "";

            Output        += "Score: " + info.score;
            Output        += "\nPlayed: ";
            ScoreText.text = Output;

            // Launch button
            if (info.unlocked || AppManager.I.GameSettings.CheatSuperDogMode)
            {
                LaunchGameButton.gameObject.SetActive(true);
                LaunchGameButton.interactable = true;
            }
            else
            {
                LaunchGameButton.gameObject.SetActive(false);
                LaunchGameButton.interactable = false;
            }

            // Set icon
            var icoPath   = currentMiniGame.GetIconResourcePath();
            var badgePath = currentMiniGame.GetBadgeIconResourcePath();

            MiniGameLogoImage.sprite  = Resources.Load <Sprite>(icoPath);
            MiniGameLogoImage.enabled = true;
            if (badgePath != "")
            {
                MiniGameBadgeImage.enabled = true;
                MiniGameBadgeImage.sprite  = Resources.Load <Sprite>(badgePath);
            }
            else
            {
                MiniGameBadgeImage.enabled = false;
            }
        }
Пример #16
0
    /// <summary>
    /// Save the result of the mini game to a persistent file, and then load the main scene
    /// </summary>
    /// <param name="isSuccessful"></param>
    public static void UpdateMiniGameData(bool isSuccessful)
    {
        MiniGameData miniGameData = SaveSystem.LoadMiniGameData();

        if (isSuccessful)
        {
            miniGameData.state = 1;
        }
        else
        {
            miniGameData.state = 2;
        }
        SaveSystem.SaveMiniGameData(miniGameData.state, miniGameData.playerIndex, miniGameData.tileNum);

        //Always go back to the main scene after saving the mini game data
    }
Пример #17
0
        public void OpenBook(BookArea area, MiniGameData directMiniGameData = null)
        {
            // TODO maybe first check if Book is already isntatiated!
            BookInstance = Instantiate(Resources.Load(RESOURCES_BOOK, typeof(GameObject))) as GameObject;
            AppManager.I.ModalWindowActivated = true;
            Book.I.OpenArea(area);

            if (directMiniGameData != null)
            {
                var mainMiniGamesList = MiniGamesUtilities.GetMainMiniGameList();
                var mainMiniGame      = mainMiniGamesList.FirstOrDefault(game => game.MainId == directMiniGameData.Main);
                var gamesPanel        = FindObjectOfType <GamesPanel>();
                gamesPanel.DetailMainMiniGame(mainMiniGame);
                gamesPanel.DetailMiniGame(mainMiniGame.variations.FirstOrDefault(var => var.data == directMiniGameData));
            }
        }
Пример #18
0
        public void InitNewPlaySession(MiniGameData dataToUse = null)
        {
            ResetEndSessionResults();
            NavData.RealPlaySession = (dataToUse == null);

            AppManager.I.Teacher.InitNewPlaySession();
            NavData.SetFirstMinigame();

            if (NavData.RealPlaySession)
            {
                NavData.CurrentPlaySessionMiniGames = AppManager.I.Teacher.SelectMiniGames();
            }
            else
            {
                NavData.CurrentPlaySessionMiniGames = new List <MiniGameData>();
                NavData.CurrentPlaySessionMiniGames.Add(dataToUse);
            }
        }
Пример #19
0
        public void InitNewPlaySession(bool directMiniGame = false, MiniGameData dataToUse = null)
        {
            ResetEndSessionResults();
            NavData.IsJourneyPlaySession = !directMiniGame;
            NavData.DirectMiniGameData   = dataToUse;

            AppManager.I.Teacher.InitNewPlaySession();
            NavData.SetFirstMinigame();

            if (NavData.IsJourneyPlaySession)
            {
                NavData.CurrentPlaySessionMiniGames = AppManager.I.Teacher.SelectMiniGames();
            }
            else
            {
                NavData.CurrentPlaySessionMiniGames = new List <MiniGameData>();
                NavData.CurrentPlaySessionMiniGames.Add(dataToUse);
            }
        }
Пример #20
0
    public static MiniGameData LoadMiniGameData()
    {
        string path = Application.persistentDataPath + "/MiniGameData.fun";

        if (File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream      stream    = new FileStream(path, FileMode.Open);

            MiniGameData miniGameData = formatter.Deserialize(stream) as MiniGameData;

            stream.Close();
            return(miniGameData);
        }
        else
        {
            return(null);
        }
    }
Пример #21
0
        /// <summary>
        /// Launches the game scene.
        /// </summary>
        /// <param name="_miniGame">The mini game.</param>
        private void InternalLaunchGameScene(MiniGameData _miniGame, MinigameLaunchConfiguration _launchConfig = null, bool useLastConfig = false)
        {
            WorldManager.I.CurrentWorld = (WorldID)(NavData.CurrentPlayer.CurrentJourneyPosition.Stage - 1);

            // Ask the teacher for a config, if needed
            if (useLastConfig)
            {
                _launchConfig = AppManager.I.GameLauncher.LastLaunchConfig;
            }
            else if (_launchConfig == null)
            {
                var teacher         = AppManager.I.Teacher;
                var difficulty      = teacher.GetCurrentDifficulty(_miniGame.Code);
                var numberOfRounds  = teacher.GetCurrentNumberOfRounds(_miniGame.Code);
                var tutorialEnabled = teacher.GetTutorialEnabled(_miniGame.Code);
                _launchConfig = new MinigameLaunchConfiguration(difficulty, numberOfRounds, tutorialEnabled, insideJourney: true);
            }
            AppManager.I.GameLauncher.LaunchGame(_miniGame.Code, _launchConfig);
        }
Пример #22
0
        private void GoToScene(AppScene wantedNewScene, MiniGameData minigameData = null, bool debugMode = false)
        {
            AppScene filteredNewScene = wantedNewScene;

            if (!debugMode)
            {
                bool keepPrevAsBackable = false;
                filteredNewScene = FirstContactManager.I.FilterNavigation(GetCurrentScene(), wantedNewScene, out keepPrevAsBackable);
                if (keepPrevAsBackable)
                {
                    UpdatePrevSceneStack(wantedNewScene);
                }

                if (FirstContactManager.I.IsSequenceFinished())
                {
                    // Additional general checks when entering specific scenes
                    switch (filteredNewScene)
                    {
                    case AppScene.Map:
                        // When coming back to the map, we need to check whether a new daily reward is needed
                        if (CheckDailySceneTrigger())
                        {
                            GoToScene(AppScene.Mood);
                            return;
                        }
                        break;
                    }
                }
            }

            // Scene switch
            UpdatePrevSceneStack(filteredNewScene);
            NavData.CurrentScene = filteredNewScene;

            // check to have closed any possible Keeper Dialog
            KeeperManager.I.ResetKeeper();

            GoToSceneByName(SceneHelper.GetSceneName(filteredNewScene, minigameData));
        }
Пример #23
0
 public Sprite GetMainIcon(MiniGameData data)
 {
     return(GetSprite("Ico", data.Main));
 }
Пример #24
0
 public void EndMiniGame()
 {
     CurrentMiniGame.state = MiniGameState.NotPlayed;
     CurrentMiniGame       = null;
 }
Пример #25
0
 public void SetMiniGameByIndex(int indexMiniGame, MiniGameState miniGameState, int miniGamesViewed)
 {
     this.miniGamesView    = miniGamesViewed;
     CurrentMiniGame       = this.miniGames [indexMiniGame];
     CurrentMiniGame.state = miniGameState;
 }
 public void GoToGameScene(MiniGameData _miniGame)
 {
     AppManager.I.GameLauncher.LaunchGame(_miniGame.Code);
 }
Пример #27
0
        public void DetailMiniGame(MiniGameInfo selectedGameInfo)
        {
            if (selectedGameInfo == null)
            {
                currentMiniGame            = null;
                GameTitle.text             = "";
                MiniGameLogoImage.enabled  = false;
                MiniGameBadgeImage.enabled = false;
                LaunchGameButton.gameObject.SetActive(false);
                DetailPanel.SetActive(false);
                return;
            }

            DetailPanel.SetActive(true);

            if (currentMiniGame?.Main != selectedGameInfo.data.Main)
            {
                // only first time we see a new main minigame
                KeeperManager.I.PlayDialogue(selectedGameInfo.data.GetTitleSoundFilename(), false, true, null, KeeperMode.LearningNoSubtitles);
            }
            currentMiniGame = selectedGameInfo.data;

            VariationsContainer.BroadcastMessage("Select", selectedGameInfo, SendMessageOptions.DontRequireReceiver);
            GameTitle.text = selectedGameInfo.data.GetFullTitle(true);

            //var Output = "";
            //Output += "Score: " + selectedGameInfo.score;
            //Output += "\nPlayed: ";
            //ScoreText.text = Output;

            // Launch button
            if (!AppManager.I.NavigationManager.PrevSceneIsReservedArea() &&
                (selectedGameInfo.unlocked || AppManager.I.Player.IsDemoUser))
            {
                LaunchGameButton.gameObject.SetActive(true);
                LaunchGameButton.interactable = true;
            }
            else
            {
                LaunchGameButton.gameObject.SetActive(false);
                LaunchGameButton.interactable = false;
            }

            // Set icon
            var icon  = AppManager.I.AssetManager.GetMainIcon(currentMiniGame);
            var badge = AppManager.I.AssetManager.GetBadgeIcon(currentMiniGame);

            MiniGameLogoImage.sprite  = icon;
            MiniGameLogoImage.enabled = true;

            if (badge != null)
            {
                MiniGameBadgeImage.enabled = true;
                MiniGameBadgeImage.sprite  = badge;
            }
            else
            {
                MiniGameBadgeImage.enabled = false;
            }

            Debug.Log($"MiniGame selected: {selectedGameInfo.data.Code}");
        }
Пример #28
0
 /// <summary>
 /// Data for a minigame played during the session
 /// </summary>
 /// <param name="_stars">Total stars gained</param>
 /// <param name="_miniGameData">Data of the minigame that was played</param>
 public EndsessionResultData(int _stars, MiniGameData _miniGameData)
 {
     Stars        = _stars;
     MiniGameData = _miniGameData;
 }
Пример #29
0
 /// <summary>
 /// Launches the game scene.
 /// </summary>
 /// <param name="_miniGame">The mini game.</param>
 private void InternalLaunchGameScene(MiniGameData _miniGame)
 {
     AppManager.I.GameLauncher.LaunchGame(_miniGame.Code);
 }
Пример #30
0
	public void EndMiniGame ()
	{
		CurrentMiniGame.state = MiniGameState.NotPlayed;
		CurrentMiniGame = null;
	}
Пример #31
0
	public void SetMiniGameByIndex (int indexMiniGame, MiniGameState miniGameState,int miniGamesViewed)
	{
		this.miniGamesView = miniGamesViewed;
		CurrentMiniGame = this.miniGames [indexMiniGame];
		CurrentMiniGame.state = miniGameState;
	}
Пример #32
0
 public Sprite GetBadgeIcon(MiniGameData data)
 {
     return(GetSprite("BadgeIco", data.Badge));
 }
Пример #33
0
    /// <summary>
    /// This is used in the beginning of the GameManager to load game information to put players in place
    /// If there is no game progress, meaning that the player hasn't started the game, then load all the player to the first tile
    /// </summary>
    /// <returns></returns>
    private bool LoadGameProgress()
    {
        MainGameData mainGameData = SaveSystem.LoadMainGameData();

        if (mainGameData == null)
        {
            Debug.LogError("There is no main game data");
            // Player hasn't save anything yet
            return(false);
        }

        gameMode = (GameMode)(mainGameData.playerNum - 1);
        players  = new Player[4];
        for (int i = 0; i < players.Length; i++)
        {
            GameObject player = Instantiate(ResourceManager.Instance.players[i], gameBoard.wayPoints[mainGameData.playersPositionsIndexes[i]].position, Quaternion.identity);
            players[i] = player.GetComponent <Player>();
            players[i].PositionIndex = mainGameData.playersPositionsIndexes[i];
        }


        switch (mainGameData.playerTurnIndex)
        {
        case 0:
            gameTurnState = GameTurnState.Player1Turn;
            break;

        case 1:
            gameTurnState = GameTurnState.Player2Turn;
            break;

        case 2:
            gameTurnState = GameTurnState.Player3Turn;
            break;

        case 3:
            gameTurnState = GameTurnState.Player4Turn;
            break;
        }



        for (int i = 0; i < players.Length; i++)
        {
            players[i].playerIndex = i + 1;
        }

        foreach (var player in players)
        {
            player.onPlayerMovementFinished += ToggleGameState;
            player.onPlayerMovementFinished += AiBeginMoving;
        }


        MiniGameData miniGameData = SaveSystem.LoadMiniGameData();

        if (miniGameData != null)    // If the player comes back from the mini game
        {
            switch (miniGameData.playerIndex)
            {
            case 1:
                gameTurnState = GameTurnState.Player1Turn;
                break;

            case 2:
                gameTurnState = GameTurnState.Player2Turn;
                break;

            case 3:
                gameTurnState = GameTurnState.Player3Turn;
                break;

            case 4:
                gameTurnState = GameTurnState.Player4Turn;
                break;
            }

            if (miniGameData.state == 1)    // Success
            {
                GetPlayerInTurn().MoveTiles(miniGameData.tileNum);
            }
            else if (miniGameData.state == 2)    // Failure
            {
                GetPlayerInTurn().MoveTiles(-miniGameData.tileNum);
            }
        }
        else
        {
            Debug.LogWarning("There is no mini game data yet (Ignore it if this shows in the beginning of the game)");
        }



        return(true);
    }