Compare commits
3 Commits
0101b40c20
...
6ff01c9bb2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ff01c9bb2 | ||
|
|
0829b0bc9d | ||
|
|
033fd44560 |
@@ -7,11 +7,11 @@
|
|||||||
"embeddedPlayerGroups": []
|
"embeddedPlayerGroups": []
|
||||||
},
|
},
|
||||||
"_native": "",
|
"_native": "",
|
||||||
"sample": 30,
|
"sample": 20,
|
||||||
"speed": 1,
|
"speed": 1,
|
||||||
"wrapMode": 1,
|
"wrapMode": 1,
|
||||||
"enableTrsBlending": false,
|
"enableTrsBlending": false,
|
||||||
"_duration": 0.4,
|
"_duration": 0.6,
|
||||||
"_hash": 500763545,
|
"_hash": 500763545,
|
||||||
"_tracks": [
|
"_tracks": [
|
||||||
{
|
{
|
||||||
@@ -69,17 +69,17 @@
|
|||||||
"__type__": "cc.ObjectCurve",
|
"__type__": "cc.ObjectCurve",
|
||||||
"_times": [
|
"_times": [
|
||||||
0,
|
0,
|
||||||
0.03333333333333333,
|
0.05,
|
||||||
0.06666666666666667,
|
|
||||||
0.1,
|
0.1,
|
||||||
0.13333333333333333,
|
0.15,
|
||||||
0.16666666666666666,
|
|
||||||
0.2,
|
0.2,
|
||||||
0.23333333333333334,
|
0.25,
|
||||||
0.26666666666666666,
|
|
||||||
0.3,
|
0.3,
|
||||||
0.3333333333333333,
|
0.35,
|
||||||
0.36666666666666664
|
0.4,
|
||||||
|
0.45,
|
||||||
|
0.5,
|
||||||
|
0.55
|
||||||
],
|
],
|
||||||
"_values": [
|
"_values": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
"embeddedPlayerGroups": []
|
"embeddedPlayerGroups": []
|
||||||
},
|
},
|
||||||
"_native": "",
|
"_native": "",
|
||||||
"sample": 30,
|
"sample": 20,
|
||||||
"speed": 1,
|
"speed": 1,
|
||||||
"wrapMode": 1,
|
"wrapMode": 1,
|
||||||
"enableTrsBlending": false,
|
"enableTrsBlending": false,
|
||||||
"_duration": 0.4,
|
"_duration": 0.6,
|
||||||
"_hash": 500763545,
|
"_hash": 500763545,
|
||||||
"_tracks": [
|
"_tracks": [
|
||||||
{
|
{
|
||||||
@@ -69,17 +69,17 @@
|
|||||||
"__type__": "cc.ObjectCurve",
|
"__type__": "cc.ObjectCurve",
|
||||||
"_times": [
|
"_times": [
|
||||||
0,
|
0,
|
||||||
0.03333333333333333,
|
0.05,
|
||||||
0.06666666666666667,
|
|
||||||
0.1,
|
0.1,
|
||||||
0.13333333333333333,
|
0.15,
|
||||||
0.16666666666666666,
|
|
||||||
0.2,
|
0.2,
|
||||||
0.23333333333333334,
|
0.25,
|
||||||
0.26666666666666666,
|
|
||||||
0.3,
|
0.3,
|
||||||
0.3333333333333333,
|
0.35,
|
||||||
0.36666666666666664
|
0.4,
|
||||||
|
0.45,
|
||||||
|
0.5,
|
||||||
|
0.55
|
||||||
],
|
],
|
||||||
"_values": [
|
"_values": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,11 +7,11 @@
|
|||||||
"embeddedPlayerGroups": []
|
"embeddedPlayerGroups": []
|
||||||
},
|
},
|
||||||
"_native": "",
|
"_native": "",
|
||||||
"sample": 30,
|
"sample": 18,
|
||||||
"speed": 1,
|
"speed": 1,
|
||||||
"wrapMode": 1,
|
"wrapMode": 1,
|
||||||
"enableTrsBlending": false,
|
"enableTrsBlending": false,
|
||||||
"_duration": 0.4,
|
"_duration": 0.6666666666666666,
|
||||||
"_hash": 500763545,
|
"_hash": 500763545,
|
||||||
"_tracks": [
|
"_tracks": [
|
||||||
{
|
{
|
||||||
@@ -69,17 +69,17 @@
|
|||||||
"__type__": "cc.ObjectCurve",
|
"__type__": "cc.ObjectCurve",
|
||||||
"_times": [
|
"_times": [
|
||||||
0,
|
0,
|
||||||
0.03333333333333333,
|
0.05555555555555555,
|
||||||
0.06666666666666667,
|
0.1111111111111111,
|
||||||
0.1,
|
|
||||||
0.13333333333333333,
|
|
||||||
0.16666666666666666,
|
0.16666666666666666,
|
||||||
0.2,
|
0.2222222222222222,
|
||||||
0.23333333333333334,
|
0.2777777777777778,
|
||||||
0.26666666666666666,
|
|
||||||
0.3,
|
|
||||||
0.3333333333333333,
|
0.3333333333333333,
|
||||||
0.36666666666666664
|
0.3888888888888889,
|
||||||
|
0.4444444444444444,
|
||||||
|
0.5,
|
||||||
|
0.5555555555555556,
|
||||||
|
0.6111111111111112
|
||||||
],
|
],
|
||||||
"_values": [
|
"_values": [
|
||||||
{
|
{
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -195,6 +195,8 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
|||||||
heroView.playReady("yellow");
|
heroView.playReady("yellow");
|
||||||
} else if (triggerType === 'dead') {
|
} else if (triggerType === 'dead') {
|
||||||
heroView.playOther("dead");
|
heroView.playOther("dead");
|
||||||
|
}else{
|
||||||
|
heroView.playOther('yellow')
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果是敌方攻击技能,必须在战斗中才能释放;友方增益/护盾则允许在非战斗中释放
|
// 如果是敌方攻击技能,必须在战斗中才能释放;友方增益/护盾则允许在非战斗中释放
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
* - smc.vmdata.mission_data —— 读写局内金币
|
* - smc.vmdata.mission_data —— 读写局内金币
|
||||||
*/
|
*/
|
||||||
import { mLogger } from "../common/Logger";
|
import { mLogger } from "../common/Logger";
|
||||||
import { _decorator, Animation, AnimationClip, EventTouch, Label, Node, NodeEventType, Sprite, SpriteAtlas, Tween, tween, UIOpacity, Vec3, resources, Light } from "cc";
|
import { _decorator, Animation, AnimationClip, EventTouch, Label, Node, NodeEventType, Sprite, SpriteAtlas, Tween, tween, UIOpacity, Vec3, resources, Light, UITransform, Widget } from "cc";
|
||||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||||
import { CardConfig, CardType, SpecialRefreshCardList, SpecialUpgradeCardList, CKind, CardPoolList } from "../common/config/CardSet";
|
import { CardConfig, CardType, SpecialRefreshCardList, SpecialUpgradeCardList, CKind, CardPoolList } from "../common/config/CardSet";
|
||||||
@@ -121,6 +121,14 @@ export class CardComp extends CCComp {
|
|||||||
* 防止快速切卡时旧回调错误覆盖新图标。
|
* 防止快速切卡时旧回调错误覆盖新图标。
|
||||||
*/
|
*/
|
||||||
private iconVisualToken: number = 0;
|
private iconVisualToken: number = 0;
|
||||||
|
/** 是否处于放大状态 */
|
||||||
|
private isEnlarged: boolean = false;
|
||||||
|
/** 长按定时器标记 */
|
||||||
|
private longPressTimer: any = null;
|
||||||
|
/** 是否触发了长按 */
|
||||||
|
private isLongPressed: boolean = false;
|
||||||
|
/** 长按触发时间(秒) */
|
||||||
|
private readonly LONG_PRESS_DURATION: number = 0.5;
|
||||||
|
|
||||||
// ======================== 生命周期 ========================
|
// ======================== 生命周期 ========================
|
||||||
|
|
||||||
@@ -259,6 +267,7 @@ export class CardComp extends CCComp {
|
|||||||
this.card_type = data.type;
|
this.card_type = data.type;
|
||||||
this.card_cost = data.cost;
|
this.card_cost = data.cost;
|
||||||
this.node.active = true;
|
this.node.active = true;
|
||||||
|
this.isEnlarged = false;
|
||||||
this.applyCardUI();
|
this.applyCardUI();
|
||||||
this.playRefreshAnim();
|
this.playRefreshAnim();
|
||||||
mLogger.log(this.debugMode, "CardComp", "card updated", {
|
mLogger.log(this.debugMode, "CardComp", "card updated", {
|
||||||
@@ -394,7 +403,28 @@ export class CardComp extends CCComp {
|
|||||||
this.restPosition = new Vec3(x, this.fixedBaseY, this.fixedBaseZ);
|
this.restPosition = new Vec3(x, this.fixedBaseY, this.fixedBaseZ);
|
||||||
// 拖拽/使用中不立即移动,等状态结束后归位
|
// 拖拽/使用中不立即移动,等状态结束后归位
|
||||||
if (!this.isDragging && !this.isUsing) {
|
if (!this.isDragging && !this.isUsing) {
|
||||||
this.node.setPosition(this.restPosition);
|
// ---- 放大时的位置偏移和层级调整 ----
|
||||||
|
let targetX = this.restPosition.x;
|
||||||
|
let targetY = this.restPosition.y;
|
||||||
|
|
||||||
|
if (this.isEnlarged) {
|
||||||
|
// 层级提高,凸显在最外层
|
||||||
|
this.node.setSiblingIndex(999);
|
||||||
|
// x轴偏移逻辑
|
||||||
|
if (this.restPosition.x < -200) { // -260
|
||||||
|
targetX = this.restPosition.x + 30;
|
||||||
|
} else if (this.restPosition.x > 200) { // 260
|
||||||
|
targetX = this.restPosition.x - 30;
|
||||||
|
}
|
||||||
|
// y轴变大时 +35
|
||||||
|
targetY = this.restPosition.y + 35;
|
||||||
|
} else {
|
||||||
|
// 恢复层级(可以根据实际情况调整,默认层级在父节点管理下应该会恢复)
|
||||||
|
// 如果需要严格恢复,这里可以不设置或者使用原始的siblingIndex,但目前不影响,只要放大的是最高就行
|
||||||
|
// 如果有兄弟节点层级问题,可以在 MissionCardComp 中处理,这里先只管提高
|
||||||
|
}
|
||||||
|
|
||||||
|
this.node.setPosition(targetX, targetY, this.restPosition.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,6 +445,7 @@ export class CardComp extends CCComp {
|
|||||||
this.isLocked = false;
|
this.isLocked = false;
|
||||||
this.isDragging = false;
|
this.isDragging = false;
|
||||||
this.isUsing = false;
|
this.isUsing = false;
|
||||||
|
this.isEnlarged = false;
|
||||||
this.node.setPosition(this.restPosition);
|
this.node.setPosition(this.restPosition);
|
||||||
this.node.setScale(new Vec3(1, 1, 1));
|
this.node.setScale(new Vec3(1, 1, 1));
|
||||||
this.updateLockUI();
|
this.updateLockUI();
|
||||||
@@ -440,6 +471,7 @@ export class CardComp extends CCComp {
|
|||||||
this.card_type = CardType.Hero;
|
this.card_type = CardType.Hero;
|
||||||
this.isLocked = false;
|
this.isLocked = false;
|
||||||
this.isDragging = false;
|
this.isDragging = false;
|
||||||
|
this.isEnlarged = false;
|
||||||
this.node.setPosition(this.restPosition);
|
this.node.setPosition(this.restPosition);
|
||||||
this.node.setScale(new Vec3(1, 1, 1));
|
this.node.setScale(new Vec3(1, 1, 1));
|
||||||
this.updateLockUI();
|
this.updateLockUI();
|
||||||
@@ -476,6 +508,20 @@ export class CardComp extends CCComp {
|
|||||||
if (!this.cardData || this.isUsing) return;
|
if (!this.cardData || this.isUsing) return;
|
||||||
this.touchStartY = event.getUILocation().y;
|
this.touchStartY = event.getUILocation().y;
|
||||||
this.isDragging = true;
|
this.isDragging = true;
|
||||||
|
this.isLongPressed = false;
|
||||||
|
|
||||||
|
// 开启长按定时器
|
||||||
|
this.unschedule(this.onLongPress);
|
||||||
|
this.scheduleOnce(this.onLongPress, this.LONG_PRESS_DURATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 长按触发逻辑 */
|
||||||
|
private onLongPress() {
|
||||||
|
if (!this.isDragging || this.isUsing) return;
|
||||||
|
this.isLongPressed = true;
|
||||||
|
this.isEnlarged = true;
|
||||||
|
this.applyCardUI();
|
||||||
|
this.playReboundAnim();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -485,31 +531,72 @@ export class CardComp extends CCComp {
|
|||||||
if (!this.isDragging || !this.cardData || this.isUsing) return;
|
if (!this.isDragging || !this.cardData || this.isUsing) return;
|
||||||
const currentY = event.getUILocation().y;
|
const currentY = event.getUILocation().y;
|
||||||
const deltaY = Math.max(0, currentY - this.touchStartY);
|
const deltaY = Math.max(0, currentY - this.touchStartY);
|
||||||
this.node.setPosition(this.restPosition.x, this.restPosition.y + deltaY, this.restPosition.z);
|
|
||||||
|
// 拖拽距离超过一定阈值,取消长按
|
||||||
|
if (deltaY > 10) {
|
||||||
|
this.unschedule(this.onLongPress);
|
||||||
|
if (this.isLongPressed && !this.isEnlarged) {
|
||||||
|
// 如果已经触发了长按但想取消放大(比如拖拽时恢复),视情况处理
|
||||||
|
// 这里我们认为一旦拖动就取消未触发的长按,如果已经触发放大则保持放大直到松手
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let baseX = this.restPosition.x;
|
||||||
|
let baseY = this.restPosition.y;
|
||||||
|
if (this.isEnlarged) {
|
||||||
|
if (this.restPosition.x <= -200) {
|
||||||
|
baseX = this.restPosition.x + 30;
|
||||||
|
} else if (this.restPosition.x >= 200) {
|
||||||
|
baseX = this.restPosition.x - 30;
|
||||||
|
}
|
||||||
|
baseY = this.restPosition.y + 35;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.node.setPosition(baseX, baseY + deltaY, this.restPosition.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 触摸结束:
|
* 触摸结束:
|
||||||
* - 上拉距离 >= dragUseThreshold → 视为"使用卡牌"
|
* - 上拉距离 >= dragUseThreshold → 视为"使用卡牌"
|
||||||
* - 否则视为"点击",打开英雄信息弹窗(仅英雄卡)并回弹
|
* - 否则视为"点击"或者"长按结束"
|
||||||
*/
|
*/
|
||||||
private onCardTouchEnd(event: EventTouch) {
|
private onCardTouchEnd(event: EventTouch) {
|
||||||
|
this.unschedule(this.onLongPress);
|
||||||
if (!this.isDragging || !this.cardData || this.isUsing) return;
|
if (!this.isDragging || !this.cardData || this.isUsing) return;
|
||||||
const endY = event.getUILocation().y;
|
const endY = event.getUILocation().y;
|
||||||
const deltaY = endY - this.touchStartY;
|
const deltaY = endY - this.touchStartY;
|
||||||
this.isDragging = false;
|
this.isDragging = false;
|
||||||
|
|
||||||
if (deltaY >= this.dragUseThreshold) {
|
if (deltaY >= this.dragUseThreshold) {
|
||||||
this.useCard();
|
this.useCard();
|
||||||
|
// 使用卡牌后恢复非放大状态
|
||||||
|
this.isEnlarged = false;
|
||||||
|
this.isLongPressed = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.openHeroInfoIBox();
|
|
||||||
|
// 无论是点击还是长按松手,都恢复正常大小
|
||||||
|
if (this.isEnlarged) {
|
||||||
|
this.isEnlarged = false;
|
||||||
|
this.applyCardUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isLongPressed = false;
|
||||||
this.playReboundAnim();
|
this.playReboundAnim();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 触摸取消:回弹至原位 */
|
/** 触摸取消:回弹至原位 */
|
||||||
private onCardTouchCancel() {
|
private onCardTouchCancel() {
|
||||||
|
this.unschedule(this.onLongPress);
|
||||||
if (!this.isDragging || this.isUsing) return;
|
if (!this.isDragging || this.isUsing) return;
|
||||||
this.isDragging = false;
|
this.isDragging = false;
|
||||||
|
|
||||||
|
if (this.isEnlarged) {
|
||||||
|
this.isEnlarged = false;
|
||||||
|
this.applyCardUI();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isLongPressed = false;
|
||||||
this.playReboundAnim();
|
this.playReboundAnim();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -560,15 +647,27 @@ export class CardComp extends CCComp {
|
|||||||
// 递增视觉令牌,用于异步加载竞态保护
|
// 递增视觉令牌,用于异步加载竞态保护
|
||||||
this.iconVisualToken += 1;
|
this.iconVisualToken += 1;
|
||||||
if (this.opacityComp) this.opacityComp.opacity = 255;
|
if (this.opacityComp) this.opacityComp.opacity = 255;
|
||||||
this.node.setPosition(this.restPosition);
|
|
||||||
|
let targetX = this.restPosition.x;
|
||||||
|
let targetY = this.restPosition.y;
|
||||||
|
if (this.isEnlarged) {
|
||||||
|
this.node.setSiblingIndex(99); // 变大时提到最前
|
||||||
|
if (this.restPosition.x <= -200) { // -260
|
||||||
|
targetX = this.restPosition.x + 30;
|
||||||
|
} else if (this.restPosition.x >= 200) { // 260
|
||||||
|
targetX = this.restPosition.x - 30;
|
||||||
|
}
|
||||||
|
targetY = this.restPosition.y + 35; // y轴增加
|
||||||
|
}
|
||||||
|
this.node.setPosition(targetX, targetY, this.restPosition.z);
|
||||||
|
|
||||||
// ---- 卡牌种类标识(近战 / 远程 / 辅助等) ----
|
// ---- 卡牌种类标识(近战 / 远程 / 辅助等) ----
|
||||||
if (this.Ckind_node) {
|
// if (this.Ckind_node) {
|
||||||
const kindName = CKind[this.cardData.kind];
|
// const kindName = CKind[this.cardData.kind];
|
||||||
this.Ckind_node.children.forEach(child => {
|
// this.Ckind_node.children.forEach(child => {
|
||||||
child.active = (child.name === kindName);
|
// child.active = (child.name === kindName);
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
|
|
||||||
// ---- 背景底框(按卡池等级显示对应子节点) ----
|
// ---- 背景底框(按卡池等级显示对应子节点) ----
|
||||||
const cardLvStr = `lv${this.cardData.pool_lv}`;
|
const cardLvStr = `lv${this.cardData.pool_lv}`;
|
||||||
@@ -593,16 +692,105 @@ export class CardComp extends CCComp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---- 按卡牌类型渲染具体内容 ----
|
// ---- 按卡牌类型渲染具体内容 ----
|
||||||
|
const uiTrans = this.node.getComponent(UITransform);
|
||||||
|
if (uiTrans) {
|
||||||
|
uiTrans.setContentSize(this.isEnlarged ? 230 : 170, this.isEnlarged ? 300 : 230);
|
||||||
|
const widget = this.node.getComponent(Widget);
|
||||||
|
if (widget) widget.updateAlignment();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 同时修改背景节点和边框节点的尺寸
|
||||||
|
if (this.BG_node) {
|
||||||
|
const bgTrans = this.BG_node.getComponent(UITransform);
|
||||||
|
if (bgTrans) {
|
||||||
|
bgTrans.setContentSize(this.isEnlarged ? 230 : 170, this.isEnlarged ? 300 : 230);
|
||||||
|
const widget = this.BG_node.getComponent(Widget);
|
||||||
|
if (widget) widget.updateAlignment();
|
||||||
|
}
|
||||||
|
this.BG_node.children.forEach(child => {
|
||||||
|
const childTrans = child.getComponent(UITransform);
|
||||||
|
if (childTrans) {
|
||||||
|
childTrans.setContentSize(this.isEnlarged ? 230 : 170, this.isEnlarged ? 300 : 230);
|
||||||
|
const widget = child.getComponent(Widget);
|
||||||
|
if (widget) widget.updateAlignment();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.HF_node) {
|
||||||
|
const hfTrans = this.HF_node.getComponent(UITransform);
|
||||||
|
if (hfTrans) {
|
||||||
|
hfTrans.setContentSize(this.isEnlarged ? 230 : 170, this.isEnlarged ? 300 : 230);
|
||||||
|
const widget = this.HF_node.getComponent(Widget);
|
||||||
|
if (widget) widget.updateAlignment();
|
||||||
|
}
|
||||||
|
this.HF_node.children.forEach(child => {
|
||||||
|
const childTrans = child.getComponent(UITransform);
|
||||||
|
if (childTrans) {
|
||||||
|
childTrans.setContentSize(this.isEnlarged ? 230 : 170, this.isEnlarged ? 300 : 230);
|
||||||
|
const widget = child.getComponent(Widget);
|
||||||
|
if (widget) widget.updateAlignment();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.NF_node) {
|
||||||
|
const nfTrans = this.NF_node.getComponent(UITransform);
|
||||||
|
if (nfTrans) {
|
||||||
|
nfTrans.setContentSize(this.isEnlarged ? 230 : 170, this.isEnlarged ? 300 : 230);
|
||||||
|
const widget = this.NF_node.getComponent(Widget);
|
||||||
|
if (widget) widget.updateAlignment();
|
||||||
|
}
|
||||||
|
this.NF_node.children.forEach(child => {
|
||||||
|
const childTrans = child.getComponent(UITransform);
|
||||||
|
if (childTrans) {
|
||||||
|
childTrans.setContentSize(this.isEnlarged ? 230 : 170, this.isEnlarged ? 300 : 230);
|
||||||
|
const widget = child.getComponent(Widget);
|
||||||
|
if (widget) widget.updateAlignment();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const hbNode = this.node.getChildByName("HB");
|
||||||
|
if (hbNode) {
|
||||||
|
const hbTrans = hbNode.getComponent(UITransform);
|
||||||
|
if (hbTrans) {
|
||||||
|
hbTrans.setContentSize(this.isEnlarged ? 230 : 170, this.isEnlarged ? 300 : 230);
|
||||||
|
const widget = hbNode.getComponent(Widget);
|
||||||
|
if (widget) widget.updateAlignment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 触发布局刷新,确保其所有子节点(比如右上角的cost、名字等)依赖 Widget 的节点重新对齐
|
||||||
|
this.node.children.forEach(child => {
|
||||||
|
const widget = child.getComponent(Widget);
|
||||||
|
if (widget) widget.updateAlignment();
|
||||||
|
child.children.forEach(subChild => {
|
||||||
|
const subWidget = subChild.getComponent(Widget);
|
||||||
|
if (subWidget) subWidget.updateAlignment();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
if(this.card_type===CardType.Hero){
|
if(this.card_type===CardType.Hero){
|
||||||
// 英雄卡:显示英雄名 + 星级 + AP/HP
|
// 英雄卡:显示英雄名 + 星级 + AP/HP
|
||||||
const hero = HeroInfo[this.card_uuid];
|
const hero = HeroInfo[this.card_uuid];
|
||||||
const heroLv = Math.max(1, Math.floor(this.cardData.hero_lv ?? hero?.lv ?? 1));
|
const heroLv = Math.max(1, Math.floor(this.cardData.hero_lv ?? hero?.lv ?? 1));
|
||||||
const suffix = heroLv >= 2 ? "★".repeat(heroLv - 1) : "";
|
const suffix = heroLv >= 2 ? "★".repeat(heroLv - 1) : "";
|
||||||
this.setLabel(this.name_node, `${suffix}${hero?.name || ""}${suffix}`);
|
this.setLabel(this.name_node, `${suffix}${hero?.name || ""}${suffix}`);
|
||||||
this.info_node.active = true;
|
|
||||||
this.oinfo_node.active = false;
|
|
||||||
this.info_node.getChildByName("ap").getChildByName("val").getComponent(Label).string = `${(hero?.ap ?? 0) * heroLv}`;
|
this.info_node.getChildByName("ap").getChildByName("val").getComponent(Label).string = `${(hero?.ap ?? 0) * heroLv}`;
|
||||||
this.info_node.getChildByName("hp").getChildByName("val").getComponent(Label).string = `${(hero?.hp ?? 0) * heroLv}`;
|
this.info_node.getChildByName("hp").getChildByName("val").getComponent(Label).string = `${(hero?.hp ?? 0) * heroLv}`;
|
||||||
|
if (this.oinfo_node) {
|
||||||
|
const infoLabel = this.oinfo_node.getChildByName("info")?.getComponent(Label);
|
||||||
|
if (infoLabel) infoLabel.string = `${hero?.info || ""}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isEnlarged) {
|
||||||
|
this.info_node.active = true;
|
||||||
|
this.oinfo_node.active = true;
|
||||||
|
} else {
|
||||||
|
this.info_node.active = false;
|
||||||
|
this.oinfo_node.active = false;
|
||||||
|
}
|
||||||
}else if(this.card_type===CardType.Skill){
|
}else if(this.card_type===CardType.Skill){
|
||||||
// 技能卡:显示技能名 + 品质后缀 + 描述
|
// 技能卡:显示技能名 + 品质后缀 + 描述
|
||||||
const skill = SkillSet[this.card_uuid];
|
const skill = SkillSet[this.card_uuid];
|
||||||
@@ -610,9 +798,15 @@ export class CardComp extends CCComp {
|
|||||||
const card_lv = Math.max(1, Math.floor(this.cardData.card_lv ?? 1));
|
const card_lv = Math.max(1, Math.floor(this.cardData.card_lv ?? 1));
|
||||||
const spSuffix = card_lv >= 2 ? "★".repeat(card_lv - 1) : "";
|
const spSuffix = card_lv >= 2 ? "★".repeat(card_lv - 1) : "";
|
||||||
this.setLabel(this.name_node, `${spSuffix}${skillCard?.name || skill?.name || ""}${spSuffix}`);
|
this.setLabel(this.name_node, `${spSuffix}${skillCard?.name || skill?.name || ""}${spSuffix}`);
|
||||||
this.info_node.active = false;
|
|
||||||
this.oinfo_node.active = true;
|
|
||||||
this.oinfo_node.getChildByName("info").getComponent(Label).string = `${skillCard?.info || skill?.info || ""}`;
|
this.oinfo_node.getChildByName("info").getComponent(Label).string = `${skillCard?.info || skill?.info || ""}`;
|
||||||
|
|
||||||
|
if (this.isEnlarged) {
|
||||||
|
this.info_node.active = false;
|
||||||
|
this.oinfo_node.active = true;
|
||||||
|
} else {
|
||||||
|
this.info_node.active = false;
|
||||||
|
this.oinfo_node.active = false;
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
// 特殊卡(升级 / 刷新):显示卡名 + 品质后缀 + 描述
|
// 特殊卡(升级 / 刷新):显示卡名 + 品质后缀 + 描述
|
||||||
const specialCard = this.card_type === CardType.SpecialUpgrade
|
const specialCard = this.card_type === CardType.SpecialUpgrade
|
||||||
@@ -621,13 +815,25 @@ export class CardComp extends CCComp {
|
|||||||
const card_lv = Math.max(1, Math.floor(this.cardData.card_lv ?? 1));
|
const card_lv = Math.max(1, Math.floor(this.cardData.card_lv ?? 1));
|
||||||
const spSuffix = card_lv >= 2 ? "★".repeat(card_lv - 1) : "";
|
const spSuffix = card_lv >= 2 ? "★".repeat(card_lv - 1) : "";
|
||||||
this.setLabel(this.name_node, `${spSuffix}${specialCard?.name || ""}${spSuffix}`);
|
this.setLabel(this.name_node, `${spSuffix}${specialCard?.name || ""}${spSuffix}`);
|
||||||
this.info_node.active = false;
|
|
||||||
this.oinfo_node.active = true;
|
|
||||||
this.oinfo_node.getChildByName("info").getComponent(Label).string = `${specialCard?.info || ""}`;
|
this.oinfo_node.getChildByName("info").getComponent(Label).string = `${specialCard?.info || ""}`;
|
||||||
|
|
||||||
|
if (this.isEnlarged) {
|
||||||
|
this.info_node.active = false;
|
||||||
|
this.oinfo_node.active = true;
|
||||||
|
} else {
|
||||||
|
this.info_node.active = false;
|
||||||
|
this.oinfo_node.active = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- 费用标签 ----
|
// ---- 费用标签 ----
|
||||||
this.setLabel(this.cost_node, `${this.card_cost}`);
|
this.setLabel(this.cost_node, `${this.card_cost}`);
|
||||||
|
|
||||||
|
// ---- 名字节点位置调整 ----
|
||||||
|
if (this.name_node) {
|
||||||
|
const currentPos = this.name_node.position;
|
||||||
|
this.name_node.setPosition(currentPos.x, this.isEnlarged ? 8 : -70, currentPos.z);
|
||||||
|
}
|
||||||
|
|
||||||
// ---- 图标 ----
|
// ---- 图标 ----
|
||||||
const iconNode = this.icon_node as Node;
|
const iconNode = this.icon_node as Node;
|
||||||
@@ -660,12 +866,23 @@ export class CardComp extends CCComp {
|
|||||||
.start();
|
.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 回弹动画:从当前位置平滑回到静止位并恢复缩放 */
|
/** 回弹动画:从当前位置平滑回到静止位或放大位置并恢复缩放 */
|
||||||
private playReboundAnim() {
|
private playReboundAnim() {
|
||||||
Tween.stopAllByTarget(this.node);
|
Tween.stopAllByTarget(this.node);
|
||||||
|
let targetX = this.restPosition.x;
|
||||||
|
let targetY = this.restPosition.y;
|
||||||
|
if (this.isEnlarged) {
|
||||||
|
if (this.restPosition.x <= -200) {
|
||||||
|
targetX = this.restPosition.x + 30;
|
||||||
|
} else if (this.restPosition.x >= 200) {
|
||||||
|
targetX = this.restPosition.x - 30;
|
||||||
|
}
|
||||||
|
targetY = this.restPosition.y + 35;
|
||||||
|
}
|
||||||
|
|
||||||
tween(this.node)
|
tween(this.node)
|
||||||
.to(0.12, {
|
.to(0.12, {
|
||||||
position: this.restPosition,
|
position: new Vec3(targetX, targetY, this.restPosition.z),
|
||||||
scale: new Vec3(1, 1, 1)
|
scale: new Vec3(1, 1, 1)
|
||||||
})
|
})
|
||||||
.start();
|
.start();
|
||||||
@@ -703,16 +920,93 @@ export class CardComp extends CCComp {
|
|||||||
* 清空名称、费用、信息面板、种类标识、背景底框、边框、图标。
|
* 清空名称、费用、信息面板、种类标识、背景底框、边框、图标。
|
||||||
*/
|
*/
|
||||||
private applyEmptyUI() {
|
private applyEmptyUI() {
|
||||||
|
const uiTrans = this.node.getComponent(UITransform);
|
||||||
|
if (uiTrans) {
|
||||||
|
uiTrans.setContentSize(170, 230);
|
||||||
|
const widget = this.node.getComponent(Widget);
|
||||||
|
if (widget) widget.updateAlignment();
|
||||||
|
}
|
||||||
|
if (this.BG_node) {
|
||||||
|
const bgTrans = this.BG_node.getComponent(UITransform);
|
||||||
|
if (bgTrans) {
|
||||||
|
bgTrans.setContentSize(170, 230);
|
||||||
|
const widget = this.BG_node.getComponent(Widget);
|
||||||
|
if (widget) widget.updateAlignment();
|
||||||
|
}
|
||||||
|
this.BG_node.children.forEach(child => {
|
||||||
|
const childTrans = child.getComponent(UITransform);
|
||||||
|
if (childTrans) {
|
||||||
|
childTrans.setContentSize(170, 230);
|
||||||
|
const widget = child.getComponent(Widget);
|
||||||
|
if (widget) widget.updateAlignment();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (this.HF_node) {
|
||||||
|
const hfTrans = this.HF_node.getComponent(UITransform);
|
||||||
|
if (hfTrans) {
|
||||||
|
hfTrans.setContentSize(170, 230);
|
||||||
|
const widget = this.HF_node.getComponent(Widget);
|
||||||
|
if (widget) widget.updateAlignment();
|
||||||
|
}
|
||||||
|
this.HF_node.children.forEach(child => {
|
||||||
|
const childTrans = child.getComponent(UITransform);
|
||||||
|
if (childTrans) {
|
||||||
|
childTrans.setContentSize(170, 230);
|
||||||
|
const widget = child.getComponent(Widget);
|
||||||
|
if (widget) widget.updateAlignment();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (this.NF_node) {
|
||||||
|
const nfTrans = this.NF_node.getComponent(UITransform);
|
||||||
|
if (nfTrans) {
|
||||||
|
nfTrans.setContentSize(170, 230);
|
||||||
|
const widget = this.NF_node.getComponent(Widget);
|
||||||
|
if (widget) widget.updateAlignment();
|
||||||
|
}
|
||||||
|
this.NF_node.children.forEach(child => {
|
||||||
|
const childTrans = child.getComponent(UITransform);
|
||||||
|
if (childTrans) {
|
||||||
|
childTrans.setContentSize(170, 230);
|
||||||
|
const widget = child.getComponent(Widget);
|
||||||
|
if (widget) widget.updateAlignment();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const hbNode = this.node.getChildByName("HB");
|
||||||
|
if (hbNode) {
|
||||||
|
const hbTrans = hbNode.getComponent(UITransform);
|
||||||
|
if (hbTrans) {
|
||||||
|
hbTrans.setContentSize(170, 230);
|
||||||
|
const widget = hbNode.getComponent(Widget);
|
||||||
|
if (widget) widget.updateAlignment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.node.children.forEach(child => {
|
||||||
|
const widget = child.getComponent(Widget);
|
||||||
|
if (widget) widget.updateAlignment();
|
||||||
|
child.children.forEach(subChild => {
|
||||||
|
const subWidget = subChild.getComponent(Widget);
|
||||||
|
if (subWidget) subWidget.updateAlignment();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this.name_node) {
|
||||||
|
const currentPos = this.name_node.position;
|
||||||
|
this.name_node.setPosition(currentPos.x, -70, currentPos.z);
|
||||||
|
}
|
||||||
this.iconVisualToken += 1;
|
this.iconVisualToken += 1;
|
||||||
this.setLabel(this.name_node, "");
|
this.setLabel(this.name_node, "");
|
||||||
this.setLabel(this.cost_node, "");
|
this.setLabel(this.cost_node, "");
|
||||||
if (this.info_node) this.info_node.active = false;
|
if (this.info_node) this.info_node.active = false;
|
||||||
if (this.oinfo_node) this.oinfo_node.active = false;
|
if (this.oinfo_node) this.oinfo_node.active = false;
|
||||||
if (this.Ckind_node) {
|
// if (this.Ckind_node) {
|
||||||
this.Ckind_node.children.forEach(child => {
|
// this.Ckind_node.children.forEach(child => {
|
||||||
child.active = false;
|
// child.active = false;
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
if (this.BG_node) {
|
if (this.BG_node) {
|
||||||
this.BG_node.children.forEach(child => child.active = false);
|
this.BG_node.children.forEach(child => child.active = false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,6 +137,8 @@ export class MissionCardComp extends CCComp {
|
|||||||
private cardsShowScale: Vec3 = new Vec3(1, 1, 1);
|
private cardsShowScale: Vec3 = new Vec3(1, 1, 1);
|
||||||
/** 卡牌面板收起态缩放(scale=0 隐藏) */
|
/** 卡牌面板收起态缩放(scale=0 隐藏) */
|
||||||
private cardsHideScale: Vec3 = new Vec3(0, 0, 1);
|
private cardsHideScale: Vec3 = new Vec3(0, 0, 1);
|
||||||
|
/** 卡牌原始定位点 */
|
||||||
|
private cardsPos = [-260,-86,86,260]
|
||||||
/**
|
/**
|
||||||
* 英雄信息面板映射:EID → { node, model, comp }
|
* 英雄信息面板映射:EID → { node, model, comp }
|
||||||
* 用于追踪每个出战英雄的面板实例和数据引用
|
* 用于追踪每个出战英雄的面板实例和数据引用
|
||||||
|
|||||||
Reference in New Issue
Block a user