林旭祥 1 mēnesi atpakaļ
vecāks
revīzija
fd0f4b13cf
1 mainītis faili ar 18 papildinājumiem un 3 dzēšanām
  1. 18 3
      src/views/game/fruit.vue

+ 18 - 3
src/views/game/fruit.vue

@@ -1354,9 +1354,24 @@ class PlayScene extends Phaser.Scene {
 
   startFruit() {
 
-    const number = Math.floor(mathTool.randomMinMax(1, 3));
-    const hasBomb = Math.random() > 0.9; // 炸弹概率
-    const bombIndex = hasBomb ? Math.floor(Math.random() * number) : -1;
+  // 根据分数动态调整数量:分数越高,生成越多水果
+  let min = 1;
+  let max = 1;
+  
+  if (this.score >=0 && this.score <30) {
+    min = 1;
+    max = 1;
+  } else if (this.score >=30 && this.score <60) {
+    min = 1;
+    max = 2;
+  }else{
+    min = 2;
+    max = 3;
+  }
+
+  const number = Math.floor(mathTool.randomMinMax(min, max + 1)); // +1是因为randomMinMax的max是 exclusive
+  const hasBomb = Math.random() > 0.9;
+  const bombIndex = hasBomb ? Math.floor(Math.random() * number) : -1;
 
     for (let i = 0; i < number; i++) {
       if (i === bombIndex) {