import { _EJsonRes } from "./Engine/Data/CommonDataType"; import Engine from "./Engine/Engine"; import EventManager from "./Engine/Event/EventManager"; import JsonResources from "./Engine/Resources/JsonResources"; import GameBehaviorTree from "./Game/BehaviorTree/GameBehaviorTree"; import DataManager from "./Game/Data/DataManager"; import { ConstObject, _EGameBehavior, _EGameJsonRes } from "./Game/Data/GameDataType"; import GameEventName from "./Game/Event/GameEventName"; import UnitManager from "./Game/Unit/UnitManager"; import InitLoadView from "./Game/View/InitLoadView/InitLoadView"; import SDKManager from "./Game/SDK/SDKManager"; import Tool from "./Engine/Tool/Tool"; const {ccclass, property} = cc._decorator; @ccclass export default class Helloworld extends cc.Component { start () { Tool.isLog = false; cc.assetManager.loadBundle("res/cocos", (err: Error, cocos: cc.AssetManager.Bundle) => { cc.assetManager.loadBundle("res/fgui", (err: Error, fgui: cc.AssetManager.Bundle) => { // 首次加载必要的配置表 let res: Array = [ _EJsonRes.GameConfig, _EJsonRes.ViewConfig, _EJsonRes.GameBehaviorTree, _EGameJsonRes.UserDataConfig, ]; JsonResources.loadJsonResources(ConstObject.ResPath, res, 0, 0, () => { Engine.create(() => { // 获取用户数据 EventManager.onEvent(GameEventName.UserData.UserData_ReadUserData, this, (gameBehavior: _EGameBehavior) => { // 创建游戏行为树 new GameBehaviorTree(this.node, JsonResources.getResources(_EJsonRes.GameBehaviorTree)); // 进入初始加载页 let map: Object = (fgui as any)._config.paths._map; let initLoadView: Array = []; for (let index in map) { if (index.includes(InitLoadView.resPath) == true) { initLoadView.push(index); } } fgui.load(initLoadView, (error: Error, assets: cc.Asset[]) => { EventManager.sendEventByTargetID(GameEventName.Behavior.Behavior_EnterBehavior, ConstObject.GameBehaviorTreeID, gameBehavior); }); }); // 创建全局管理器 Engine.managers.push(new UnitManager()); Engine.managers.push(new SDKManager()); Engine.managers.push(new DataManager()); }); }); }); }); } }