feat(heroBox): 添加英雄信息次级属性折叠功能

1. 移除了三个精灵组件的固定贴图,改为空引用
2. 新增更多属性折叠按钮和5个次级属性栏节点
3. 实现点击按钮切换次级属性栏显示/隐藏的逻辑
4. 调整了英雄盒子预制体的布局和文本内容
5. 修复了布局对齐参数和预制体关联信息
This commit is contained in:
pan
2026-07-28 16:06:28 +08:00
parent a9d891ab86
commit 16cc50cfdf
3 changed files with 140 additions and 85 deletions

View File

@@ -12,9 +12,10 @@
* - HeroInfoheroSet—— 英雄静态配置
*/
import { mLogger } from "../common/Logger";
import { _decorator, Node, Sprite, Label, resources, AnimationClip, SpriteFrame } from "cc";
import { _decorator, Node, Sprite, Label, resources, AnimationClip, SpriteFrame, NodeEventType } from "cc";
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { oops } from "db://oops-framework/core/Oops";
import { HeroInfo } from "../common/config/heroSet";
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
import { getLvColor } from "../common/config/GameSet";
@@ -109,6 +110,30 @@ export class HeroBoxComp extends CCComp {
@property(Label)
private crit_dmg_plus_label: Label = null;
// ======================== 更多属性折叠栏 ========================
/** 更多按钮(点击展开/收起次级属性栏) */
@property(Node)
private more_btn: Node = null;
/** 击晕信息栏(默认隐藏) */
@property(Node)
private stun_row: Node = null;
/** 冰冻信息栏(默认隐藏) */
@property(Node)
private freeze_row: Node = null;
/** 击退信息栏(默认隐藏) */
@property(Node)
private knockback_row: Node = null;
/** 穿透信息栏(默认隐藏) */
@property(Node)
private puncture_row: Node = null;
/** 风怒信息栏(默认隐藏) */
@property(Node)
private wfuny_row: Node = null;
/** 次级属性栏是否展开 */
private moreExpanded: boolean = false;
// ======================== 运行时状态 ========================
/** 绑定的英雄实体 ID0 表示空槽位) */
@@ -123,6 +148,32 @@ export class HeroBoxComp extends CCComp {
// ======================== 生命周期 ========================
onLoad() {
// 次级属性栏默认收起
this.setMoreRowsVisible(false);
this.more_btn?.on(NodeEventType.TOUCH_END, this.onMoreBtnClick, this);
}
onDestroy() {
if (this.more_btn && this.more_btn.isValid) {
this.more_btn.off(NodeEventType.TOUCH_END, this.onMoreBtnClick, this);
}
}
/** 更多按钮点击:切换次级属性栏显示/隐藏 */
private onMoreBtnClick() {
oops.audio.playEffect("music/button");
this.moreExpanded = !this.moreExpanded;
this.setMoreRowsVisible(this.moreExpanded);
}
/** 设置 5 个次级属性栏(击晕/冰冻/击退/穿透/风怒)的可见性 */
private setMoreRowsVisible(visible: boolean) {
const rows = [this.stun_row, this.freeze_row, this.knockback_row, this.puncture_row, this.wfuny_row];
for (const row of rows) {
if (row && row.isValid) {
row.active = visible;
}
}
}
/** ECS 组件移除时销毁节点 */