|
@@ -1,7 +1,8 @@
|
|
|
-import { assetManager, instantiate, Prefab, Node, UITransform, Vec3, Vec2, view, game, director, Scheduler } from "cc";
|
|
|
+import { assetManager, instantiate, Prefab, Node, UITransform, Vec3, Vec2, view, game, director, Scheduler, Label } from "cc";
|
|
|
import { resLoader } from "db://assets/core_tgx/base/ResLoader";
|
|
|
import { StormSunderGlobalInstance } from "../StormSunderGlobalInstance";
|
|
|
import { PropMgr } from "./PropMgr"; // 假设PropMgr在同一个目录下
|
|
|
+import { GameMgr, GameStatus } from "./GameMgr";
|
|
|
|
|
|
/** 时间管理器*/
|
|
|
export class TimerMgr {
|
|
@@ -33,17 +34,25 @@ export class TimerMgr {
|
|
|
this.stopCountdown();
|
|
|
console.log("Countdown finished!");
|
|
|
}
|
|
|
+ this.upateLbTime();
|
|
|
}, 1000); // 每秒减少一次
|
|
|
|
|
|
Scheduler.enableForTarget(this);
|
|
|
director.getScheduler().schedule(this.update, this, 0);
|
|
|
}
|
|
|
|
|
|
+ private upateLbTime() {
|
|
|
+ const battleUI = StormSunderGlobalInstance.instance.battleUI;
|
|
|
+ const lbTime = battleUI.getChildByName('LbTime')!;
|
|
|
+ lbTime.getComponent(Label).string = this.countDownTime.toString();
|
|
|
+ }
|
|
|
+
|
|
|
// 停止倒计时
|
|
|
private stopCountdown(): void {
|
|
|
if (this.timerId) {
|
|
|
clearInterval(this.timerId);
|
|
|
this.timerId = 0;
|
|
|
+ GameMgr.inst.setGameStatus(GameStatus.End);
|
|
|
}
|
|
|
}
|
|
|
|