You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.3 KiB
46 lines
1.3 KiB
import { _decorator, Component, EventTouch, Node } from 'cc';
|
|
import { MapGrid } from './MapGrid';
|
|
import { GEvent } from 'db://assets/mx/module/event/GEvent';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('MapPosGuide')
|
|
export class MapPosGuide extends Component {
|
|
|
|
grid: MapGrid = null;
|
|
anim: Node = null;
|
|
|
|
protected onLoad(): void {
|
|
this.anim = this.node.getChildByName('anim');
|
|
}
|
|
|
|
protected onEnable(): void {
|
|
GEvent.Ins.on(GEvent.EnterEdit, this.onEnterEdit, this);
|
|
GEvent.Ins.on(GEvent.ExitEdit, this.onExitEdit, this);
|
|
GEvent.Ins.on(GEvent.UpdateBestPlace, this.updateShow, this);
|
|
}
|
|
|
|
protected onDisable(): void {
|
|
GEvent.Ins.off(GEvent.EnterEdit, this.onEnterEdit, this);
|
|
GEvent.Ins.off(GEvent.ExitEdit, this.onExitEdit, this);
|
|
GEvent.Ins.off(GEvent.UpdateBestPlace, this.updateShow, this);
|
|
}
|
|
|
|
onEnterEdit() {
|
|
this.updateShow();
|
|
}
|
|
|
|
onExitEdit() {
|
|
this.updateShow();
|
|
}
|
|
|
|
updateShow() {
|
|
let show = false;
|
|
if (this.grid?.isFreePlace) show = true;
|
|
if (this.grid?.ShowGuidePos) show = true;
|
|
if (!this.grid.isCanPutObstacle) show = false;
|
|
if (!gg.game.CurentBattle.IsEdit) show = false;
|
|
this.anim.active = show;
|
|
}
|
|
}
|
|
|
|
|
|
|