IEnumerator gamePlaying() { print("gamePlaying"); // 開始播放背景音樂 audio_manager.modifyVolumn(BG_VOL); audio_manager.playOnLoop(AudioManager.AudioName.Game1); yield return(new WaitForSeconds(ROUND_INTERVAL_TIME)); layout.showStage(false); DetectSkeleton?result; string path; yield return(new WaitForSeconds(Time.deltaTime)); while (round < ROUND) { // 告訴玩家這是第幾題 & 總題數 //layout.setQuestionInfo(round + 1, ROUND); layout.setOperator("+"); // create question 3 ~ 5 target = Random.Range(3, 6); print(string.Format("target number: {0}", target)); path = string.Format("GameImage/Number{0}", target); layout.setTarget(path); number = 0; answer = 0; // round_time 歸零 round_time = 0f; #region 一輪 while (number < NUMBER && round_time < ROUND_TIME) { // 告訴玩家目前是第幾回合 layout.showRound(number, true); yield return(new WaitForSeconds(2f)); // 關閉回合提示 layout.showRound(number, false); // 第 0 輪 if (number == 0) { // 呈現題目 layout.showQuestion(true); layout.setOperator("+"); // 要回答的空格,以問號填入 且 框色為紅色,讓玩家清楚現在要做的事情 path = string.Format("GameImage/QuestionMark"); layout.setFirstNumber(path, Box.Red); // 尚未要回答的空格,框色為黑色 path = string.Format("GameImage/None"); layout.setSecondNumber(path, Box.Black); left_number = Random.Range(1, target); right_number = Random.Range(1, target); while (left_number == right_number) { left_number = Random.Range(1, target); } } // 其他輪 else { // "不"呈現第 0 輪所選之答案 path = string.Format("GameImage/None"); layout.setFirstNumber(path, Box.Black); // 要回答的空格,以問號填入,讓玩家清楚現在要做的事情 path = string.Format("GameImage/QuestionMark"); layout.setSecondNumber(path, Box.Red); int temp = left_number; left_number = target - right_number; right_number = target - temp; } path = string.Format("_Apple/{0}", left_number); layout.setLeftOption(path); path = string.Format("_Apple/{0}", right_number); layout.setRightOption(path); // 題目出現後緩衝數秒再開始偵測 yield return(new WaitForSeconds(QUESTION_BUFFER)); // 開始偵測 detect_manager.startMatch(DetectSkeleton.Game1); game_record.start( detect_manager.getGuid(), detect_manager.getStage(), getFirst(number), "+", getSecond(number), getAnswer(target)); while ((result = detect_manager.whichOnePass(DetectSkeleton.Game1)) == null && number < NUMBER && round_time < ROUND_TIME) { round_time += Time.deltaTime; yield return(new WaitForSeconds(Time.deltaTime)); } // 無論是否做到動作,回合數皆 +1 number++; //根據玩家做的動作給予回饋 yield return(StartCoroutine(playerSelection(result, number, round))); // 結束偵測 detect_manager.endMatch(DetectSkeleton.Game1, file_id); selection_messege = ""; } #endregion // 一輪結束,關閉題目 UI layout.showQuestion(false); // 無論是否答對題目,輪數皆 +1 round++; // 兩輪之間的緩衝時間 yield return(new WaitForSeconds(ROUND_INTERVAL_TIME)); } audio_manager.fadeOut(); StartCoroutine(gameEnd()); }
IEnumerator gamePlaying() { print("gamePlaying"); // 開始播放背景音樂 audio_manager.modifyVolumn(BG_VOL); audio_manager.playOnLoop(AudioManager.AudioName.Game3); // StageImage 中要放入該關卡的圖片 yield return(new WaitForSeconds(ROUND_INTERVAL_TIME)); layout.showStage(false); DetectSkeleton?result; while (round < ROUND) { // 告訴玩家這是第幾題 & 總題數 //layout.setQuestionInfo(round + 1, ROUND); // 呈現題目 layout.showQuestion(true); // 根據輪數,切換固定題目與選項 layout.setGame3(round); number = 0; // round_time 歸零 round_time = 0f; #region 一輪 while (number < NUMBER && round_time < ROUND_TIME) { // 題目出現後緩衝數秒再開始偵測 yield return(new WaitForSeconds(QUESTION_BUFFER)); // 開始偵測 detect_manager.startMatch(DetectSkeleton.Game3); game_record.start( detect_manager.getGuid(), detect_manager.getStage(), getFirst(round), "-", getSecond(), getAnswer(round)); while ((result = detect_manager.whichOnePass(DetectSkeleton.Game3)) == null && number < NUMBER && round_time < ROUND_TIME) { round_time += Time.deltaTime; yield return(new WaitForSeconds(Time.deltaTime)); } // 無論是否做到動作,回合數皆 +1 number++; // 根據玩家做的動作給予回饋 yield return(StartCoroutine(playerSelection(result, round + 1))); // 結束偵測 detect_manager.endMatch(DetectSkeleton.Game3, file_id); } #endregion // 一輪結束,關閉題目 UI layout.showQuestion(false); // 無論是否答對題目,輪數皆 +1 round++; yield return(new WaitForSeconds(ROUND_INTERVAL_TIME)); } audio_manager.fadeOut(); StartCoroutine(gameEnd()); }