refactor(gui): 优化role_controller.prefab结构和视觉表现

- 调整多个组件的__id__以规范资源引用
- 修改部分节点名称以提升可读性和管理
- 优化节点的位置、旋转和缩放参数
- 更新Sprite和Label组件的颜色及资源关联
- 替换部分SpriteFrame资源,提高图像清晰度
- 修改UITransform尺寸和锚点以匹配设计需求
- 添加新的Animation和Widget组件,完善动画与布局
- 调整光源节点的变换参数以改善光照效果
- 清理和重组节点层次结构,简化子节点管理
- 改进字体样式及视觉表现,符合设计规范
This commit is contained in:
2025-10-20 16:53:35 +08:00
parent 8d9c7bbe0d
commit d67c63b768
2 changed files with 1235 additions and 261 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
import { _decorator, Animation, AnimationClip, Component, Label, Node, resources, Sprite, SpriteFrame } from 'cc';
import { _decorator, Animation, AnimationClip, Component, instantiate, Label, Node, Prefab, resources, Sprite, SpriteFrame, v3 } from 'cc';
import { oops } from 'db://oops-framework/core/Oops';
import { getHeroList, HeroInfo, HType, HTypeName } from '../common/config/heroSet';
import { smc } from '../common/SingletonModuleComp';
@@ -12,6 +12,24 @@ export class HInfoComp extends Component {
ap_node:any=null
hp_node:any=null
def_node:any=null
// 重新定义节点映射,使名称更清晰
// 当前显示的英雄节点数组7个位置
heroNodes: (Node | null)[] = [null, null, null, null, null, null, null];
// 英雄位置定义
hero_pos:any={
0:v3(420,-109,0), // 不在屏幕内
1:v3(280,-109,0),
2:v3(140,-109,0),
3:v3(0,-109,0),
4:v3(-140,-109,0),
5:v3(-280,-109,0),
6:v3(-420,-109,0), // 不在屏幕内
}
// 位置索引常量
private static center_pos = 3;
start() {
this.name_node=this.node.getChildByName("hero").getChildByName("hname").getChildByName("name")
this.type_node=this.node.getChildByName("hero").getChildByName("hname").getChildByName("type")
@@ -26,19 +44,39 @@ export class HInfoComp extends Component {
}
update_data(uuid:number){
this.h_uuid=uuid
let hero_data = HeroInfo[uuid]
console.log("[HInfoComp]:update_data",uuid,hero_data,this.node)
this.name_node.getComponent(Label).string=hero_data.name
this.type_node.getComponent(Label).string=HTypeName[hero_data.type]
this.ap_node.getComponent(Label).string=hero_data.ap.toString()
this.hp_node.getComponent(Label).string=hero_data.hp.toString()
this.def_node.getComponent(Label).string=hero_data.def.toString()
let anm_path=hero_data.path
resources.load("game/heros/hero/"+anm_path+"/idle", AnimationClip, (err, clip) => {
this.node.getChildByName("hero").getComponent(Animation).addClip(clip);
this.node.getChildByName("hero").getComponent(Animation).play("idle");
});
console.log("[HInfoComp]:update_data",uuid,HeroInfo[uuid],this.node)
this.name_node.getComponent(Label).string=HeroInfo[uuid].name
this.type_node.getComponent(Label).string=HTypeName[HeroInfo[uuid].type]
this.ap_node.getComponent(Label).string=HeroInfo[uuid].ap.toString()
this.hp_node.getComponent(Label).string=HeroInfo[uuid].hp.toString()
this.def_node.getComponent(Label).string=HeroInfo[uuid].def.toString()
this.load_all_hero(uuid)
}
load_all_hero(uuid:number){
}
load_hui(uuid:number,pos_index: number){
var path = "game/heros/"+HeroInfo[uuid].path;
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
HeroInfo[uuid]
let anm_path=HeroInfo[uuid].path
resources.load("game/heros/hero/"+anm_path+"/idle", AnimationClip, (err, clip) => {
node.getComponent(Animation).addClip(clip);
node.getComponent(Animation).play("idle");
});
node.setPosition(this.hero_pos[pos_index])
}
claear_hero(){
for (let i = 0; i < this.heroNodes.length; i++) {
if (this.heroNodes[i]) {
this.heroNodes[i].destroy();
this.heroNodes[i] = null;
}
}
}
next_hero(){
let heros=getHeroList()
let index = heros.indexOf(this.h_uuid);
@@ -61,6 +99,4 @@ export class HInfoComp extends Component {
reset() {
this.node.destroy()
}
}
}