12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- 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!;
- @property(cc.Node)
- private node_select: cc.Node = null!;
- @property(cc.Node)
- private sp_item: cc.Node = 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;
- }
- SetSelect(isSelect: boolean) {
- this.node_select.active = isSelect;
- }
- 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;
- this.PlayJellyAnim();
- }
- }
- ClearCell() {
- }
- /** 播放果冻效果 */
- PlayJellyAnim() {
- cc.tween(this.itemNode)
- .to(0.15, { position: cc.Vec3.ZERO })
- .to(0.1, { scale: 1.3 })
- .to(0.1, { scale: 0.9 })
- .to(0.08, { scale: 1 })
- .start();
- }
- /** 播放合成动画 */
- PlayMergeAnim() {
- cc.tween(this.itemNode)
- .by(0.1, { position: cc.v3(0, 40) })
- .by(0.1, { position: cc.v3(0, -40) })
- .by(0.1, { position: cc.v3(0, 10) })
- .by(0.1, { position: cc.v3(0, -10) })
- .start();
- }
- private UpdateItemDisplay(): void {
- // 根据 itemType 和 itemLevel 更新物品显示
- if (this.itemNode) {
- this.itemNode.active = true;
- // TODO: 更新物品的具体显示效果
- }
- }
- }
|