英雄去除 smchp

This commit is contained in:
2025-08-11 22:33:22 +08:00
parent 5bcf5e737b
commit 919ff09351
5 changed files with 33 additions and 83 deletions

View File

@@ -20,7 +20,6 @@ export class Hero extends ecs.Entity {
HeroModel!: HeroModelComp;
HeroView!: HeroViewComp;
BattleMove!: BattleMoveComp;
vmHero:any={}
protected init() {
this.addComponents<ecs.Comp>(
BattleMoveComp,
@@ -40,34 +39,14 @@ export class Hero extends ecs.Entity {
super.destroy();
}
/**
* 获取所有英雄槽位
* @returns 英雄槽位数组
*/
private getHeroSlots(): any[] {
return [smc.vmdata.hero1, smc.vmdata.hero2, smc.vmdata.hero3]
}
/**
* 查找可用的英雄槽位
* @returns 可用的英雄槽位对象如果没有可用槽位则返回null
*/
private findAvailableHeroSlot(): any {
return this.getHeroSlots().find(slot => slot.uuid === 0) || null
}
/** 加载角色 */
load(pos: Vec3 = Vec3.ZERO,scale:number = 1,uuid:number=1001,info:any={ap:0,hp:0,lv:1,crit:0,crit_d:0,dod:0,dod_no:false,crit_no:false},fight_pos:number=1) {
// console.log("英雄加载:",uuid,pos,scale,info)
scale = 1
// 查找空闲英雄槽位
this.vmHero = this.findAvailableHeroSlot()
if (!this.vmHero) {
console.log("[Hero] 英雄已满")
return
}
this.vmHero.uuid=uuid
this.vmHero.count=1
var path = "game/heros/"+HeroInfo[uuid].path;
var prefab: Prefab = oops.res.get(path, Prefab)!;
var node = instantiate(prefab);
@@ -92,8 +71,6 @@ export class Hero extends ecs.Entity {
hero_init(uuid:number=1001,node:Node,info:any={ap:0,hp:0,lv:1,crit:0,crit_d:0,dod:0,dod_no:false,crit_no:false}) {
var hv = node.getComponent(HeroViewComp)!;
let hero= HeroInfo[uuid] // 共用英雄数据
hv.vmHero=this.vmHero
this.vmHero.name=hero.name
hv.scale = 1;
hv.is_master=true;
hv.lv=1
@@ -106,7 +83,7 @@ export class Hero extends ecs.Entity {
hv.speed =hv.ospeed = hero.speed;
hv.dis = hero.dis;
hv.cd = hv.cd_base = hero.cd
this.vmHero.hp=this.vmHero.hp_max= hv.hp = hv.hp_max = hv.hp_base=hero.hp+info.hp
hv.hp = hv.hp_max = hv.hp_base=hero.hp+info.hp
hv.ap = hv.ap_base=hero.ap+info.ap;
hero.buff.forEach((buff:any)=>{
switch(buff.buff_type){
@@ -161,8 +138,13 @@ export class Hero extends ecs.Entity {
}
})
hv.atk_skill=hero.skills[0]
hv.skills=hero.skills
this.vmHero.cd_max=SkillSet[hv.skills[1]].cd
for(let i=0;i<hero.skills.length;i++){
hv.skills.push({
cd:0,
uuid:hero.skills[i],
cd_max:i==0?hero.cd:SkillSet[hero.skills[i]].cd
})
}
return hv
}