英雄召唤基本完成 下一步 满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

@@ -39,6 +39,48 @@ export class HeroViewComp extends CCComp {
vmHero:any={}
/**
* 获取当前血量 - 根据阵营选择正确的变量
*/
get currentHp(): number {
if (this.fac === FacSet.HERO) {
return this.vmHero.hp || 0;
}
return this.hp;
}
/**
* 设置当前血量 - 根据阵营选择正确的变量
*/
set currentHp(value: number) {
if (this.fac === FacSet.HERO) {
this.vmHero.hp = value;
} else {
this.hp = value;
}
}
/**
* 获取最大血量 - 根据阵营选择正确的变量
*/
get currentHpMax(): number {
if (this.fac === FacSet.HERO) {
return this.vmHero.hp_max || 0;
}
return this.hp_max;
}
/**
* 设置最大血量 - 根据阵营选择正确的变量
*/
set currentHpMax(value: number) {
if (this.fac === FacSet.HERO) {
this.vmHero.hp_max = value;
} else {
this.hp_max = value;
}
}
box_group:number = BoxSet.HERO;
is_dead:boolean = false; //是否摧毁
@@ -68,6 +110,7 @@ export class HeroViewComp extends CCComp {
dis: number = 80;
at: number = 0; /** 冷却时间 */
atk_skill:number=0;
skills:any[]=[]
puncture:number=0; //穿刺敌人伤害后方敌人个数
puncture_damage:number=0; //后伤害加成
def: number = 0; //免伤
@@ -156,6 +199,7 @@ export class HeroViewComp extends CCComp {
this.as = this.getComponent(HeroSpine);
//console.log("[HeroViewComp]:hero view comp ",this.FIGHTCON)
this.on(GameEvent.EXPUP,this.exp_up,this)
this.on(GameEvent.HeroLvUp,this.to_update_lv,this)
const collider = this.node.getComponent(BoxCollider2D);
this.scheduleOnce(()=>{
if (collider) collider.enabled = true; // 先禁用
@@ -311,7 +355,6 @@ export class HeroViewComp extends CCComp {
return this.cd_base/((this.cd_buff+this.TALENT[BuffAttr.ATK_CD])/100+1)
case BuffAttr.HP:
return Math.floor(this.hp_base*(100+this.hp_buff+this.TALENT[BuffAttr.HP])/100)
}
}
@@ -326,9 +369,9 @@ export class HeroViewComp extends CCComp {
// this.update_vmdata()
break
case BuffAttr.HP:
let diff=this.check_atrr(BuffAttr.HP)-this.hp_max
this.hp_max=this.check_atrr(BuffAttr.HP)
this.hp+=diff
let diff=this.check_atrr(BuffAttr.HP)-this.currentHpMax
this.currentHpMax=this.check_atrr(BuffAttr.HP)
this.currentHp+=diff
// this.update_vmdata()
break
}
@@ -363,7 +406,7 @@ export class HeroViewComp extends CCComp {
}
add_hp_max(hp: number=0,is_num:boolean=false){
// console.log("[HeroViewComp]:add_hp_max add:",hp,this.hp_max)
// console.log("[HeroViewComp]:add_hp_max add:",hp,this.currentHpMax)
if(is_num){
this.hp_base += Math.floor(hp) ;
}else{
@@ -374,7 +417,7 @@ export class HeroViewComp extends CCComp {
}
de_hp_max(hp: number=0,is_num:boolean=true){ //最大值 只存在数值添加, 比例通过hp_buff处理
//console.log("[HeroViewComp]:de_hp_max de:",hp,this.hp_max)
//console.log("[HeroViewComp]:de_hp_max de:",hp,this.currentHpMax)
this.hp_base -= Math.floor(hp) ;
this.count_atrr(BuffAttr.HP)
// this.update_vm
@@ -383,8 +426,8 @@ export class HeroViewComp extends CCComp {
add_hp(hp: number = 0,is_num:boolean=true) {
this.BUFFCOMP.heathed();
let real_hp=0
let hp_max=Math.floor(this.hp_max*(100+this.hp_buff)/100)
let lost_hp=hp_max-this.hp
let hp_max=Math.floor(this.currentHpMax*(100+this.hp_buff)/100)
let lost_hp=hp_max-this.currentHp
if(is_num){
if(lost_hp > hp){
real_hp=Math.floor(hp);
@@ -399,7 +442,7 @@ export class HeroViewComp extends CCComp {
}
}
if(real_hp > 0){
this.hp+=real_hp;
this.currentHp+=real_hp;
this.BUFFCOMP.tooltip(TooltipTypes.health,real_hp.toFixed(0));
}
// this.update_vm
@@ -486,8 +529,8 @@ export class HeroViewComp extends CCComp {
// this.is_stop=true
break
case DebuffAttr.DEHP:
this.hp_max-=deV/100*this.hp_max
if(this.hp-this.hp_max>0) this.hp=this.hp_max
this.currentHpMax-=deV/100*this.currentHpMax
if(this.currentHp-this.currentHpMax>0) this.currentHp=this.currentHpMax
break
case DebuffAttr.DEATK: //99为具体数字 并且局内永久生效,其他为百分比
if(deC == 99){
@@ -610,11 +653,11 @@ export class HeroViewComp extends CCComp {
damage = Math.floor(damage * (1 + (FightSet.CRIT_DAMAGE+crit_d)/100))
if(this.fac==FacSet.MON) smc.vmdata.hero.power+=smc.vmdata.hero.POWER_UP+FightSet.CRIT_TO_POWER //暴击涨能量 怪物被暴击,因为只有一个英雄 直接处理
}
this.hp -= damage;
this.currentHp -= damage;
if(this.fac==FacSet.HERO) smc.vmdata.hero.power+=smc.vmdata.hero.POWER_UP+FightSet.ATKED_TO_POWER //被攻击涨能量
if(this.fac==FacSet.MON) smc.vmdata.hero.power+=smc.vmdata.hero.POWER_UP+FightSet.ATK_TO_POWER //攻击命中涨能量 因为是只有1个英雄 直接处理
if(this.hp <= 0) {
if(this.currentHp <= 0) {
if(this == null) return;
this.is_dead=true
this.BUFFCOMP.dead()
@@ -727,7 +770,7 @@ export class HeroViewComp extends CCComp {
}
// to_alive(){
// this.is_dead=false
// this.hp=this.hp_max*(100+this.hp_buff)/100
// this.currentHp=this.currentHpMax*(100+this.hp_buff)/100
// this.BUFFCOMP.vmdata_update(true)
// this.node.setPosition(HeroPos[this.fight_pos].pos)
// this.BUFFCOMP.heathed()
@@ -775,14 +818,18 @@ export class HeroViewComp extends CCComp {
// smc.vmdata.hero.next_exp=getUpExp(this.lv)
if(smc.vmdata.hero.exp >= smc.vmdata.hero.next_exp){
// console.log("[HeroViewComp]:升级")
this.to_update()
this.to_update_lv("seft",data)
oops.message.dispatchEvent(GameEvent.CanUpdateLv)
}
}
to_update(){
to_update_lv(event:string,data:any){
if(this.fac==FacSet.MON) return
console.log("[HeroViewComp]:升级",this.BUFFCOMP)
if(this.hero_uuid!=data.uuid) return
this.add_ap(HeroInfo[data.uuid].ap,true)
this.add_hp_max(HeroInfo[data.uuid].hp,true)
this.BUFFCOMP.lv_up()
// this.BUFFCOMP.tooltip(TooltipTypes.lvup)
}