예제 #1
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);
        }
예제 #2
0
        /// <summary>
        /// Prepare the context and start a minigame.
        /// </summary>
        /// <param name="gameCode">The minigame code.</param>
        /// <param name="launchConfig">The launch configuration. If null, the Teacher will generate a new one.</param>
        public void LaunchGame(MiniGameCode gameCode, MinigameLaunchConfiguration launchConfig)
        {
            LastLaunchConfig = launchConfig;

            ConfigAI.StartTeacherReport();

            var miniGameData = AppManager.I.DB.GetMiniGameDataByCode(gameCode);

            if (launchConfig.DirectGame)
            {
                AppManager.I.NavigationManager.InitNewPlaySession(true, miniGameData);
            }

            if (ApplicationConfig.I.DebugLogEnabled)
            {
                Debug.Log("StartGame " + gameCode.ToString());
                Debug.Log(launchConfig);
            }

            // Assign the configuration for the given minigame
            var minigameSession = DateTime.Now.Ticks.ToString();

            currentGameConfig = ConfigureMiniGameScene(gameCode, minigameSession, launchConfig);

            // Retrieve the packs for the current minigame configuration
            currentQuestionBuilder      = currentGameConfig.SetupBuilder();
            currentQuestionPacks        = questionPacksGenerator.GenerateQuestionPacks(currentQuestionBuilder);
            currentGameConfig.Questions = new SequentialQuestionPackProvider(currentQuestionPacks);

            // Communicate to LogManager the start of a new single minigame play session.
            if (AppConfig.DebugLogDbInserts)
            {
                Debug.Log("InitGameplayLogSession " + gameCode.ToString());
            }
            LogManager.I.LogInfo(InfoEvent.GameStart, "{\"minigame\":\"" + gameCode.ToString() + "\"}");
            LogManager.I.StartMiniGame();

            // Print the teacher's report now
            ConfigAI.PrintTeacherReport();

            // Play the title dialog for the game
            //AudioManager.I.PlayDialogue(_gameCode.ToString()+"_Title");

            // Launch the game
            AppManager.I.NavigationManager.GoToMiniGameScene();
        }
예제 #3
0
        /// <summary>
        /// Prepare the context and start a minigame.
        /// </summary>
        /// <param name="_gameCode">The minigame code.</param>
        /// <param name="_launchConfiguration">The launch configuration. If null, the Teacher will generate a new one.</param>
        /// <param name="forceNewPlaySession">Is this a new play session?</param>
        public void LaunchGame(MiniGameCode _gameCode, MinigameLaunchConfiguration _launchConfiguration = null,
                               bool forceNewPlaySession = false)
        {
            ConfigAI.StartTeacherReport();
            if (_launchConfiguration == null)
            {
                var difficulty      = teacher.GetCurrentDifficulty(_gameCode);
                var numberOfRounds  = teacher.GetCurrentNumberOfRounds(_gameCode);
                var tutorialEnabled = teacher.GetTutorialEnabled(_gameCode);
                _launchConfiguration = new MinigameLaunchConfiguration(difficulty, numberOfRounds, tutorialEnabled);
            }

            var miniGameData = AppManager.I.DB.GetMiniGameDataByCode(_gameCode);

            if (forceNewPlaySession)
            {
                AppManager.I.NavigationManager.InitNewPlaySession(miniGameData);
            }

            if (AppConfig.DebugLogEnabled)
            {
                Debug.Log("StartGame " + _gameCode.ToString());
            }

            // Assign the configuration for the given minigame
            var minigameSession = System.DateTime.Now.Ticks.ToString();

            currentGameConfig                 = ConfigureMiniGameScene(_gameCode, minigameSession);
            currentGameConfig.Difficulty      = _launchConfiguration.Difficulty;
            currentGameConfig.TutorialEnabled = _launchConfiguration.TutorialEnabled;

            // Set also the number of rounds
            // @note: only for assessment, for now
            if (currentGameConfig is Assessment.IAssessmentConfiguration)
            {
                var assessmentConfig = currentGameConfig as Assessment.IAssessmentConfiguration;
                assessmentConfig.NumberOfRounds = _launchConfiguration.NumberOfRounds;
            }

            // Retrieve the packs for the current minigame configuration
            currentQuestionBuilder      = currentGameConfig.SetupBuilder();
            currentQuestionPacks        = questionPacksGenerator.GenerateQuestionPacks(currentQuestionBuilder);
            currentGameConfig.Questions = new SequentialQuestionPackProvider(currentQuestionPacks);

            // Communicate to LogManager the start of a new single minigame play session.
            if (AppConfig.DebugLogDbInserts)
            {
                Debug.Log("InitGameplayLogSession " + _gameCode.ToString());
            }
            LogManager.I.LogInfo(InfoEvent.GameStart, "{\"minigame\":\"" + _gameCode.ToString() + "\"}");
            LogManager.I.StartMiniGame();

            // Print the teacher's report now
            ConfigAI.PrintTeacherReport();

            // Play the title dialog for the game
            //AudioManager.I.PlayDialogue(_gameCode.ToString()+"_Title");

            // Launch the game
            AppManager.I.NavigationManager.GoToMiniGameScene();
        }