英雄展示页面++
This commit is contained in:
@@ -1,14 +1,52 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('HeroPageComp')
|
||||
export class HeroPageComp extends Component {
|
||||
start() {
|
||||
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
|
||||
import { smc } from '../common/SingletonModuleComp';
|
||||
import { oops } from 'db://oops-framework/core/Oops';
|
||||
import { HCardUICom } from './HCardUICom';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('HeroPageComp')
|
||||
export class HeroPageComp extends Component {
|
||||
start() {
|
||||
console.log("[HeroPageComp]:start")
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
|
||||
}
|
||||
update_heros(){
|
||||
let heros=smc.getHasHeroUUID()
|
||||
console.log("[HeroPageComp]:update_heros",heros)
|
||||
this.clear_heros()
|
||||
for(let i=0;i<3;i++){
|
||||
let hero=heros[i]
|
||||
console.log("[HeroPageComp]:hero",hero)
|
||||
if(hero){
|
||||
this.load_hero(hero)
|
||||
}
|
||||
}
|
||||
}
|
||||
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)
|
||||
}
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user