From f1d3267547015ee2b37deb4c5f5591d01e906c23 Mon Sep 17 00:00:00 2001
From: Tt <505623963@qq.com>
Date: Tue, 27 Jun 2023 20:07:31 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 assets/hy06_danxuan/scene/hy06_danxuan.ts | 36 +++++++++++++----------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/assets/hy06_danxuan/scene/hy06_danxuan.ts b/assets/hy06_danxuan/scene/hy06_danxuan.ts
index 4e58b47..a272ded 100644
--- a/assets/hy06_danxuan/scene/hy06_danxuan.ts
+++ b/assets/hy06_danxuan/scene/hy06_danxuan.ts
@@ -130,7 +130,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
     startQuestion() {
         // 游戏所需的初始化数据
         this.currentId = 0
-        this.time = this.data.options.length * 3
+        this.time = this.data.options.length * 4
         this.currentTime = this.time * 1000;
         this.lengthProgress = 0
         this.right = 0
@@ -151,6 +151,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
         this.state = State.Recording;
         this.updateTitleOptions();
     }
+    gameOver() {
+        this.state = State.Over;
+    }
     private startCountDown: boolean;
     update(dt) {
         if (this.startCountDown) {
@@ -186,6 +189,12 @@ export default class SceneComponent extends MyCocosSceneComponent {
                 break;
             case State.RecordShow:
                 this.state = State.Recording;
+                this.hideAnswer();
+                this.currentId++;
+                if (!this.getCurrentOptions()) {
+                    this.gameOver();
+                    return;
+                }
                 this.updateTitleOptions()
                 break;
         }
@@ -194,6 +203,16 @@ export default class SceneComponent extends MyCocosSceneComponent {
     getCurrentOptions() {
         return this.data.options[this.currentId];
     }
+    hideAnswer() {
+        let topQuestion = pg.view.find(this, 'layer_game/topQuestion');
+        let row = pg.view.find(this, 'layer_game/row');
+        let right = pg.view.find(row, 'right');
+        let mistake = pg.view.find(row, 'mistake');
+        let answer = pg.view.find(topQuestion, 'answer');
+        right.active = false
+        mistake.active = false
+        answer.active = false
+    }
     //题目
     updateTitleOptions() {
         let topQuestion = pg.view.find(this, 'layer_game/topQuestion');
@@ -302,8 +321,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
             //错误
             row.children[1].active = true
         }
-        //添加动画
-        this.addAnimation(row, topQuestion)
     }
     //回答正确后回调
     rightQuestions(row) {
@@ -333,19 +350,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
 
         row.children[0].active = true
     }
-    addAnimation(row, topQuestion) {
-        if (this.currentId < (this.time / 5) - 1) {
-            //初始化
-            setTimeout(() => {
-                row.children[0].active = false
-                row.children[1].active = false
-                topQuestion.children[2].active = false
-                this.currentId++
-            }, 700);
-        } else {
-            console.log('回答完毕')
-        }
-    }
     playLocalAudio(audioName) {
         const audio = cc.find(`Canvas/res/audio/${audioName}`).getComponent(cc.AudioSource);
         return new Promise((resolve, reject) => {
-- 
2.21.0