英雄展示页面++

This commit is contained in:
2025-08-14 17:10:36 +08:00
parent 6adff46fd1
commit 7203a4ab07
8 changed files with 644 additions and 1760 deletions

View File

@@ -7,13 +7,14 @@ const { ccclass, property } = _decorator;
export class HCardUICom extends Component {
h_uuid:number=0
start() {
console.log("[HCardUICom]:start")
}
update(deltaTime: number) {
}
update_data(uuid:number){
console.log("[HCardUICom]:update_data",uuid)
this.h_uuid=uuid
let hero_data = HeroInfo[uuid]
let hero= this.node.getChildByName("hero")

View File

@@ -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()
}
}
}

View File

@@ -4,6 +4,7 @@ import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/modu
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { smc } from "../common/SingletonModuleComp";
import { GameEvent } from "../common/config/GameEvent";
import { HeroPageComp } from "./HeroPageComp";
const { ccclass, property } = _decorator;
@@ -38,10 +39,11 @@ export class MissionHomeComp extends CCComp {
smc.syncData()
}
btn_func(e:string,data:any){
console.log("[MissionHomeComp]:btn_func",e,data)
// console.log("[MissionHomeComp]:btn_func",e,data)
let btns=this.node.getChildByName("btns")
let shop =btns.getChildByName("shop")
let heros =btns.getChildByName("heros")
let heros_page=this.node.getChildByName("heros").getComponent(HeroPageComp)!
let fight =btns.getChildByName("fight")
let skill =btns.getChildByName("skill")
let set =btns.getChildByName("set")
@@ -62,6 +64,7 @@ export class MissionHomeComp extends CCComp {
break
case "heros":
this.node.getChildByName("heros").active=true
heros_page.update_heros()
heros.getChildByName("act").active=true
break
case "fight":