123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- 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);
- }
- }
- GetZIndex() {
- return 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;
- }
- /** 清空棋格里的棋子 */
- ClearCube() {
- this.cellData.ueCube.unUse();
- this.cellData.ueCube = null;
- }
- MoveCubeToCell(toCell: UECell) {
- this.cellData.ueCube.MoveToNewPos(toCell.node.position.clone());
- }
- }
|