1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- import BasicManager from "./Basic/BasicManager";
- import BasicObject from "./Basic/BasicObject";
- import EventManager from "./Event/EventManager";
- import { EventName } from "./Event/EventName";
- import AudioManager from "./Audio/AudioManager";
- import TimeManager from "./Time/TimeManager";
- import Tool from "./Tool/Tool";
- import ViewManager from "./View/ViewManager";
- import PoolManager from "./Pool/PoolManager";
- /**
- * 注意事项
- * 1、引擎层不因为游戏层的需求而更改,修改引擎层时要谨慎考虑
- * 2、禁止在声明成员变量时传值,声明Object中的属性除外,但仍要注意是否被覆盖
- * 3、所有缓动功能必须使用Tool.Tween.tweenTo(...),防止不可控
- * 4、所有计时器功能必须使用TimeManager.schedule(...),防止不可控
- * 5、接口前缀需要加 _I,枚举前缀需要加 _E,若与配置表数据对应,需要加后缀Config
- * 6、数据层、逻辑层与表现层分离
- * 7、所有类名需要加后缀,写明数据层、逻辑层、表现层;程序执行流程,数据层->逻辑层->表现层
- * 8、若函数响应事件,且参数大于1个,需要定义接口规范参数,...args类型参数除外
- */
- /**
- * 引擎类 - 逻辑层
- */
- export default class Engine extends BasicObject {
- public managers: Array<BasicManager>;
-
- constructor (custom: Function) {
- super();
- Tool.log("启动引擎");
- this.managers = new Array<BasicManager>();
- // 创建必要管理器
- EventManager.create();
- this.managers.push(new ViewManager());
- this.managers.push(new AudioManager());
- this.managers.push(new TimeManager());
- this.managers.push(new PoolManager());
- // 自定义进入游戏流程
- custom(this);
- Tool.log("启动完毕");
- Tool.log("");
- EventManager.onEvent(EventName.Game_QuitGame, this, () => {
- Tool.log("关闭引擎");
- for (let index in this.managers) {
- this.managers[index]._destroy();
- }
- this.managers = null;
- this._destroy();
- EventManager.destroy();
- cc.assetManager.releaseAll();
- Tool.log("退出游戏");
- });
- }
- }
|