|
@@ -2,12 +2,27 @@ import { _decorator, Component } from 'cc';
|
|
|
import { CarColors } from './CarColorsGlobalTypes';
|
|
|
import { PinComponent } from './Components/PinComponent';
|
|
|
import { LayerAction } from './LayerAction';
|
|
|
+import { EventDispatcher } from '../../core_tgx/easy_ui_framework/EventDispatcher';
|
|
|
+import { GameEvent } from './Enum/GameEvent';
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@ccclass('UnitAction')
|
|
|
export class UnitAction extends Component {
|
|
|
start() {
|
|
|
+ EventDispatcher.instance.on(GameEvent.EVENT_UPDATE_LAYER, this.onCheckLayerChild, this);
|
|
|
+ }
|
|
|
+
|
|
|
+ onCheckLayerChild() {
|
|
|
+ if (!this.node) return
|
|
|
|
|
|
+ this.node.children.forEach(layer_node => {
|
|
|
+ const layer_action = layer_node.getComponent(LayerAction)!;
|
|
|
+ if (layer_action.node.children.length <= 0) {
|
|
|
+ console.log('删除一个Layer层 没有element元素了---->')
|
|
|
+ layer_action.node.removeFromParent();
|
|
|
+ layer_action.node.destroy();
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
update(deltaTime: number) {
|