浏览代码

fixed 体力bug

woso_javan 3 周之前
父节点
当前提交
3cf0d4ac80

+ 0 - 9
assets/module_aliens/Image.meta

@@ -1,9 +0,0 @@
-{
-  "ver": "1.2.0",
-  "importer": "directory",
-  "imported": true,
-  "uuid": "765f6c68-85c2-4c7d-b7cb-a11d2be26205",
-  "files": [],
-  "subMetas": {},
-  "userData": {}
-}

+ 9 - 4
assets/module_aliens/Prefabs/UI/PowerUp/UI_PowerUp_Impl.ts

@@ -28,19 +28,24 @@ export class UI_PowerUp_Impl extends UI_PowerUp {
             AliensAudioMgr.playOneShot(AliensAudioMgr.getMusicIdName(2), 1.0);
             if (!GlobalConfig.isDebug) {
                 AdvertMgr.instance.showReawardVideo(() => {
-
+                    this.addPower();
                 })
             } else {
-                this.hide();
-                UserManager.instance.addPower(1);
-                EventDispatcher.instance.emit(GameEvent.EVENT_GAME_ENTER);
+                this.addPower();
             }
         });
         this.onButtonEvent(layout.btn_back, () => {
             AliensAudioMgr.playOneShot(AliensAudioMgr.getMusicIdName(2), 1.0);
             this.hide();
+            EventDispatcher.instance.emit(GameEvent.EVENT_GAME_BACK_HOME);
         });
     }
+
+    private addPower() {
+        this.hide();
+        UserManager.instance.addPower(1);
+        EventDispatcher.instance.emit(GameEvent.EVENT_GAME_ENTER);
+    }
 }
 
 tgxModuleContext.attachImplClass(UI_PowerUp, UI_PowerUp_Impl);

+ 11 - 3
assets/module_aliens/Prefabs/UI/Result/UI_BattleResult_Impl.ts

@@ -1,7 +1,7 @@
 import { isValid, Label, tween, v3, Vec3, Node, Tween } from "cc";
-import { tgxModuleContext } from "../../../../core_tgx/tgx";
+import { tgxModuleContext, tgxUIMgr } from "../../../../core_tgx/tgx";
 import { GameUILayers } from "../../../../scripts/GameUILayers";
-import { UI_BattleResult } from "../../../../scripts/UIDef";
+import { UI_BattleResult, UI_PowerUp } from "../../../../scripts/UIDef";
 import { Layout_BattleResult } from "./Layout_BattleResult";
 import { GameEvent } from "../../../Script/Enum/GameEvent";
 import { LevelManager } from "../../../Script/Manager/LevelMgr";
@@ -78,7 +78,15 @@ export class UI_BattleResult_Impl extends UI_BattleResult {
         if (this.win) {
             LevelManager.instance.levelUpHandler();
         } else {
-            LevelManager.instance.restartLevelHandler();
+            const power = UserManager.instance.reducePower(1);
+            if (!power) {
+                const match = tgxUIMgr.inst.isShowing(UI_PowerUp);
+                if (!match) {
+                    tgxUIMgr.inst.showUI(UI_PowerUp);
+                }
+                return;
+            }
+            // LevelManager.instance.restartLevelHandler();
         }
     }
 

+ 6 - 0
assets/module_aliens/RoosterAliens.ts

@@ -59,6 +59,7 @@ export class RoosterAliens extends Component {
 
         EventDispatcher.instance.on(GameEvent.EVENT_GAME_ENTER,this.onStart,this);
         EventDispatcher.instance.on(GameEvent.EVENT_CAMERA_HIDE_AIM,this.onClickResetAim,this);
+        EventDispatcher.instance.on(GameEvent.EVENT_GAME_BACK_HOME,this.backHome,this);
     }
 
     private onClickSet(): void {
@@ -106,6 +107,11 @@ export class RoosterAliens extends Component {
         AliensGlobalInstance.instance.battleUI.active = true;
         UserManager.instance.reducePower(1);
     }
+
+    private backHome(): void {
+        AliensGlobalInstance.instance.homeUI.active = true;
+        AliensGlobalInstance.instance.battleUI.active = false; 
+    }
 }
 
 

+ 2 - 0
assets/module_aliens/Script/Enum/GameEvent.ts

@@ -5,6 +5,8 @@ export class GameEvent {
     static readonly EVENT_GAME_START = 'EVENT_GAME_START';
     /** 进入游戏*/
     static readonly EVENT_GAME_ENTER = 'EVENT_GAME_ENTER';
+    /** 回到主页HOME*/
+    static readonly EVENT_GAME_BACK_HOME = 'EVENT_GAME_BACK_HOME';
     /** 游戏暂停*/
     static readonly EVENT_GAME_PAUSE = 'EVENT_GAME_PAUSE';
 

+ 4 - 2
assets/module_aliens/Script/HomeUI.ts

@@ -89,8 +89,10 @@ export class HomeUI extends Component {
 
     private updatePowerUI() {
         if(!this.lbPower) return;
-        this.lbPower.string = this.powerCurrent.toString();
-        if (this.powerCurrent >= this.powerMax) {
+
+        const {powerCurrent} = UserManager.instance.userModel;
+        this.lbPower.string = powerCurrent.toString();
+        if (powerCurrent >= this.powerMax) {
             this.lbTimeCount.string = 'Max';
         }
     }

+ 1 - 1
assets/module_aliens/Script/Manager/TimerMgr.ts

@@ -133,6 +133,6 @@ export class TimerMgr {
         director.getScheduler().unscheduleAllForTarget(this);
         this.addTimeCount = 0;
         this.countDownTime = LevelManager.instance.levelModel.levelTime;
-        // this.countDownTime = 3; //测试
+        this.countDownTime = 3; //测试
     }
 }

+ 1 - 4
assets/module_aliens/rooster_aliens.scene

@@ -5289,10 +5289,7 @@
       "b": 255,
       "a": 255
     },
-    "_spriteFrame": {
-      "__uuid__": "a92f5b0d-c5a4-4604-b4a4-27ac18d0fec7@f9941",
-      "__expectedType__": "cc.SpriteFrame"
-    },
+    "_spriteFrame": null,
     "_type": 0,
     "_fillType": 0,
     "_sizeMode": 0,