英雄出战选择 +英雄相关 ui 改变

This commit is contained in:
2025-08-17 20:40:03 +08:00
parent ba61724a08
commit 1a25a566c8
20 changed files with 6674 additions and 2240 deletions

View File

@@ -0,0 +1,67 @@
import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
import { oops } from 'db://oops-framework/core/Oops';
import { HCardUICom } from './HCardUICom';
import { smc } from '../common/SingletonModuleComp';
import { HeroConSet } from '../common/config/BoxSet';
const { ccclass, property } = _decorator;
@ccclass('HeroSelectCom')
export class HeroSelectCom extends Component {
slot:number=0
start() {
}
onAdded(args: any) {
console.log("[HeroSelectCom]:onAdded",args)
this.slot=args.slot
this.update_heros()
}
protected onDisable(): void {
console.log("[HeroSelectCom]:onDisable")
this.clear_heros()
}
update_heros(){
let heros=smc.getHasHeroUUID()
console.log("[HeroPageComp]:update_heros",heros)
let width= heros.length*235+30
for(let i=0;i<heros.length;i++){
let hero=heros[i]
console.log("[HeroPageComp]:hero",hero)
if(hero){
this.load_hero(hero)
}
}
}
clear_heros(){
let parent=this.node.getChildByName("main").getChildByName("view").getChildByName("heros")
let children=parent.children
console.log("[HeroPageComp]:clear_heros",children)
for(let i=0;i<children.length;i++){
children[i].destroy()
}
}
load_hero(uuid:number){
console.log("[HeroPageComp]:load_hero",uuid)
let parent=this.node.getChildByName("main").getChildByName("view").getChildByName("heros")
let path = "game/gui/hcard"
const prefab = oops.res.get(path, Prefab);
if (!prefab) {
console.error("[Skill] 预制体加载失败:", path);
return;
}
const node = instantiate(prefab);
node.parent=parent
let hcard=node.getComponent(HCardUICom)!
hcard.update_data(uuid,{type:HeroConSet.SELECT,slot:this.slot})
}
update(deltaTime: number) {
}
close(){
oops.gui.removeByNode(this.node)
}
}