123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- 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.director.getScene().getChildByName("Canvas").zIndex = 100;
-
- 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<string> = [
- _EJsonRes.GameConfig,
- _EJsonRes.ViewConfig,
- _EJsonRes.GameBehaviorTree,
- _EGameJsonRes.UserDataConfig,
- ];
-
- JsonResources.loadJsonResources(ConstObject.ResPath, res, 0, 0, () => {
- new Engine((engine: Engine) => {
- // 获取用户数据
- 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<string> = [];
- 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());
- });
- });
- });
- });
- }
- }
|