feat(game): 为技能配置添加类型字段并完善信息框交互
- 在 SkillSet 中新增 IType 枚举定义技能类型(近战/远程/辅助) - 为所有技能配置添加 IType 字段 - 在 IBoxComp 中添加英雄名称显示和点击关闭功能
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { _decorator, Label, Node, UITransform } from "cc";
|
||||
import { _decorator, Label, Node, NodeEventType, UITransform } 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 { HeroInfo } from "../common/config/heroSet";
|
||||
import { SkillSet } from "../common/config/SkillSet";
|
||||
import { oops } from "db://oops-framework/core/Oops";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('IBoxComp')
|
||||
@@ -29,6 +30,14 @@ export class IBoxComp extends CCComp {
|
||||
this.renderHeroInfo(args);
|
||||
}
|
||||
|
||||
onLoad() {
|
||||
this.node.on(NodeEventType.TOUCH_END, this.onTapClose, this);
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
this.node.off(NodeEventType.TOUCH_END, this.onTapClose, this);
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
@@ -42,9 +51,11 @@ export class IBoxComp extends CCComp {
|
||||
const heroLv = Math.max(1, Math.floor(args?.heroLv ?? 1));
|
||||
const hero = HeroInfo[heroUuid];
|
||||
if (!hero) {
|
||||
this.setHeroName("");
|
||||
this.applyLineTexts(["暂无技能信息"]);
|
||||
return;
|
||||
}
|
||||
this.setHeroName(hero.name);
|
||||
const runtimeSkills = args?.skills ? Object.values(args.skills) : [];
|
||||
const sourceSkills = runtimeSkills.length > 0 ? runtimeSkills : Object.values(hero.skills ?? {});
|
||||
const skillTexts = sourceSkills.map(skill => {
|
||||
@@ -78,14 +89,24 @@ export class IBoxComp extends CCComp {
|
||||
}
|
||||
|
||||
private updateIBoxHeight(height: number) {
|
||||
const rootTransform = this.node.getComponent(UITransform);
|
||||
if (rootTransform) {
|
||||
rootTransform.setContentSize(rootTransform.contentSize.width, height);
|
||||
}
|
||||
const bgNode = this.node.getChildByName("Bg");
|
||||
const bgTransform = bgNode?.getComponent(UITransform);
|
||||
if (bgTransform) {
|
||||
bgTransform.setContentSize(bgTransform.contentSize.width, height);
|
||||
}
|
||||
}
|
||||
|
||||
private setHeroName(name: string) {
|
||||
const bgNode = this.node.getChildByName("Bg");
|
||||
const nameNode = bgNode?.getChildByName("name");
|
||||
const valNode = nameNode?.getChildByName("val");
|
||||
const label = valNode?.getComponent(Label) || valNode?.getComponentInChildren(Label);
|
||||
if (label) {
|
||||
label.string = name;
|
||||
}
|
||||
}
|
||||
|
||||
private onTapClose() {
|
||||
oops.gui.removeByNode(this.node);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user