public void SetQuestion() { if (arithmeticQuestionList == null || arithmeticQuestionList.Count <= 0) { return; } //1111111111 GameDifficulty result = AdaptiveDifficultyManager.Instance.GetGameDifficulty("MathDiff", 30); List <ArithmeticQuestion> arithmeticList = new List <ArithmeticQuestion> (); for (int i = 0; i < arithmeticQuestionList.Count; i++) { if (arithmeticQuestionList[i].Difficulty >= result.MinDiff && arithmeticQuestionList[i].Difficulty <= result.MaxDiff) { arithmeticList.Add(arithmeticQuestionList[i]); } } if (arithmeticList.Count.Equals(1)) { arithmeticQuestion = arithmeticList[0]; } else { arithmeticQuestion = arithmeticList[Random.Range(0, arithmeticList.Count - 1)]; while (usedQuestionDic.ContainsKey(arithmeticQuestion.OptionContent)) { arithmeticQuestion = arithmeticList[Random.Range(0, arithmeticList.Count - 1)]; } usedQuestionDic.Add(arithmeticQuestion.OptionContent, arithmeticQuestion); } }
public void InitData(ArithmeticQuestion arithmeticQuestion) { if (arithmeticQuestion == null) { return; } InitObject(); curQuestionData.answerList.Clear(); string tmpStr = arithmeticQuestion.OptionContent; string[] str = tmpStr.Split(','); for (int i = 0; i < str.Length; i++) { curQuestionData.answerList.Add(int.Parse(str[i])); } for (int i = 0; i < arithmeticQuestion.ItemList.Count; i++) { switch (i) { case 0: curQuestionData.rightOne = arithmeticQuestion.ItemList[i].Expression; break; case 1: curQuestionData.rightTwo = arithmeticQuestion.ItemList[i].Expression; break; } } curQuestionData.result = curQuestionData.rightOne + curQuestionData.rightTwo; if (originPlate != null && originTitle != null) { DestoryPlate(); for (int i = 0; i < curQuestionData.answerList.Count; i++) { GameObject go = (GameObject)Instantiate(originPlate); go.transform.parent = MoveObject.transform; go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; UIPlate plate = go.transform.GetComponent <UIPlate>(); if (plate != null) { plateList.Add(plate); } go = (GameObject)Instantiate(originTitle); go.transform.parent = titleObject.transform; go.transform.localRotation = Quaternion.identity; go.transform.localScale = Vector3.one; UITitle title = go.transform.GetComponent <UITitle>(); if (title != null) { titleList.Add(title); } } SetPlatePosition(); } }
public void Initialize() { rightCount = 0; wrongCount = 0; UICamera uiCamera = WindowManager.Instance.GetUICamera().GetComponent <UICamera>(); usedQuestionDic.Clear(); if (uiCamera != null) { uiCamera.allowMultiTouch = false; } if (parentTrans != null && WindowManager.Instance.UIWindowCameraRoot != null) { parentTrans.parent = WindowManager.Instance.UIWindowCameraRoot.transform; } parentTrans.transform.localPosition = Vector3.zero; arithmeticQuestionList = ConfigManager.Instance.GetArithmeticConfigTable().QuestionList; arithmeticTimerList = ConfigManager.Instance.GetArithmeticConfigTable().TimerList; // SetTimer(); SetQuestion(); if (!UIArithmeticGuideManager.isGuide) { arithmeticQuestion = new ArithmeticQuestion(); arithmeticQuestion.Difficulty = 0.1f; arithmeticQuestion.OptionContent = "4,1,2"; arithmeticQuestion.ItemList = new List <ArithmeticItem>(); ArithmeticItem item = new ArithmeticItem(); item.Expression = 1; item.Operation = "+"; arithmeticQuestion.ItemList.Add(item); ArithmeticItem item1 = new ArithmeticItem(); item1.Expression = 2; item1.Operation = ""; arithmeticQuestion.ItemList.Add(item1); if (UIArithmeticGuideManager.Instance != null) { UIArithmeticGuideManager.Instance.StartGuide(); } } if (UIPlateManager.instance != null) { UIPlateManager.instance.InitData(arithmeticQuestion); UIPlateManager.instance.InitRound(round); } gameOver = false; }