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.
53 lines
1.6 KiB
53 lines
1.6 KiB
import { _decorator, Component, EventTouch, Node } from 'cc';
|
|
import { MapGrid } from './MapGrid';
|
|
import { GEvent } from 'db://assets/mx/module/event/GEvent';
|
|
|
|
const { ccclass } = _decorator;
|
|
|
|
/** 地图推荐摆放点引导(绑定 isBestPlace / isFreePlace / ShowGuidePos) */
|
|
@ccclass('MapPosGuide')
|
|
export class MapPosGuide extends Component {
|
|
grid: MapGrid = null;
|
|
anim: Node = null;
|
|
|
|
protected onLoad(): void {
|
|
this.anim = this.node.getChildByName('anim');
|
|
}
|
|
|
|
protected start(): void {
|
|
this.updateShow();
|
|
}
|
|
|
|
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(): void {
|
|
this.updateShow();
|
|
}
|
|
|
|
onExitEdit(): void {
|
|
this.updateShow();
|
|
}
|
|
|
|
updateShow(): void {
|
|
let show = false;
|
|
const battle = gg.game.CurentBattle as { GuidePosVisualVisible?: boolean; IsEdit?: boolean } | null;
|
|
if (battle?.GuidePosVisualVisible) {
|
|
if (this.grid?.ShowGuidePos) show = true;
|
|
if (this.grid?.isFreePlace && battle.IsEdit) show = true;
|
|
}
|
|
if (!this.grid?.isCanWalk || !this.grid?.isCanPutGrid) show = false;
|
|
if (this.anim) {
|
|
this.anim.active = show;
|
|
}
|
|
}
|
|
}
|
|
|