feat: 新增技能卡系统,优化卡牌操作逻辑
1. 调整任务开始按钮显示逻辑,新增nobg节点控制 2. 重构卡牌拖拽逻辑,技能卡改为点击使用,英雄卡保留上划使用 3. 修改技能卡牌初始消耗为0 4. 新增技能卡槽面板,在特定波次开放技能卡抽取 5. 新增技能卡刷新按钮与相关回调逻辑 6. 优化抽卡UI显示与费用更新逻辑
This commit is contained in:
@@ -110,6 +110,8 @@ export class CardComp extends CCComp {
|
||||
private readonly dragUseThreshold: number = 70;
|
||||
/** 触摸起始 Y 坐标,用于计算拖拽距离 */
|
||||
private touchStartY: number = 0;
|
||||
/** 触摸起始 X 坐标,用于点击判断 */
|
||||
private touchStartX: number = 0;
|
||||
/** 当前是否正在拖拽 */
|
||||
private isDragging: boolean = false;
|
||||
/** 当前是否正在执行"使用"流程(防止重复触发) */
|
||||
@@ -483,6 +485,7 @@ export class CardComp extends CCComp {
|
||||
private onCardTouchStart(event: EventTouch) {
|
||||
if (!this.cardData || this.isUsing) return;
|
||||
this.touchStartY = event.getUILocation().y;
|
||||
this.touchStartX = event.getUILocation().x;
|
||||
this.isDragging = true;
|
||||
this.isLongPressed = false;
|
||||
this.unschedule(this.onLongPress);
|
||||
@@ -503,19 +506,26 @@ export class CardComp extends CCComp {
|
||||
oops.gui.remove(UIID.HInfo);
|
||||
}
|
||||
}
|
||||
this.node.setPosition(this.restPosition.x, this.restPosition.y + deltaY, this.restPosition.z);
|
||||
|
||||
// 技能卡不支持上划移动
|
||||
if (this.cardData.type !== CardType.Skill) {
|
||||
this.node.setPosition(this.restPosition.x, this.restPosition.y + deltaY, this.restPosition.z);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 触摸结束:
|
||||
* - 上拉距离 >= dragUseThreshold → 视为"使用卡牌"
|
||||
* - 技能卡:点击即可使用
|
||||
* - 英雄卡/其他:上拉距离 >= dragUseThreshold → 视为"使用卡牌"
|
||||
* - 否则视为"点击"或者"长按结束"
|
||||
*/
|
||||
private onCardTouchEnd(event: EventTouch) {
|
||||
this.unschedule(this.onLongPress);
|
||||
if (!this.isDragging || !this.cardData || this.isUsing) return;
|
||||
const endY = event.getUILocation().y;
|
||||
const endX = event.getUILocation().x;
|
||||
const deltaY = endY - this.touchStartY;
|
||||
const deltaX = endX - this.touchStartX;
|
||||
this.isDragging = false;
|
||||
|
||||
if (this.isLongPressed) {
|
||||
@@ -523,12 +533,24 @@ export class CardComp extends CCComp {
|
||||
oops.gui.remove(UIID.HInfo);
|
||||
}
|
||||
|
||||
if (deltaY >= this.dragUseThreshold) {
|
||||
const used = this.useCard();
|
||||
if (!used) {
|
||||
this.playReboundAnim();
|
||||
// 技能卡改为点击使用
|
||||
if (this.cardData.type === CardType.Skill) {
|
||||
if (Math.abs(deltaY) < 20 && Math.abs(deltaX) < 20) {
|
||||
const used = this.useCard();
|
||||
if (!used) {
|
||||
this.playReboundAnim();
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// 英雄卡保持上划使用
|
||||
if (deltaY >= this.dragUseThreshold) {
|
||||
const used = this.useCard();
|
||||
if (!used) {
|
||||
this.playReboundAnim();
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
this.playReboundAnim();
|
||||
|
||||
Reference in New Issue
Block a user