/// <summary>
        /// 初始化学习界面
        /// </summary>
        public void SetUpLearnView()
        {
//			SoundManager.Instance.PlayAudioClip ("UI/sfx_UI_Click");
            currentWordsTableName = LearningInfo.Instance.GetCurrentLearningWordsTabelName();
            Time.timeScale        = 0;
            SoundManager.Instance.PauseBgm();
//			StartCoroutine ("SetUpViewAfterDataReady");
//		}
//
//
//		private IEnumerator SetUpViewAfterDataReady(){
//
//			bool dataReady = false;
//
//			while (!dataReady) {
//
//				dataReady = GameManager.Instance.gameDataCenter.CheckDatasReady (new GameDataCenter.GameDataType[] {
//					GameDataCenter.GameDataType.UISprites,
//				});
//				yield return null;
//			}

            GameSettings.LearnMode learnMode = GameManager.Instance.gameDataCenter.gameSettings.learnMode;

            switch (learnMode)
            {
            case GameSettings.LearnMode.Test:
                                #warning 这里暂时只做英->中
                this.examType     = Examination.ExaminationType.EngToChn;
                addToTrailIfWrong = false;
                beginWithLearn    = false;
                break;

            case GameSettings.LearnMode.Learn:
                this.examType     = Examination.ExaminationType.Both;
                addToTrailIfWrong = true;
                beginWithLearn    = true;
                break;
            }

            learnedWordCount = 0;
            coinGain         = 0;
            correctWordCount = 0;

            InitWordsToLearn();

            learnView.InitLearnView(wordsToLearnArray.Length);

            if (beginWithLearn)
            {
                learnView.SetUpLearnViewWithWord(currentLearningWord);
            }
            else
            {
                GenerateFinalExams(examType);
                learnView.SetUpLearnViewWithFinalExam(finalExaminationsList [0], examType);
            }
        }
        /// <summary>
        /// 直接从本次学习单词生成最终测试列表
        /// </summary>
        private void GenerateFinalExams(Examination.ExaminationType examType)
        {
            for (int i = 0; i < ungraspedWordsList.Count; i++)
            {
                LearnWord word = ungraspedWordsList [i];

                Examination finalExam = new Examination(word, wordsToLearnArray, examType);

                finalExaminationsList.Add(finalExam);
            }
        }
예제 #3
0
        public void SetUpLearnViewWithFinalExam(Examination exam, Examination.ExaminationType examType)
        {
            IEnumerator waitShowRightAnswerFinishCoroutine = WaitShowRightAnswerFinish(delegate {
                MySetUpLearnViewWithFinalExam(exam, examType);

                GetComponent <Canvas> ().enabled = true;

                if (GameManager.Instance.gameDataCenter.gameSettings.isAutoPronounce)
                {
                    GameManager.Instance.pronounceManager.PronounceWord(exam.question);
                }
            });

            StartCoroutine(waitShowRightAnswerFinishCoroutine);
        }
예제 #4
0
        private void MySetUpLearnViewWithFinalExam(Examination exam, Examination.ExaminationType examType)
        {
            totalTurnCount++;

            switch (examType)
            {
            case Examination.ExaminationType.EngToChn:

                questionText.text = exam.question.spell;

                phoneticSymbolText.text = exam.question.phoneticSymbol;

                phoneticSymbolText.enabled = true;

                for (int i = 0; i < choices.Length; i++)
                {
                    Button choiceButton = choices [i];

                    choiceButton.GetComponentInChildren <Text> ().color = Color.white;

                    LearnWord answer = exam.answers [i];

                    choiceButton.GetComponentInChildren <Text>().text = answer.explaination;

                    choiceButton.onClick.RemoveAllListeners();

//					int currentSelectChoiceIndex = i;

                    choiceButton.onClick.AddListener(delegate {
//						currentSelectChoice = choices[currentSelectChoiceIndex];
                        GetComponent <LearnViewController>().OnAnswerChoiceButtonOfFinalExamsClick(answer);
                    });
                }
                break;

            case Examination.ExaminationType.ChnToEng:

                questionText.text = exam.question.explaination;

                phoneticSymbolText.enabled = false;

                for (int i = 0; i < choices.Length; i++)
                {
                    Button choiceButton = choices [i];

                    LearnWord answer = exam.answers [i];

                    choiceButton.GetComponentInChildren <Text>().text = answer.spell;

                    choiceButton.onClick.RemoveAllListeners();

//					int currentSelectChoiceIndex = i;

                    choiceButton.onClick.AddListener(delegate {
//						currentSelectChoice = choices[currentSelectChoiceIndex];
                        GetComponent <LearnViewController>().OnAnswerChoiceButtonOfFinalExamsClick(answer);
                    });
                }
                break;
            }

            correctExplaination.text = exam.question.explaination;

            correctExplaination.enabled = false;

            ShowContainers(false, false, true, true);
        }
        /// <summary>
        /// 用户点击了最终测试界面中的答案选项卡
        /// </summary>
        public void OnAnswerChoiceButtonOfFinalExamsClick(LearnWord selectWord)
        {
            learnedWordCount++;

            learnView.UpdateLearningProgress(learnedWordCount, wordsToLearnArray.Length, true);

            // 如果选择正确,则将该单词的测试从测试列表中移除
            if (selectWord.wordId == currentExamination.question.wordId)
            {
                Debug.Log("选择正确");

                SoundManager.Instance.PlayAudioClip("UI/sfx_UI_RightTint");

                correctWordCount++;

                coinGain++;

                learnView.UpdateCrystalHarvest(coinGain);

                currentExamination.RemoveCurrentExamType();

                // 如果当前单词测试的所有测试类型都已经完成(根据设置,测试类型有 英译中,英译中+中译英)都已经完成,则从测试列表中删除该测试
                bool currentExamFinished = currentExamination.CheckCurrentExamFinished();
                if (currentExamFinished)
                {
                    currentExamination.question.learnedTimes++;
                    finalExaminationsList.RemoveAt(0);
                }
                else
                {
                    // 当前单词测试未完成
                    Examination exam = currentExamination;
                    finalExaminationsList.RemoveAt(0);
                    finalExaminationsList.Add(exam);
                }
            }
            else
            {
                // 如果选择错误
                Debug.Log("选择错误");

                SoundManager.Instance.PlayAudioClip("UI/sfx_UI_WrongTint");

                // 单词的背错次数+1
                GetWordFromWordsToLearnArrayWith(currentExamination.question.wordId).ungraspTimes++;

                // 当前测试加入到测试列表尾部
                Examination exam = currentExamination;

                finalExaminationsList.RemoveAt(0);

                if (addToTrailIfWrong)
                {
                    finalExaminationsList.Add(exam);
                    coinGain--;
                }

                learnView.ShowRightAnswerAndEnterNextExam(exam.correctAnswerIndex, currentExamination);
            }

            // 单词测试环节结束
            if (finalExaminationsList.Count <= 0)
            {
                learnView.ShowFinishLearningHUD(coinGain, correctWordCount);
            }
            else
            {
                // 测试环节还没有结束,则初始化下一个单词的测试
                Examination.ExaminationType examType = currentExamination.GetCurrentExamType();
                learnView.SetUpLearnViewWithFinalExam(currentExamination, examType);
            }
        }