123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- import Gamecfg from "../../common/gameCfg";
- import ResSprite from "../../frameWork/compment/ResSprite";
- import UEBase from "../../frameWork/compment/UEBase";
- const { ccclass, property } = cc._decorator;
- export interface I_CubeData {
- /** 物品类型 */
- type: number;
- /** 物品ID */
- id: number;
- /** 层级 */
- zIndex: number;
- /** 解锁条件 */
- unlock: number
- }
- @ccclass
- export default class UECube extends UEBase {
- static readonly BundleKey: string = "gridMap";
- static readonly PrefabUrl: string = "UECube";
- static readonly CLS: string = "UECube";
- @property(cc.Node)
- private itemNode: cc.Node = null!;
- @property(cc.Label)
- private lbt_num: cc.Label = null!;
- @property(ResSprite)
- private sp_item: ResSprite = null!;
- private originalPos: cc.Vec3 = cc.v3(0, 0);
- cellData: I_CubeData = null!;
- Init(cellData: I_CubeData, idx: number) {
- this.cellData = cellData;
- this.node.zIndex = cellData.zIndex;
- this.lbt_num.string = idx.toString();
- this.originalPos = this.node.position;
- if (cellData.type == 3) {
- let mergePropCfg = Gamecfg.mergePropInfo.getItem(cellData.id.toString());
- this.sp_item.setSpriteFrame('gridMap', `equipIcon/${mergePropCfg.icon}`);
- }
- }
- /** 是否有物品可以拖动 */
- 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;
- 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: 更新物品的具体显示效果
- }
- }
- }
|