RootScene.ts 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 = true;
  22. ConstObject.IsEnableTouch = false;
  23. cc.game.setFrameRate(59);
  24. cc.assetManager.loadBundle("res/cocos", (err: Error, cocos: cc.AssetManager.Bundle) => {
  25. cc.assetManager.loadBundle("res/fgui", (err: Error, fgui: cc.AssetManager.Bundle) => {
  26. // 首次加载必要的配置表
  27. let res: Array<string> = [
  28. _EJsonRes.Game,
  29. _EJsonRes.View,
  30. _EJsonRes.GameFlowTree,
  31. _EGameJsonRes.UserData,
  32. ];
  33. JsonResources.loadJsonResources(ConstObject.ResPath, res, 0, 0, () => {
  34. new Engine((engine: Engine) => {
  35. // 获取用户数据
  36. EventManager.onEvent(GameEventName.UserData.UserData_ReadUserData, this, (gameFlow: _EGameFlow) => {
  37. // 创建游戏流程树
  38. new GameFlowTree(this.node, JsonResources.getResources(_EJsonRes.GameFlowTree));
  39. // 进入初始加载页
  40. let map: Object = (fgui as any)._config.paths._map;
  41. let initLoadView: Array<string> = [];
  42. for (let index in map) {
  43. if (index.includes(InitLoadView.resPath) == true) {
  44. initLoadView.push(index);
  45. }
  46. }
  47. fgui.load(initLoadView, (error: Error, assets: cc.Asset[]) => {
  48. EventManager.sendEventByTargetID(GameEventName.Behavior.Behavior_EnterBehavior, ConstObject.GameFlowTreeID, gameFlow);
  49. });
  50. });
  51. // 创建全局管理器
  52. engine.managers.push(new UnitManager());
  53. engine.managers.push(new SDKManager());
  54. engine.managers.push(new DataManager());
  55. });
  56. });
  57. });
  58. });
  59. }
  60. }