林旭祥 3 settimane fa
parent
commit
7ce399fa96

+ 14 - 12
src/components/ActionConfirmWindow/index.vue

@@ -6,7 +6,7 @@
       <div class="confirmDiaBgBox" v-if="actionState">
         <div class="confirmDiaBg">
           <div class="confirmDiaWindow">
-            <div class="prompt"><i></i> {{ actionText }}</div>
+            <div class="prompt"><i></i><span>{{ actionText }}</span></div>
             <div class="confirmDiaWindow-con">
 
 
@@ -301,15 +301,16 @@ watch(
     if (state) {
       lock.value = true;
       timerNum.value = 3;
+      speckText(timerNum.value);
       timer.value = setInterval(() => {
-        if (timerNum.value == 1) {
+        timerNum.value--;
+        speckText(timerNum.value);
+        if (timerNum.value == 0) {
           actionState.value = false;
           clearInterval(timer.value);
           timer.value = null;
           emit('confirmStart', areaStateList.value);
         }
-        speckText(timerNum.value);
-        timerNum.value--;
       }, 1000)
     }
   },
@@ -333,16 +334,16 @@ defineExpose({
   z-index: 998;
 }
 
-.confirmDiaBgBox{
-    position: fixed;
+.confirmDiaBgBox {
+  position: fixed;
   height: 100vh;
   width: 100vw;
-    top: 0;
+  top: 0;
   left: 0;
-   z-index: 998;
-   display: flex;
-   align-items: center;
-   justify-content: center;
+  z-index: 998;
+  display: flex;
+  align-items: center;
+  justify-content: center;
 }
 
 .confirmDiaBg {
@@ -366,8 +367,9 @@ defineExpose({
       color: #ffffff;
       font-size: 2.5vh;
       display: flex;
+      align-items: center;
       padding-top: 2vh;
-
+      
       i {
         width: 3vh;
         height: 3vh;

+ 2 - 2
src/views/game/components/basketball.vue

@@ -856,8 +856,8 @@ const draw = () => {
 
         // 如果需要跳转到其他页面,可以使用路由
         // router.push('/');
-        emit('confirmExit', { type: 1 });
-      }, 3000);
+        emit('confirmExit', { type: 2, area: props.currentGameArea });
+      }, 5000);
     }
 
     // 保留点击退出的功能

+ 12 - 11
src/views/game/components/football.vue

@@ -191,9 +191,9 @@ const initGame = () => {
     setTimeout(() => {
       if (currentScene.value == 'gameover') {
         // restartGame();
-        emit('confirmExit', { type: 1 });
+        emit('confirmExit', { type: 2, area: props.currentGameArea });
       }
-    }, 3000)
+    }, 5000)
   });
   setTimeout(() => {
     if (currentScene.value === 'start') {
@@ -373,9 +373,10 @@ class GameScene extends Phaser.Scene {
     //this.player = this.physics.add.sprite(clientObj.value.width / 2, clientObj.value.height - 100, 'playerAnim');
     this.player = this.physics.add.sprite(direction.value + 46, clientObj.value.height - 100, 'playerAnim');
     this.player.setCollideWorldBounds(true);
-    this.player.setScale(0.8);
+    this.player.setScale(2.5);
     this.player.lives = this.lives;
     this.player.setDepth(9);
+
   }
 
   createHUD() {
@@ -473,7 +474,7 @@ class GameScene extends Phaser.Scene {
 
     // 重新创建事件(使用安全的场景上下文)
     this.obstacleEvent = this.time.addEvent({
-      delay: 1000 / this.level,
+      delay: 1800 / this.level,
       callback: () => { if (this.gameActive) this.spawnObstacle(); },
       loop: true
     });
@@ -495,9 +496,9 @@ class GameScene extends Phaser.Scene {
   spawnObstacle() {
     const x = Phaser.Math.Between(30, clientObj.value.width - 30);
     const obstacle = this.physics.add.sprite(x, -50, 'pile');
-    obstacle.setScale(0.7);
+    obstacle.setScale(2.5);
     // 降低速度(从原来的this.speed * this.acceleration * 10调整为)
-    obstacle.setVelocityY(this.speed * this.acceleration * 5); // 速度减半
+    obstacle.setVelocityY(this.speed * this.acceleration * 12); // 速度减半
     obstacle.setDepth(8);
     obstacle.type = 'pile';
 
@@ -539,9 +540,9 @@ class GameScene extends Phaser.Scene {
     //   powerUp.type = 'broom';
     // }
 
-    powerUp.setScale(0.7);
+    powerUp.setScale(2.5);
     // 降低道具速度(从原来的this.speed * this.acceleration * 8调整为)
-    powerUp.setVelocityY(this.speed * this.acceleration * 4); // 速度降低
+    powerUp.setVelocityY(this.speed * this.acceleration * 12); // 速度降低
     powerUp.setDepth(8);
 
     // 碰撞检测
@@ -702,13 +703,13 @@ class GameScene extends Phaser.Scene {
 
     // 创建球门
     this.goal = this.physics.add.sprite(clientObj.value.width / 2, 100, 'goal');
-    this.goal.setScale(0.8);
+    this.goal.setScale(2.5);
     this.goal.setImmovable(true);
     this.goal.setDepth(5);
 
     // 创建守门员
     this.goalkeeper = this.physics.add.sprite(clientObj.value.width / 2, 150, 'goalkeeperAnim');
-    this.goalkeeper.setScale(0.9);
+    this.goalkeeper.setScale(2);
     this.goalkeeper.setImmovable(true);
     this.goalkeeper.anims.play('goalkeeperAnim', true);
     this.goalkeeper.setDepth(7);
@@ -1022,7 +1023,7 @@ class GameScene extends Phaser.Scene {
     this.physics.pause();
 
     // 显示游戏结束画面
-    this.add.image(clientObj.value.width / 2, clientObj.value.height / 2, 'gameOver').setOrigin(0.5);
+    this.add.image(clientObj.value.width / 2, clientObj.value.height / 2, 'gameOver').setOrigin(0.5).setDepth(100);
 
     // 触发游戏结束事件
     this.time.addEvent({

+ 2 - 2
src/views/game/components/fruit.vue

@@ -1615,8 +1615,8 @@ class PlayScene extends Phaser.Scene {
         setTimeout(() => {
           console.log('游戏结束,返回首页');
           // this.scene.start('main');
-          emit('confirmExit', { type: 1 });
-        }, 3000);
+          emit('confirmExit', { type: 2, area: props.currentGameArea });
+        }, 5000);
       }
     });
 

+ 31 - 6
src/views/game/index.vue

@@ -42,12 +42,12 @@
         <!---篮球投篮-->
         <div class="columns" v-if="currentGame == 'game_basketball'">
           <div class="item left">
-            <Basketball ref="basketballLeftRef" type="left" @confirmExit="getExitGame" :currentGameArea="currentGameArea[0]"
-              :areaStateList="areaStateList"></Basketball>
+            <Basketball ref="basketballLeftRef" type="left" @confirmExit="getExitGame"
+              :currentGameArea="currentGameArea[0]" :areaStateList="areaStateList"></Basketball>
           </div>
           <div class="item right">
-            <Basketball ref="basketballRightRef" type="right" @confirmExit="getExitGame" :currentGameArea="currentGameArea[1]"
-              :areaStateList="areaStateList"></Basketball>
+            <Basketball ref="basketballRightRef" type="right" @confirmExit="getExitGame"
+              :currentGameArea="currentGameArea[1]" :areaStateList="areaStateList"></Basketball>
           </div>
         </div>
         <!---足球带球-->
@@ -58,8 +58,8 @@
             </Football>
           </div>
           <div class="item right">
-            <Football ref="footballRightRef" type="right" @confirmExit="getExitGame" :currentGameArea="currentGameArea[1]"
-              :areaStateList="areaStateList">
+            <Football ref="footballRightRef" type="right" @confirmExit="getExitGame"
+              :currentGameArea="currentGameArea[1]" :areaStateList="areaStateList">
             </Football>
           </div>
         </div>
@@ -114,6 +114,24 @@ const data = reactive<any>({
 });
 const { projectList, wsState, bodyposeState, deviceInfo, currentGame, currentGameArea, start, areaStateList } = toRefs(data);
 
+/**
+ * 监听数据变化
+ */
+watch(
+  () => areaStateList.value,
+  (newData, oldData) => {
+    //如果当前都是结束了就再重新弹窗
+    let state = newData.every((item: any) => {
+      return item.gameover;
+    })
+    if (state) {
+      start.value = false;
+      actionConfirmRef.value.getOpen(currentGame.value, currentGameArea.value);
+    }
+  },
+  { deep: true }
+);
+
 /**
  * 初始化
  */
@@ -258,6 +276,13 @@ const getExitGame = (data: any) => {
     })
     currentGame.value = "";
     start.value = false;
+  } else if (data.type == 2) {
+    //游戏结束显示下一场
+
+    let myIndex = areaStateList.value.findIndex((item: any) => {
+      return item.area == data.area;
+    })
+    areaStateList.value[myIndex].gameover = true;
   } else {
     //游戏中退出
     proxy?.$modal.confirm("确定退出吗?").then(() => {