wuwangdong 4 лет назад
Родитель
Сommit
7e518adc85
2 измененных файлов с 29 добавлено и 19 удалено
  1. 26 13
      assets/script/before/GamePlay.ts
  2. 3 6
      assets/script/game/game/Game.ts

+ 26 - 13
assets/script/before/GamePlay.ts

@@ -169,8 +169,7 @@ export default class GamePlay extends cc.Component {
     }
 
     //刷新计时
-    private curTime = 0;
-    private isAllShow = false;
+    public isAllShow = false;
     private isShowRedPacket = true;
 
     // LIFE-CYCLE CALLBACKS:
@@ -1216,35 +1215,49 @@ export default class GamePlay extends cc.Component {
     }
 
     public doBubbleRedPacketLogic(dt) {
+
         if (!this.isShowRedPacket) {
             return;
         }
         if (this.isAllShow) {
+            if(gData.gameData.redPacketShowCount != 0)
+            {
+                gData.gameData.redPacketShowCount = 0;
+            }
             return;
         }
 
-        this.curTime += dt;
-
-        if (this.curTime >= gData.gameData.redPacketTime * 60) {
-            this.curTime = 0;
+        let count = 0;
+        let len = gData.gameData.redPacketShowCount;
+        for(let i = 0; i != len; ++i)
+        {
             if (!this.btn_gameGetRed1.active) {
                 this.btn_gameGetRed1.active = true;
-                //cc.tween(this.btn_getRed1).to(1.2, { y: 100 }).to(1.2, { y: 50 }).union().repeatForever().start();
-                return;
+                ++count;  
+                continue;
             } else if (!this.btn_gameGetRed2.active) {
                 this.btn_gameGetRed2.active = true;
-                //cc.tween(this.btn_getRed2).delay(0.2).to(1.5, { y: 125 }).to(1.5, { y: 50 }).union().repeatForever().start();
-                return;
+                ++count; 
+                continue;
             } else if (!this.btn_gameGetRed3.active) {
                 this.btn_gameGetRed3.active = true;
-                //cc.tween(this.btn_getRed3).delay(0.4).to(1, { y: 10 }).to(1, { y: -50 }).union().repeatForever().start();
-                return;
+                ++count; 
+                continue;
             } else if (!this.btn_gameGetRed4.active) {
                 this.btn_gameGetRed4.active = true;
+                ++count; 
+                continue;
             }
-
             this.isAllShow = true;
+            gData.gameData.redPacketShowCount = 0;
+            count = 0;
+        }
+
+        if(count > 0)
+        {
+            gData.gameData.redPacketShowCount -= count;
         }
+             
     }
 
     private refreshRedPacketUI(index) {

+ 3 - 6
assets/script/game/game/Game.ts

@@ -126,6 +126,7 @@ export default class Game extends cc.Component {
         }
 
         this.doBubbleRedPacketLogic(dt);
+        this.doBubbleRedPacketLogic2(dt);
     }
     lateUpdate() {
         gData.gameData.init_head = false;
@@ -356,13 +357,9 @@ export default class Game extends cc.Component {
         {
             return;
         }
-        if (this.isAllShow2) {
-            return;
-        }
-
+    
         this.curTime2 += dt;
-
-        if (this.curTime2 >= gData.gameData.redPacketTime * 60) {
+        if (this.curTime2 >= gData.gameData.redPacketTime * 10) {
             this.curTime2 = 0;
             gData.gameData.redPacketShowCount += 1;
         }