Files
rougelike-demo/client/assets/scripts/Boot/Boot.ts

82 lines
2.1 KiB
TypeScript
Raw Normal View History

2025-12-14 22:41:50 +08:00
import { _decorator, Component } from 'cc';
import { AppStatusManager } from '../App/AppStatus/AppStatusManager';
const { ccclass, property } = _decorator;
/**
* Boot启动组件
*
* 使:
* 1. Cocos Creator中打开主场景(main.scene)
* 2. , "Boot"
* 3. Boot节点上
* 4. ,
*
* :
* -
* - AppStatusManager
* -
* -
*/
@ccclass('Boot')
export class Boot extends Component {
private _appStatusManager: AppStatusManager | null = null;
/**
*
*/
start() {
console.log("=================================");
console.log(" Cocos3.x Roguelike Game");
console.log(" Boot Component Started");
console.log("=================================");
// 初始化并启动应用
this.initApp();
}
/**
*
*/
private initApp(): void {
console.log("[Boot] 初始化应用...");
try {
// 1. 获取AppStatusManager单例
this._appStatusManager = AppStatusManager.getInstance();
// 2. 启动应用(从Boot状态开始)
this._appStatusManager.start();
console.log("[Boot] 应用启动成功");
} catch (error) {
console.error("[Boot] 应用启动失败:", error);
}
}
/**
*
* @param deltaTime ()
*/
update(deltaTime: number) {
// 更新应用状态机
if (this._appStatusManager) {
this._appStatusManager.update(deltaTime);
}
}
/**
*
*/
onDestroy() {
console.log("[Boot] 组件销毁");
// 销毁应用状态管理器
if (this._appStatusManager) {
this._appStatusManager.destroy();
this._appStatusManager = null;
}
}
}