英雄展示页面++

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

@@ -37,9 +37,9 @@ export class SingletonModuleComp extends ecs.Comp {
4:0,
}
heros:any = {
5001:{lv:1},
5005:{lv:1},
5007:{lv:1},
5001:{uuid:5001,lv:1,slv:0},
5005:{uuid:5005,lv:1,slv:0},
5007:{uuid:5007,lv:1,slv:0},
};
monsters:any = [];
@@ -312,7 +312,9 @@ export class SingletonModuleComp extends ecs.Comp {
this.setHeroProperty(heroId, "lv", newLevel, autoSave);
console.log(`[SMC]: 英雄${heroId}升级: ${currentLevel} -> ${newLevel}`);
}
getHasHeroUUID() {
return Object.keys(this.heros).map(Number)
}
/**
* 获取英雄等级
* @param heroId 英雄ID

View File

@@ -71,7 +71,7 @@ export const MonSet = {
export const HeroInfo = {
//主将
5001:{uuid:5001,name:"火焰骑士",path:"hk1", fac:FacSet.HERO, quality:HQuality.BLUE,lv:1,kind:1,
5001:{uuid:5001,name:"火焰骑士",path:"hk1", fac:FacSet.HERO, quality:HQuality.GREEN,lv:1,kind:1,
type:HType.warrior,hp:100,ap:15,dis:100,cd:1,speed:150,skills:[6011,6020],
buff:[],info:"剑类专精,穿刺伤害额外+10%"},
@@ -92,7 +92,7 @@ export const HeroInfo = {
buff:[],info:"说明"},
5007:{uuid:5007,name:"mh1",path:"hmh1", fac:FacSet.HERO, quality:HQuality.BLUE,lv:1,kind:2,
5007:{uuid:5007,name:"mh1",path:"hmh1", fac:FacSet.HERO, quality:HQuality.PURPLE,lv:1,kind:2,
type:HType.mage,hp:100,ap:15,dis:400,cd:1,speed:100,skills:[6002,6002],
buff:[],info:"说明"},

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":