refactor(heroUi): 精简和优化英雄界面预制资源

heriui载入 还有问题
- 移除了大量冗余节点和组件,减小预制体体积
- 调整部分节点名称和层级结构,更加清晰易维护
- 优化部分节点位置和尺寸属性,提升界面表现一致性
- 更新部分精灵资源引用及颜色配置,保证视觉效果正确
- 删除无用的动画剪辑和挂载组件,提升加载性能
- 重新整理属性覆盖信息,保持配置整洁规范
This commit is contained in:
panw
2025-10-10 16:55:01 +08:00
parent 577f43042b
commit 5ed5579142
8 changed files with 1264 additions and 20297 deletions

View File

@@ -1,4 +1,4 @@
import { _decorator, Animation, AnimationClip, CCInteger, Component, Label, Node, resources } from 'cc';
import { _decorator, Animation, AnimationClip, CCInteger, Component, instantiate, Label, Node, Prefab, resources, v3 } from 'cc';
import { smc } from '../common/SingletonModuleComp';
import { HeroInfo } from '../common/config/heroSet';
import { GameEvent } from '../common/config/GameEvent';
@@ -12,66 +12,39 @@ const { ccclass, property } = _decorator;
export class HeroReadyCom extends Component {
@property(CCInteger)
slot: number=0;
@property(Prefab)
hero_prefab: Prefab = null!;
protected onLoad(): void {
oops.message.on(GameEvent.UpdateHero,this.update_hero,this)
oops.message.on(GameEvent.UpdateFightHero,this.update_hero,this)
oops.message.on(GameEvent.HeroSpeek,this.to_speek,this)
}
start() {
this.hide_speek()
this.update_hero()
}
hide_speek(){
this.node.getChildByName("tooltip").active=false
}
to_speek(e:any,args:any){
console.log("[HeroReadyCom]:to_speek",args,this.slot)
if(args.slot!=this.slot) return
if(smc.fight_heros[this.slot]==0) return
this.node.getChildByName("tooltip").active=true
this.node.getChildByName("tooltip").getChildByName("words").getComponent(Label)!.string = args.words
this.scheduleOnce(()=>{
this.hide_speek()
},3)
this.add_heros()
}
update(deltaTime: number) {
}
update_hero(){
let hero = smc.fight_heros[this.slot]
// console.log("[HeroReadyCom]hero",hero,smc.fight_heros,this.slot)
if(hero==0){
this.no_hero()
return
add_heros(){
let heros=smc.heros
let x=0
for(let key in heros){
this.add_hero(heros[key].uuid,x)
console.log("[HeroReadyCom]:add_hero",heros[key],x)
x++
}
this.node.getChildByName("icon").active=true
this.node.getChildByName("add").active=false
}
add_hero(hero:any,pos:number){
let hero_data = HeroInfo[hero]
// console.log("[HeroReadyCom]hero_data",smc.fight_heros,hero,smc.fight_heros[this.slot],this.slot,hero_data)
if(!this.hero_prefab) return
const node = instantiate(this.hero_prefab) as unknown as Node;
let anm_path=hero_data.path
resources.load("game/heros/hero/"+anm_path+"/idle", AnimationClip, (err, clip) => {
this.node.getChildByName("icon").getComponent(Animation).addClip(clip);
this.node.getChildByName("icon").getComponent(Animation).play("idle");
node.getChildByName("hero").getComponent(Animation).addClip(clip);
node.getChildByName("hero").getComponent(Animation).play("idle");
});
this.node.getChildByName("lv").active=true
this.node.getChildByName("lv").getChildByName("num").getComponent(Label).string=smc.heros[hero].lv.toString()
// console.log("[HeroReadyCom]clip",this.node.getChildByName("icon").getComponent(Animation))
node.parent = this.node;
node.setPosition(v3(-pos*100,0,0))
}
no_hero(){
this.node.getChildByName("lv").active=false
this.node.getChildByName("add").active=true
this.node.getChildByName("icon").active=false
}
select_hero(){
if(oops.gui.has(UIID.HeroSelect)) return
if(smc.fight_heros[this.slot]==0) {
finishCurrGuide(8)
}
oops.gui.open(UIID.HeroSelect,{slot:this.slot})
}
reset() {
this.node.destroy()
}