1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- import EventManager from "../../Engine/Event/EventManager";
- import Tool from "../../Engine/Tool/Tool";
- import { _EUnitType, _ICreateUnit } from "../Game/Data/Unit/UnitConfig";
- import GameEventName from "../Event/GameEventName";
- import BasicObject from "../../Engine/Basic/BasicObject";
- /**
- * 实体单元
- * @param 设计目的 规范实体单元的拓展,便于修改、维护
- * @param 可能问题 任意拓展后,出现难以预计的情况
- */
- export default abstract class Unit extends BasicObject {
-
- protected _createUnit: _ICreateUnit;
- constructor (createUnit: _ICreateUnit) {
- super();
- this._createUnit = createUnit;
- this._isUpdate = createUnit.isUpdate;
- // 替换唯一ID
- if (this._createUnit.unitID != null) {
- this._id = this._createUnit.unitID;
- }
- this.createNode();
- this.createComponents();
-
- Tool.log(this);
- EventManager.sendEvent(GameEventName.Unit.Unit_CreateUnitComplete, this);
- EventManager.onEvent(GameEventName.Unit.Unit_ReuseUnit, this, this.onReuseUnit, 1);
- }
- /**获得创建数据 */
- public get createUnit (): Readonly<_ICreateUnit> {
- return this._createUnit;
- }
- /**获得节点 */
- public abstract get fgui (): fgui.GComponent;
- /**获得类型 */
- public abstract get type (): _EUnitType;
- /**创建节点 */
- protected abstract createNode (): void;
- /**创建组件 */
- protected abstract createComponents (): void;
- protected onReuseUnit (createUnit: _ICreateUnit): void {
- this._createUnit = createUnit;
- this._isUpdate = createUnit.isUpdate;
- }
- }
|