예제 #1
0
 public VocabularyContents GetContentsOfLearningBlock(JourneyPosition pos)
 {
     return(CreateContentsFromFunc(pair => pair.Key.LearningBlock == pos.LearningBlock && pair.Key.Stage == pos.Stage));
 }
예제 #2
0
 public PlayerIconData(string _Uuid, int _AvatarId, PlayerGender _Gender, PlayerTint _Tint, bool _IsDemoUser,
                       bool _HasFinishedTheGame, bool _HasFinishedTheGameWithAllStars, bool _HasMaxStarsInCurrentPlaySessions, JourneyPosition _MaxJourneyPosition)
 {
     Uuid                             = _Uuid;
     AvatarId                         = _AvatarId;
     Gender                           = _Gender;
     Tint                             = _Tint;
     IsDemoUser                       = _IsDemoUser;
     HasFinishedTheGame               = _HasFinishedTheGame;
     HasFinishedTheGameWithAllStars   = _HasFinishedTheGameWithAllStars;
     HasMaxStarsInCurrentPlaySessions = _HasMaxStarsInCurrentPlaySessions;
     MaxJourneyPosition               = _MaxJourneyPosition;
 }
예제 #3
0
 private void LaunchMiniGameAtJourneyPosition(MiniGameCode minigameCode, float difficulty, JourneyPosition journeyPosition)
 {
     WidgetPopupWindow.I.Close();
     DebugManager.I.SetDebugJourneyPos(journeyPosition);
     DebugManager.I.LaunchMiniGame(minigameCode, difficulty);
     Close();
 }
예제 #4
0
 public void ForcePreviousJourneyPosition(JourneyPosition journeyPosition)
 {
     PreviousJourneyPosition = journeyPosition;
 }
예제 #5
0
 private IEnumerable <RewardPack> GetRewardPacksForJourneyPosition(JourneyPosition journeyPosition)
 {
     return(GetRewardPacks().Where(x => x.IsFoundAtJourneyPosition(journeyPosition)));
 }
예제 #6
0
 public void SetCurrentJourneyPosition(JourneyPosition pos)
 {
     CurrentStage         = pos.Stage;
     CurrentLearningBlock = pos.LearningBlock;
     CurrentPlaySession   = pos.PlaySession;
 }
예제 #7
0
        public IEnumerator LazyInitialiseCO()
        {
            // Generate enough pins
            var pinPlaceholders      = gameObject.GetComponentsInChildren <PinPlaceholder>().ToList();
            var allPlaySessionStates = GetAllPlaySessionStatesForStage(stageNumber);
            int nMoreNeeded          = allPlaySessionStates.Count - pinPlaceholders.Count;

            if (nMoreNeeded > 0)
            {
                for (int iPin = 0; iPin < nMoreNeeded; iPin++)
                {
                    var newPlaceholder = Instantiate(pinPlaceholders[0]);
                    pinPlaceholders.Add(newPlaceholder);
                    newPlaceholder.transform.SetParent(pinPlaceholders[0].transform.parent);
                }
            }
            else if (nMoreNeeded < 0)
            {
                int iMax = pinPlaceholders.Count - 1;
                for (int iPin = iMax; iPin >= iMax - (-nMoreNeeded) + 1; iPin--)
                {
                    var placeholder = pinPlaceholders[iPin];
                    pinPlaceholders.RemoveAt(iPin);
                    Destroy(placeholder.gameObject);
                }
            }

            // Re-align all pin placeholders
            DistributePinsDuringPlay(true);

            // Create all pins from placeholders
            playPins = new List <Pin>();
            for (var jp_i = 0; jp_i < pinPlaceholders.Count; jp_i++)
            {
                var pinPlaceholder = pinPlaceholders[jp_i];
                var pinGO          = Instantiate(pinPrefab);
                var pin            = pinGO.GetComponent <Pin>();
                pin.transform.position = pinPlaceholder.transform.position;
                playPins.Add(pin);
                Destroy(pinPlaceholder);

                if (jp_i % 5 == 0)
                {
                    yield return(null);
                }
            }

            playPins.Sort((pinA, pinB) => - MapDirection * (int)(pinA.transform.position.x - pinB.transform.position.x));

            int             playerPosIndexCount     = 0;
            JourneyPosition assignedJourneyPosition = new JourneyPosition(stageNumber, 1, 1);

            // Initialise all pins
            for (int jp_i = 0; jp_i < playPins.Count; jp_i++)
            {
                var pin = playPins[jp_i];
                pin.Initialise(playerPosIndexCount++, assignedJourneyPosition);
                mapLocations.Add(pin);

                pin.SetLocked();
                var psState = allPlaySessionStates.Find(x => x.psData.GetJourneyPosition().Equals(assignedJourneyPosition));
                if (psState != null)
                {
                    pin.SetPlaySessionState(psState);
                }

                // Dialogues added to all JPs of the stage
                playPins[jp_i].gameObject.AddComponent <IntroDialogues>();

                // Advance to the next journey pos
                //Debug.Log("Current jp: " + assignedJourneyPosition);
                assignedJourneyPosition = AppManager.I.JourneyHelper.FindNextJourneyPosition(assignedJourneyPosition);
                //Debug.Log("Next jp: " + assignedJourneyPosition);

                pin.InitPinHidden();
            }

            UnlockPlaySessions();
            //yield return new WaitForSeconds(2.0f);
        }
예제 #8
0
 public void SetDebugJourneyPos(JourneyPosition jp)
 {
     Stage         = jp.Stage;
     LearningBlock = jp.LearningBlock;
     PlaySession   = jp.PlaySession;
 }
예제 #9
0
 public LogPlaySessionScoreParams(JourneyPosition pos, int score, float playTime)
 {
     Pos      = pos;
     Score    = score;
     PlayTime = playTime;
 }
예제 #10
0
        public void LogLearn(int appSession, JourneyPosition pos, MiniGameCode miniGameCode, List <LearnResultParameters> resultsList)
        {
            var currentJourneyContents = AppManager.I.Teacher.VocabularyAi.CurrentJourneyContents;

            // No logging if we do not have contents (for example through a direct Play)
            if (currentJourneyContents == null)
            {
                return;
            }

            var learnRules = GetLearnRules(miniGameCode);

            // Retrieve previous scores
            string query = string.Format("SELECT * FROM " + typeof(VocabularyScoreData).Name);
            var    previousScoreDataList = db.Query <VocabularyScoreData>(query);

            // Prepare log data
            var logDataList   = new List <LogVocabularyScoreData>();
            var scoreDataList = new List <VocabularyScoreData>();

            foreach (var result in resultsList)
            {
                if (result.elementId == null)
                {
                    Debug.LogError("LogAI: Logging a result with a NULL elementId. Skipped.");
                    continue;
                }
                if (result.nCorrect == 0 && result.nWrong == 0)
                {
                    Debug.LogError("LogAI: Logging a result with no correct nor wrong hits. Skipped.");
                    continue;
                }

                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 logData = new LogVocabularyScoreData(appSession, pos, miniGameCode, result.dataType, result.elementId, score);
                logDataList.Add(logData);

                // We also update the score for that data element
                var scoreData = GetVocabularyScoreDataWithMovingAverage(result.dataType, result.elementId, score, previousScoreDataList, ConfigAI.ScoreMovingAverageWindow);
                scoreDataList.Add(scoreData);

                // Check whether the vocabulary data was in the journey (and can thus be unlocked)
                if (!UNLOCK_AT_PLAYSESSION_END)
                {
                    if (!scoreData.Unlocked)
                    {
                        IVocabularyData data = null;
                        bool            containedInJourney = false;
                        switch (result.dataType)
                        {
                        case VocabularyDataType.Letter:
                            data = AppManager.I.DB.GetLetterDataById(result.elementId);
                            containedInJourney = currentJourneyContents.Contains(data as LetterData);
                            break;

                        case VocabularyDataType.Word:
                            data = AppManager.I.DB.GetWordDataById(result.elementId);
                            containedInJourney = currentJourneyContents.Contains(data as WordData);
                            break;

                        case VocabularyDataType.Phrase:
                            data = AppManager.I.DB.GetPhraseDataById(result.elementId);
                            containedInJourney = currentJourneyContents.Contains(data as PhraseData);
                            break;
                        }

                        if (containedInJourney)
                        {
                            scoreData.Unlocked = true;
                        }
                    }
                }
            }

            db.InsertAll(logDataList);
            db.InsertOrReplaceAll(scoreDataList);
        }
예제 #11
0
 public VocabularyContents GetContentsAtLearningBlock(JourneyPosition jp)
 {
     return(progressionContents.GetContentsOfLearningBlock(jp));
 }
예제 #12
0
 public VocabularyContents GetContentsUpToJourneyPosition(JourneyPosition jp)
 {
     return(progressionContents.GetContentsUpToPlaySession(jp));
 }
예제 #13
0
 public VocabularyContents GetContentsOfStage(JourneyPosition pos)
 {
     return(CreateContentsFromFunc(pair => pair.Key.Stage == pos.Stage));
 }
예제 #14
0
        /// <summary>
        /// Can the given minigame be played at the given play session?
        /// Strong check: it must be the actual play session
        /// </summary>
        public bool CanMiniGameBePlayedAtPlaySession(JourneyPosition journeyPos, MiniGameCode code)
        {
            var psData = dbManager.GetPlaySessionDataById(journeyPos.Id);

            return(CanMiniGameBePlayedAtPlaySession(psData, code));
        }
예제 #15
0
 public void Appear(JourneyPosition fromPos, JourneyPosition toPos)
 {
     StartCoroutine(AppearCO(fromPos, toPos));
 }
예제 #16
0
        void UnlockJP(int stage, int lb, int ps)
        {
            var jp = new JourneyPosition(stage, lb, ps);

            AppManager.I.RewardSystemManager.UnlockAllRewardPacksForJourneyPosition(jp);
        }
예제 #17
0
 public Pin PinForJourneyPosition(JourneyPosition jp)
 {
     return(playPins.FirstOrDefault(p => p.JourneyPos.Equals(jp)));
 }
예제 #18
0
 private IEnumerable <RewardPack> GetRewardPacksAlreadyUnlockedForJourneyPosition(JourneyPosition journeyPosition)
 {
     return(GetRewardPacks().Where(x => x.IsFoundAtJourneyPosition(journeyPosition) && x.IsUnlocked));
 }
예제 #19
0
 public PlayerIconData(string _Uuid, int _AvatarId, PlayerTint _Tint, PlayerGender _Gender, Color _SkinColor, Color _HairColor, Color _BgColor, bool _IsDemoUser,
                       bool _HasFinishedTheGame, bool _HasFinishedTheGameWithAllStars, bool _HasMaxStarsInCurrentPlaySessions, JourneyPosition _MaxJourneyPosition, AppEditions _Edition, string _AppVersion)
 {
     Uuid                             = _Uuid;
     AvatarId                         = _AvatarId;
     SkinColor                        = _SkinColor;
     HairColor                        = _HairColor;
     BgColor                          = _BgColor;
     Gender                           = _Gender;
     Tint                             = _Tint;
     IsDemoUser                       = _IsDemoUser;
     HasFinishedTheGame               = _HasFinishedTheGame;
     HasFinishedTheGameWithAllStars   = _HasFinishedTheGameWithAllStars;
     HasMaxStarsInCurrentPlaySessions = _HasMaxStarsInCurrentPlaySessions;
     MaxJourneyPosition               = _MaxJourneyPosition;
     Edition                          = _Edition;
     AppVersion                       = _AppVersion;
     Debug.Log("CREATE PLAYER ICON DATA > " + SkinColor + " > " + HairColor);
 }
예제 #20
0
 public void SetMaxJourneyPosition(JourneyPosition pos)
 {
     MaxStage         = pos.Stage;
     MaxLearningBlock = pos.LearningBlock;
     MaxPlaySession   = pos.PlaySession;
 }
예제 #21
0
        IEnumerator PopulateDatabaseWithUsefulDataCO(JourneyPosition targetPosition)
        {
            bool useBestScores = true;

            var logAi          = AppManager.I.Teacher.logAI;
            var fakeAppSession = LogManager.I.AppSession;

            // Add some mood data
            Debug.Log("Start adding mood scores");
            yield return(null);

            int nMoodData = 15;

            for (int i = 0; i < nMoodData; i++)
            {
                logAi.LogMood(0, Random.Range(AppConfig.MinMoodValue, AppConfig.MaxMoodValue + 1));
            }
            yield return(null);

            // Add scores for all play sessions
            Debug.Log("Start adding PS scores");
            yield return(null);

            var logPlaySessionScoreParamsList = new List <LogPlaySessionScoreParams>();
            var allPlaySessionInfos           = AppManager.I.ScoreHelper.GetAllPlaySessionInfo();

            for (int i = 0; i < allPlaySessionInfos.Count; i++)
            {
                if (allPlaySessionInfos[i].data.Stage <= targetPosition.Stage)
                {
                    int score = useBestScores
                        ? AppConfig.MaxMiniGameScore
                        : Random.Range(AppConfig.MinMiniGameScore, AppConfig.MaxMiniGameScore);
                    logPlaySessionScoreParamsList.Add(new LogPlaySessionScoreParams(allPlaySessionInfos[i].data.GetJourneyPosition(), score,
                                                                                    12f));
                    //Debug.Log("Add play session score for " + allPlaySessionInfos[i].data.Id);
                }
            }
            logAi.LogPlaySessionScores(0, logPlaySessionScoreParamsList);
            yield return(null);

            // Add scores for all minigames
            Debug.Log("Start adding MiniGame scores");
            yield return(null);

            var logMiniGameScoreParamses = new List <LogMiniGameScoreParams>();
            var allMiniGameInfo          = AppManager.I.ScoreHelper.GetAllMiniGameInfo();

            for (int i = 0; i < allMiniGameInfo.Count; i++)
            {
                int score = useBestScores
                    ? AppConfig.MaxMiniGameScore
                    : Random.Range(AppConfig.MinMiniGameScore, AppConfig.MaxMiniGameScore);
                logMiniGameScoreParamses.Add(new LogMiniGameScoreParams(JourneyPosition.InitialJourneyPosition,
                                                                        allMiniGameInfo[i].data.Code, score, 12f));
                //Debug.Log("Add minigame score " + i);
            }
            logAi.LogMiniGameScores(0, logMiniGameScoreParamses);

            // Add scores for some learning data (words/letters/phrases)

            /*var maxPlaySession = AppManager.I.Player.MaxJourneyPosition.ToString();
             * var allWordInfo = AppManager.I.Teacher.ScoreHelper.GetAllWordInfo();
             * for (int i = 0; i < allWordInfo.Count; i++)
             * {
             *  if (Random.value < 0.3f)
             *  {
             *      var resultsList = new List<Teacher.LogAI.LearnResultParameters>();
             *      var newResult = new Teacher.LogAI.LearnResultParameters();
             *      newResult.elementId = allWordInfo[i].data.Id;
             *      newResult.table = DbTables.Words;
             *      newResult.nCorrect = Random.Range(1,5);
             *      newResult.nWrong = Random.Range(1, 5);
             *      resultsList.Add(newResult);
             *      logAi.LogLearn(fakeAppSession, maxPlaySession, MiniGameCode.Assessment_LetterForm, resultsList);
             *  }
             * }
             * var allLetterInfo = AppManager.I.Teacher.ScoreHelper.GetAllLetterInfo();
             * for (int i = 0; i < allLetterInfo.Count; i++)
             * {
             *  if (Random.value < 0.3f)
             *  {
             *      var resultsList = new List<Teacher.LogAI.LearnResultParameters>();
             *      var newResult = new Teacher.LogAI.LearnResultParameters();
             *      newResult.elementId = allLetterInfo[i].data.Id;
             *      newResult.table = DbTables.Letters;
             *      newResult.nCorrect = Random.Range(1, 5);
             *      newResult.nWrong = Random.Range(1, 5);
             *      resultsList.Add(newResult);
             *      logAi.LogLearn(fakeAppSession, maxPlaySession, MiniGameCode.Assessment_LetterForm, resultsList);
             *  }
             * }*/
        }
예제 #22
0
 // Checks for unlock
 private bool HasReachedJourneyPosition(JourneyPosition journeyPosition)
 {
     return(AppManager.I.Player.MaxJourneyPosition.IsGreaterOrEqual(journeyPosition));
 }
예제 #23
0
 public void MoveToJourneyPosition(JourneyPosition journeyPosition, StageMap stageMap)
 {
     MoveToPin(StageMapsManager.GetPosIndexFromJourneyPosition(stageMap, journeyPosition), stageMap.stageNumber);
 }
예제 #24
0
 public void UpdatePreviousJourneyPosition()
 {
     PreviousJourneyPosition = new JourneyPosition(CurrentJourneyPosition);
     //Debug.LogError("Updating Prev to " + PreviousJourneyPosition);
 }
예제 #25
0
        public void ForceToJourneyPosition(JourneyPosition journeyPosition, bool justVisuals = false)
        {
            int posIndex = StageMapsManager.GetPosIndexFromJourneyPosition(currentStageMap, journeyPosition);

            ForceToPin(posIndex, justVisuals);
        }
예제 #26
0
 public VocabularyContents GetContentsUpToPlaySession(JourneyPosition pos)
 {
     return(CreateContentsFromFunc(pair => pair.Key.IsMinor(pos) || pair.Key.Equals(pos)));
 }
예제 #27
0
 public bool IsAssessmentTime(JourneyPosition journeyPosition)
 {
     return(journeyPosition.PlaySession == AssessmentPlaySessionIndex);
 }