import UEBase from "../../frameWork/compment/UEBase"; import UECube from "./UECube"; const { ccclass, property } = cc._decorator; export interface I_CellData { zIndex: number; ueCube: UECube; } @ccclass export default class UECell extends UEBase { static readonly BundleKey: string = "gridMap"; static readonly PrefabUrl: string = "UECell"; static readonly CLS: string = "UECell"; @property(cc.Node) private node_select: cc.Node = null!; cellData: I_CellData = null!; Init(cellData: I_CellData) { this.cellData = cellData; this.node.zIndex = cellData.zIndex; } SetCube(cube: UECube) { this.cellData.ueCube = cube; if (cube) { this.cellData.ueCube.SetZIndex(this.cellData.zIndex); } } SetSelect(isSelect: boolean) { this.node_select.active = isSelect; } /** 是否有物品可以拖动 */ CanDrag(): boolean { return !this.IsEmpty(); } GetCube(): UECube { return this.cellData.ueCube; } /** 该棋格是否是空的 */ IsEmpty(): boolean { return this.cellData.ueCube == null; } MoveCubeToCell(toCell: UECell) { this.cellData.ueCube.MoveToNewPos(toCell.node.position.clone()); } }