RootScene.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import { _EJsonRes } from "./Engine/Data/CommonDataType";
  2. import Engine from "./Engine/Engine";
  3. import EventManager from "./Engine/Event/EventManager";
  4. import JsonResources from "./Engine/Resources/JsonResources";
  5. import { _EGameFlow } from "./Game/GameFlowTree/Data/GameFlowConfig";
  6. import GameFlowTree from "./Game/GameFlowTree/GameFlowTree";
  7. import DataManager from "./Game/Data/DataManager";
  8. import { ConstObject, _EGameJsonRes } from "./Game/Data/GameDataType";
  9. import GameEventName from "./Game/Event/GameEventName";
  10. import UnitManager from "./Game/Unit/UnitManager";
  11. import InitLoadView from "./Game/View/InitLoadView/InitLoadView";
  12. import Tool from "./Engine/Tool/Tool";
  13. import SDKManager from "./Game/SDK/SDKManager";
  14. const {ccclass, property} = cc._decorator;
  15. /**
  16. * 启动类 - 逻辑层
  17. */
  18. @ccclass
  19. export default class Helloworld extends cc.Component {
  20. start () {
  21. Tool.isLog = false;
  22. ConstObject.IsEnableTouch = false;
  23. cc.assetManager.loadBundle("res/cocos", (err: Error, cocos: cc.AssetManager.Bundle) => {
  24. cc.assetManager.loadBundle("res/fgui", (err: Error, fgui: cc.AssetManager.Bundle) => {
  25. // 首次加载必要的配置表
  26. let res: Array<string> = [
  27. _EJsonRes.Game,
  28. _EJsonRes.View,
  29. _EJsonRes.GameFlowTree,
  30. _EGameJsonRes.UserData,
  31. ];
  32. JsonResources.loadJsonResources(ConstObject.ResPath, res, 0, 0, () => {
  33. new Engine((engine: Engine) => {
  34. // 获取用户数据
  35. EventManager.onEvent(GameEventName.UserData.UserData_ReadUserData, this, (gameFlow: _EGameFlow) => {
  36. // 创建游戏流程树
  37. new GameFlowTree(this.node, JsonResources.getResources(_EJsonRes.GameFlowTree));
  38. // 进入初始加载页
  39. let map: Object = (fgui as any)._config.paths._map;
  40. let initLoadView: Array<string> = [];
  41. for (let index in map) {
  42. if (index.includes(InitLoadView.resPath) == true) {
  43. initLoadView.push(index);
  44. }
  45. }
  46. fgui.load(initLoadView, (error: Error, assets: cc.Asset[]) => {
  47. EventManager.sendEventByTargetID(GameEventName.Behavior.Behavior_EnterBehavior, ConstObject.GameFlowTreeID, gameFlow);
  48. });
  49. });
  50. // 创建全局管理器
  51. engine.managers.push(new UnitManager());
  52. engine.managers.push(new SDKManager());
  53. engine.managers.push(new DataManager());
  54. });
  55. });
  56. });
  57. });
  58. }
  59. }