UECell.ts 996 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import UEBase from "../../frameWork/compment/UEBase";
  2. import UECube from "./UECube";
  3. const { ccclass, property } = cc._decorator;
  4. export interface I_CellData {
  5. zIndex: number;
  6. ueCube: UECube;
  7. }
  8. @ccclass
  9. export default class UECell extends UEBase {
  10. static readonly BundleKey: string = "gridMap";
  11. static readonly PrefabUrl: string = "UECell";
  12. static readonly CLS: string = "UECell";
  13. @property(cc.Node)
  14. private node_select: cc.Node = null!;
  15. cellData: I_CellData = null!;
  16. Init(cellData: I_CellData) {
  17. this.cellData = cellData;
  18. this.node.zIndex = cellData.zIndex;
  19. }
  20. SetSelect(isSelect: boolean) {
  21. this.node_select.active = isSelect;
  22. }
  23. /** 是否有物品可以拖动 */
  24. CanDrag(): boolean {
  25. return !this.IsEmpty();
  26. }
  27. GetCube(): UECube {
  28. return this.cellData.ueCube;
  29. }
  30. /** 该棋格是否是空的 */
  31. IsEmpty(): boolean {
  32. return this.cellData.ueCube == null;
  33. }
  34. }