public int GetCurrentNumberOfRounds(MiniGameCode miniGameCode) { var currentPos = AppManager.I.Player.CurrentJourneyPosition; var psData = dbManager.GetPlaySessionDataById(currentPos.Id); return(psData.NumberOfRoundsPerMinigame); }
private void LaunchMiniGameAtJourneyPosition(MiniGameCode minigameCode, float difficulty, JourneyPosition journeyPosition) { WidgetPopupWindow.I.Close(); DebugManager.I.SetDebugJourneyPos(journeyPosition); DebugManager.I.LaunchMiniGame(minigameCode, difficulty); Close(); }
/// <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); }
private IEnumerator DoTestMinigameCO(MiniGameCode code, float delay = 0.1f) { SetButtonStatus(minigamesButtonsDict[code], Color.yellow); yield return(new WaitForSeconds(delay)); var statusColor = Color.green; if (!ignoreJourneyPlaySessionSelection && !AppManager.I.Teacher.CanMiniGameBePlayedAtAnyPlaySession(code)) { Debug.LogError("Cannot select " + code + " for any journey position!"); statusColor = Color.magenta; } else { if (ignoreJourneyPlaySessionSelection || AppManager.I.Teacher.CanMiniGameBePlayedAfterMinPlaySession(AppManager.I.Player.CurrentJourneyPosition, code)) { try { SimulateMiniGame(code); } catch (Exception e) { Debug.LogError("!! " + code + " at PS(" + AppManager.I.Player.CurrentJourneyPosition + ")\n " + e.Message); statusColor = Color.red; } } else { Debug.LogError("Cannot select " + code + " for position " + AppManager.I.Player.CurrentJourneyPosition); statusColor = Color.gray; } } SetButtonStatus(minigamesButtonsDict[code], statusColor); yield return(null); }
public void LogMiniGameScore(int appSession, JourneyPosition pos, MiniGameCode miniGameCode, int score, float playTime) { if (ApplicationConfig.I.DebugLogEnabled) { Debug.Log("LogMiniGameScore " + miniGameCode + " / " + score); } // Log for history var data = new LogMiniGameScoreData(appSession, pos, miniGameCode, score, playTime); db.Insert(data); // Retrieve previous scores string query = string.Format("SELECT * FROM " + typeof(MiniGameScoreData).Name); var previousScoreDataList = db.Query <MiniGameScoreData>(query); // Score update var scoreData = GetMinigameScoreDataWithMaximum(miniGameCode, playTime, score, previousScoreDataList); db.InsertOrReplace(scoreData); // We also log play skills related to that minigame, as read from MiniGameData var minigameData = db.GetMiniGameDataByCode(miniGameCode); var results = new List <PlayResultParameters>(); float normalizedScore = Mathf.InverseLerp(AppConfig.MinMiniGameScore, AppConfig.MaxMiniGameScore, score); foreach (var weightedPlaySkill in minigameData.AffectedPlaySkills) { results.Add(new PlayResultParameters(PlayEvent.Skill, weightedPlaySkill.Skill, normalizedScore)); } LogPlay(appSession, pos, miniGameCode, results); }
public LogMiniGameScoreParams(JourneyPosition pos, MiniGameCode miniGameCode, int score, float playTime) { Pos = pos; MiniGameCode = miniGameCode; Score = score; PlayTime = playTime; }
public void LaunchGame(MiniGameCode miniGameCode) { float difficulty = teacher.GetCurrentDifficulty(miniGameCode); GameConfiguration configuration = new GameConfiguration(difficulty); MiniGameAPI.Instance.StartGame(miniGameCode, configuration); }
public void LogLearn(string session, string playSession, MiniGameCode miniGameCode, List <LearnResultParameters> resultsList) { var learnRules = GetLearnRules(miniGameCode); foreach (var result in resultsList) { float score = 0f; float successRatio = result.nCorrect * 1f / (result.nCorrect + result.nWrong); switch (learnRules.voteLogic) { case MiniGameLearnRules.VoteLogic.Threshold: // Uses a binary threshold float threshold = learnRules.logicParameter; score = successRatio > threshold ? 1f : -1f; break; case MiniGameLearnRules.VoteLogic.SuccessRatio: // Uses directly the success ratio to drive the vote score = Mathf.InverseLerp(-1f, 1f, successRatio); break; } score *= learnRules.minigameImportanceWeight; score += learnRules.minigameVoteSkewOffset; var data = new LogLearnData(session, playSession, miniGameCode, result.table, result.elementId, score); db.Insert(data); // We also update the score for that data element UpdateScoreDataWithMovingAverage(result.table, result.elementId, score, 5); } }
public JourneyPosition GetMinimumJourneyPositionForMiniGame(MiniGameCode minigameCode) { var finalPos = AppManager.I.JourneyHelper.GetFinalJourneyPosition(); int NBasePlaySession = 2; for (int s = 1; s <= finalPos.Stage; s++) { for (int lb = 1; lb <= finalPos.LearningBlock; lb++) { for (int ps = 1; ps <= NBasePlaySession; ps++) { var jp = new JourneyPosition(s, lb, ps); if (AppManager.I.DB.HasPlaySessionDataById(jp.Id)) { if (AppManager.I.Teacher.CanMiniGameBePlayedAtPlaySession(jp, minigameCode)) { return(new JourneyPosition(s, lb, ps)); } } } int assessmentCode = AssessmentPlaySessionIndex; var jp_assessment = new JourneyPosition(s, lb, assessmentCode); if (AppManager.I.DB.HasPlaySessionDataById(jp_assessment.Id)) { if (AppManager.I.Teacher.CanMiniGameBePlayedAtPlaySession(jp_assessment, minigameCode)) { return(new JourneyPosition(s, lb, assessmentCode)); } } } } return(null); }
public void LaunchMiniGame(MiniGameCode minigameCode, float difficulty) { playedMinigames[GetDictKey(minigameCode, difficulty)] = true; var debugJP = GetCurrentJourneyPositionInUI(); if (!DebugManager.I.SafeLaunch || AppManager.I.Teacher.CanMiniGameBePlayedAfterMinPlaySession(debugJP, minigameCode)) { LaunchMiniGameAtJourneyPosition(minigameCode, difficulty, debugJP); } else { if (DebugManager.I.SafeLaunch) { JourneyPosition minJP = AppManager.I.JourneyHelper.GetMinimumJourneyPositionForMiniGame(minigameCode); if (minJP == null) { Debug.LogWarningFormat( "Minigame {0} could not be selected for any PlaySession. Please check the PlaySession data table.", minigameCode); } else { Debug.LogErrorFormat("Minigame {0} cannot be selected PS {1}. Minimum PS is: {2}", minigameCode, debugJP, minJP); if (AutoCorrectJourneyPos) { LaunchMiniGameAtJourneyPosition(minigameCode, difficulty, minJP); } } } } }
void GoToMinigame() { MiniGameCode myGameCode = TeacherAI.I.CurrentMiniGame.Code; //myGameCode = MiniGameCode.Egg; // SET THIS TO TET SPECIFIC MINIGAMES IN THE MAIN PROGRESSION FLOW // AppManager.I.GameLauncher.LaunchGame(myGameCode); NavigationManager.I.GoToNextScene(); }
public MiniGameScoreData(MiniGameCode code, int stars, float totalPlayTime, int timestamp) { MiniGameCode = code; Id = ((int)code).ToString(); Stars = stars; TotalPlayTime = totalPlayTime; UpdateTimestamp = timestamp; }
public void LogMiniGameScore(MiniGameCode miniGameCode, float score) { if (AppConstants.VerboseLogging) { Debug.Log("LogMiniGameScore " + miniGameCode + " / " + score); } UpdateScoreDataWithMaximum(DbTables.MiniGames, (miniGameCode).ToString(), score); }
public void LogPlay(string session, string playSession, MiniGameCode miniGameCode, List <PlayResultParameters> resultsList) { // The teacher receives a score for each play skill the minigame deems worthy of analysis foreach (var result in resultsList) { var data = new LogPlayData(session, playSession, miniGameCode, result.playEvent, result.skill, result.score); db.Insert(data); } }
/// <summary> /// Can minigame be played at the given play session? /// Weak check: it just requires that the minimum has been reached. /// </summary> public bool CanMiniGameBePlayedAfterMinPlaySession(JourneyPosition jp, MiniGameCode code) { if (minMiniGameJourneyPositions[code] == null) { return(false); } return(minMiniGameJourneyPositions[code].IsMinor(jp) || minMiniGameJourneyPositions[code].Equals(jp)); }
/// <summary> /// Initializes the single minigame gameplay log session. /// </summary> public void InitGameplayLogSession(MiniGameCode _minigameCode) { if (AppConstants.DebugLogInserts) { Debug.Log("InitGameplayLogSession " + _minigameCode.ToString()); } miniGameCode = _minigameCode; minigameSession = DateTime.Now.Ticks.ToString(); LogManager.I.LogInfo(InfoEvent.GameStart, miniGameCode.ToString()); }
public LogLearnData(string _Session, string _PlaySession, MiniGameCode _MiniGame, DbTables _table, string _elementId, float _score) { this.Session = _Session; this.PlaySession = _PlaySession; this.MiniGame = _MiniGame; this.TableName = _table.ToString(); this.ElementId = _elementId; this.Score = _score; this.Timestamp = GenericUtilities.GetTimestampForNow(); }
private void CreateButtonForCode(MiniGameCode enumValue) { MiniGameCode code = enumValue; var btnGO = Instantiate(buttonPrefab); btnGO.transform.SetParent(this.transform); btnGO.GetComponentInChildren <Text>().text = (enumValue.ToString()).Replace("_", "\n"); btnGO.GetComponent <Button>().onClick.AddListener(() => { tester.DoTestMinigame(code); }); tester.minigamesButtonsDict[enumValue] = btnGO.GetComponent <Button>(); }
public List <float> GetLatestScoresForMiniGame(MiniGameCode minigameCode, int nLastDays) { int fromTimestamp = GenericUtilities.GetRelativeTimestampFromNow(-nLastDays); string query = string.Format("SELECT * FROM LogPlayData WHERE MiniGame = '{0}' AND Timestamp < {1}", (int)minigameCode, fromTimestamp); List <LogPlayData> list = dbManager.FindLogPlayDataByQuery(query); List <float> scores = list.ConvertAll(x => x.Score); return(scores); }
public void SimulateMiniGame(MiniGameCode code) { var config = API.MiniGameAPI.Instance.GetGameConfigurationForMiniGameCode(code); InitialisePlaySession(); var builder = config.SetupBuilder(); Debug.Log("Simulating minigame: " + code + " with builder " + builder.GetType().Name); builder.CreateAllQuestionPacks(); }
public LogGamePlayData(JourneyPosition journeyPosition, MiniGameCode miniGameCode, int stars, float playTime) { Stage = journeyPosition.Stage; LearningBlock = journeyPosition.LearningBlock; PlaySession = journeyPosition.PlaySession; Stars = stars; PlayTime = (int)playTime; MiniGameCode = miniGameCode.ToString(); Timestamp = GenericHelper.GetTimestampForNow(); }
public LogMiniGameScoreData(int appSession, JourneyPosition journeyPosition, MiniGameCode miniGameCode, int stars, float playTime) { AppSession = appSession; Stage = journeyPosition.Stage; LearningBlock = journeyPosition.LearningBlock; PlaySession = journeyPosition.PlaySession; Stars = stars; PlayTime = playTime; MiniGameCode = miniGameCode; Timestamp = GenericHelper.GetTimestampForNow(); }
public void LaunchMiniGame(MiniGameCode miniGameCodeSelected, float difficulty) { AppManager.I.Player.CurrentJourneyPosition.SetPosition(Stage, LearningBlock, PlaySession); Difficulty = difficulty; Debug.Log("LaunchMiniGame " + miniGameCodeSelected + " PS: " + AppManager.I.Player.CurrentJourneyPosition + " Diff: " + Difficulty + " Tutorial: " + AppConfig.MinigameTutorialsEnabled); AppManager.I.GameLauncher.LaunchGame(miniGameCodeSelected, new MinigameLaunchConfiguration(Difficulty, NumberOfRounds, tutorialEnabled: AppConfig.MinigameTutorialsEnabled), forceNewPlaySession: true); }
public List <float> GetLatestScoresForMiniGame(MiniGameCode minigameCode, int nLastDays) { int fromTimestamp = GenericHelper.GetRelativeTimestampFromNow(-nLastDays); string query = string.Format( "SELECT * FROM " + typeof(LogMiniGameScoreData).Name + " WHERE MiniGameCode = '{0}' AND Timestamp < {1}", (int)minigameCode, fromTimestamp); var list = dbManager.FindLogPlayDataByQuery(query); var scores = list.ConvertAll(x => x.Score); return(scores); }
public LogPlayData(string _Session, string _PlaySession, MiniGameCode _MiniGame, PlayEvent _PlayEvent, PlaySkill _PlaySkill, float _Score, string _RawData) { this.Session = _Session; this.PlaySession = _PlaySession; this.MiniGame = _MiniGame; this.PlayEvent = _PlayEvent; this.PlaySkill = _PlaySkill; this.Score = _Score; this.RawData = _RawData; this.Timestamp = GenericUtilities.GetTimestampForNow(); }
public void DoTestMinigame(MiniGameCode code) { if (testWholeJourneyAtButtonClick) { StartCoroutine(DoTest(() => DoTestMinigameWholeJourneyCO(code))); } else { StartCoroutine(DoTest(() => DoTestMinigameCO(code))); } }
public void LaunchGame() { // Example minigame call MiniGameCode miniGameCodeSelected = (MiniGameCode)Enum.Parse(typeof(MiniGameCode), MiniGamesDropDownList.options[MiniGamesDropDownList.value].text); float difficulty = float.Parse(FindObjectsOfType <InputField>().First(n => n.name == "Difficulty").text); // Call start game with parameters MiniGameAPI.Instance.StartGame( miniGameCodeSelected, new GameConfiguration(difficulty) ); }
public List <WordData> GetFailedAssessmentWords(MiniGameCode assessmentCode) { string query = string.Format( "SELECT * FROM LogLearnData WHERE TableName = 'WordData' AND Score < 0 and MiniGame = {0}", (int)assessmentCode); List <LogLearnData> logLearnData_list = dbManager.FindLogLearnDataByQuery(query); List <string> words_ids_list = logLearnData_list.ConvertAll(x => x.ElementId); List <WordData> words = dbManager.FindWordData(x => words_ids_list.Contains(x.Id)); return(words); }
public bool CanMiniGameBePlayedAtPlaySession(PlaySessionData psData, MiniGameCode code) { if (psData != null) { var mgIndex = psData.Minigames.ToList().FindIndex(x => x.MiniGameCode == code); if (mgIndex >= 0) { return(true); } } return(false); }
void Start() { foreach (var enumValue in GenericUtilities.SortEnums <MiniGameCode>()) { MiniGameCode code = enumValue; var btnGO = Instantiate(buttonPrefab); btnGO.transform.SetParent(this.transform); btnGO.GetComponentInChildren <Text>().text = (enumValue.ToString()).Replace("_", "\n"); btnGO.GetComponent <Button>().onClick.AddListener(() => { tester.SimulateMiniGame(code); }); } Destroy(buttonPrefab); }