英雄召唤基本完成 下一步 满3个英雄后 不再出现其他英雄

This commit is contained in:
2025-08-05 22:28:24 +08:00
parent 6f9529ada2
commit 97bba4edb7
8 changed files with 3112 additions and 1365 deletions

View File

@@ -10,8 +10,9 @@ import { BattleMoveComp } from "../common/ecs/position/BattleMoveComp";
import { FriendModelComp } from "./FriendModel";
import { MasterModelComp } from "./MasterModel";
import { GameEvent } from "../common/config/GameEvent";
import { BuffAttr } from "../common/config/SkillSet";
import { BuffAttr, SkillSet } from "../common/config/SkillSet";
import { FightSet } from "../common/config/Mission";
import { Skill } from "../skills/Skill";
/** 角色实体 */
@ecs.register(`Hero`)
@@ -39,20 +40,29 @@ 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
if(smc.vmdata.hero1.uuid==0){
this.vmHero=smc.vmdata.hero1
}else if(smc.vmdata.hero2.uuid==0){
this.vmHero=smc.vmdata.hero2
}else if(smc.vmdata.hero3.uuid==0){
this.vmHero=smc.vmdata.hero3
}else{
// 查找空闲英雄槽位
this.vmHero = this.findAvailableHeroSlot()
if (!this.vmHero) {
console.log("[Hero] 英雄已满")
return
}
@@ -95,7 +105,7 @@ export class Hero extends ecs.Entity {
hv.hero_name= hero.name;
hv.speed =hv.ospeed = hero.speed;
hv.dis = hero.dis;
this.vmHero.cd_max=hv.cd = hv.cd_base = hero.cd
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.ap = hv.ap_base=hero.ap+info.ap;
hero.buff.forEach((buff:any)=>{
@@ -151,6 +161,8 @@ 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
return hv
}