Files
Pizza/assets/GameLaunch.ts
wuguiyu 1512bf46d1 初始化工程
基础玩法代码
修复回收对象池回收后还出现在手上
顾客移动速度
引导箭头
收银员触发发放披萨圈
pizza机的Max
主角Max
顾客吃完留钞票
顾客优先拼桌
顾客就餐位置
完善地块解锁(解锁图标宽高不对)
2026-03-03 11:58:26 +08:00

118 lines
3.4 KiB
TypeScript

import { _decorator } from "cc";
import GameApp from "./GameApp";
import BaseLaunch from "./scripts/base/architecture/BaseLaunch";
import BaseModule from "./scripts/base/architecture/module/BaseModule";
import CommonModule from "./scripts/module/common/CommonModule";
import { SceneConst } from "./scripts/define/SceneConst";
import { LoadingEvent } from "./scripts/module/common/loading/LoadingConst";
import GameModule from "./scripts/module/game/GameModule";
import { ConfigConst } from "./scripts/define/ConfigConst";
const { ccclass, property } = _decorator;
@ccclass
export default class GameLaunch extends BaseLaunch {
// 修改这个,会影响本地数据存储
gameName: string = "demo";
// 修改这个,会影响本地数据存储
version: string = "v1";
// 游戏模块
moduleList: BaseModule[] = [
CommonModule.GetInstance(),
GameModule.GetInstance(),
];
async init() {
const _this = this;
GameApp.S.SceneMgr.getCurScene().open();
// sdk初始化
await GameApp.S.SDKMgr.init();
// 预加载场景
let loadScenePromise = _this.preloadScene();
// 初始化策略
_this.initStrategy();
// 初始化资源bundle
await _this.initBundle();
// 初始化功能模块
_this.initModules();
GameApp.S.DataMgr.setProjectTag(`${_this.gameName}_${_this.version}`)
await loadScenePromise
}
async preloadScene() {
let sceneList = [SceneConst.Game]
let curFinishCount = 0
let needLoadingCount = sceneList.length
GameApp.S.EventMgr.emit(LoadingEvent.LoadingScene, curFinishCount, needLoadingCount)
let asyncList = []
for (let i = 0; i < sceneList.length; i++) {
let loadScene = sceneList[i];
asyncList.push(new Promise<void>(async (r, j) => {
await GameApp.S.SceneMgr.preload(loadScene);
curFinishCount++
GameApp.S.EventMgr.emit(LoadingEvent.LoadingScene, curFinishCount, needLoadingCount)
r();
}))
}
await Promise.all(asyncList);
}
async initBundle() {
let _this = this
let bundleList = [
GameApp.S.ResMgr.addBundle("resources"),
GameApp.S.ResMgr.addBundle("common"),
]
_this.moduleList.forEach(module => {
bundleList.push(...module.loadBundle())
});
let curFinishCount = 0
let needLoadingCount = bundleList.length
GameApp.S.EventMgr.emit(LoadingEvent.LoadingBundle, curFinishCount, needLoadingCount)
let asyncList = []
for (let i = 0; i < bundleList.length; i++) {
let loadBundle = bundleList[i];
asyncList.push(new Promise<void>(async (r, j) => {
await loadBundle
curFinishCount++
GameApp.S.EventMgr.emit(LoadingEvent.LoadingBundle, curFinishCount, needLoadingCount)
r();
}))
}
await Promise.all(asyncList);
await GameApp.S.ConfigMgr.loadConfig<GameConfig>(ConfigConst.GameData)
}
initModules(): void {
// 初始化配置文件
this.moduleList.forEach(module => {
module.initConfig()
});
// 初始化模块
this.moduleList.forEach(module => {
module.initModel()
});
}
}