import UEBase from "../../frameWork/compment/UEBase"; const { ccclass, property } = cc._decorator; export interface I_CellData { id: number; type: number; level?: number; zIndex: number; } @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 itemNode: cc.Node = null!; @property(cc.Label) private lbt_num: cc.Label = null!; private originalPos: cc.Vec3 = cc.v3(0, 0); cellData: I_CellData = null!; Init(cellData: I_CellData, idx: number) { this.cellData = cellData; this.node.zIndex = cellData.zIndex; this.lbt_num.string = idx.toString(); this.originalPos = this.node.position; } /** 是否有物品可以拖动 */ CanDrag(): boolean { return true; } StartDrag(): void { this.node.zIndex = 1000; } UpdateDragPosition(pos: cc.Vec3): void { if (this.itemNode) { this.itemNode.position = pos.sub(this.node.position); } } EndDrag(): void { if (this.itemNode) { this.node.zIndex = this.cellData.zIndex; cc.tween(this.itemNode) .to(0.15, { position: cc.Vec3.ZERO }) .call(() => { this.itemNode.scale = 1.3; }) .to(0.3, { scale: 1 }) .to(0.2, { scale: 1.1 }) .to(0.2, { scale: 1 }) .start(); } } private UpdateItemDisplay(): void { // 根据 itemType 和 itemLevel 更新物品显示 if (this.itemNode) { this.itemNode.active = true; // TODO: 更新物品的具体显示效果 } } }