hp buff 基本完成

This commit is contained in:
2025-06-25 21:09:54 +08:00
parent db0a0dd19c
commit 7363952dae
7 changed files with 62 additions and 73 deletions

View File

@@ -30,11 +30,9 @@ export class HeroViewComp extends CCComp {
hero_name : string = "hero";
fight_pos:number=0;
lv:number =1;
slv:number =1;
scale: number = 1; /** 角色阵营 1hero -1 :mon */
type: number = 0; /**角色类型 0近战-需要贴身 1远程-保持距离 2辅助 */
fac:number=0; //阵营 0hero 1monster
atk_range:number = 150;
box_group:number = BoxSet.HERO;
@@ -47,21 +45,20 @@ export class HeroViewComp extends CCComp {
is_master:boolean =false;
is_friend:boolean =false;
is_kalami:boolean =false;
ap_u:number=0;
ap_ur:number=0;
hp_up:number=0;
hp: number = 100; /** 血量 */
hp_max: number = 100; /** 最大血量 */
hp_buff:number=0;
hp_speed: number = 0; //每秒回复量
buff_hp:number=0;
pwt:Timer = new Timer(1); //计时器
ap: number = 10; /**攻击力 */
buff_ap:number=0;
// atk_speed: number = 1;
cd: number = 1.3; /**攻击速度 攻击间隔 */
dis: number = 80;
at: number = 0; /** 冷却时间 */
atk_skill:number=0;
def: number = 0; //防御
vun: number = 0; //易伤
@@ -79,12 +76,12 @@ export class HeroViewComp extends CCComp {
atked_count: number = 0;
atk_add_count:number=0;
stop_cd: number = 0; /*停止倒计时*/
dir_y:number = 0;
speek_time:number = 0;
is_stop_temp:boolean = false;i
is_stop_temp:boolean = false
Friend_alive_cd:Timer=new Timer(10)
double_dead:boolean=false
double_atked:boolean=false
BUFF_DEFS: Array<{value: number, count: number}> = []
BUFF_ATKS: Array<{value: number, count: number}> = []
BUFF_CDS: Array<{value: number, count: number}> = []
@@ -127,11 +124,8 @@ export class HeroViewComp extends CCComp {
}
/* 显示角色血量 */
this.node.getChildByName("top").getChildByName("hp").active = true;
if(!this.is_master&&this.fac==FacSet.HERO){
this.is_friend=true
}
if(this.fac==FacSet.MON&&!this.is_boss&&!this.is_big_boss){
this.is_kalami=true
if(this.is_friend){ //只有伙伴需要召唤后添加hp 怪物,和boss 不要设置减hp debuff 主要 一开始就战斗开始就存在,所以不需要
this.hp+=this.FIGHTCON.friend_buff.HP*this.hp_max/100
}
}
@@ -237,34 +231,25 @@ export class HeroViewComp extends CCComp {
update_hp(e:GameEvent,data:any){
console.log("[HeroViewComp]:update_hp",data)
if(this.is_master===data.is_master&&this.fac===FacSet.HERO){
this.hp_buff += data.hp
this.buff_hp += data.hp
if(data.hp > 0){
this.hp += this.hp_max*data.hp/100
if(this.hp > this.hp_max*(100+this.hp_buff/100)){
this.hp=this.hp_max*(100+this.hp_buff/100)
if(this.hp > this.hp_max*(100+this.buff_hp/100)){
this.hp=this.hp_max*(100+this.buff_hp/100)
}
}
}
}
add_hp_max(hp: number=0,is_num:boolean=true){
console.log("[HeroViewComp]:add_hp_max add:",hp,this.hp_max)
if(is_num){
this.hp_max += Math.floor(hp) ;
this.hp += Math.floor(hp) ;
}else{
this.hp_max += Math.floor(hp/100*this.hp_max);
this.hp += Math.floor(hp/100*this.hp_max);
}
this.hp_max += Math.floor(hp) ;
this.hp += Math.floor(hp*(100+this.buff_hp)/100) ;
this.BUFFCOMP.update_info_hp()
}
de_hp_max(hp: number=0,is_num:boolean=true){
de_hp_max(hp: number=0,is_num:boolean=true){ //最大值 只存在数值添加, 比例通过buff_hp处理
console.log("[HeroViewComp]:de_hp_max de:",hp,this.hp_max)
if(is_num){
this.hp_max -= Math.floor(hp) ;
}else{
this.hp_max -= Math.floor(hp/100*this.hp_max);
}
this.hp_max -= Math.floor(hp) ;
this.BUFFCOMP.update_info_hp()
this.BUFFCOMP.vmdata_update(true)
}
@@ -539,7 +524,7 @@ export class HeroViewComp extends CCComp {
}
to_alive(){
this.is_dead=false
this.hp=this.hp_max
this.hp=this.hp_max*(100+this.buff_hp)/100
this.BUFFCOMP.update_info_hp()
this.node.setPosition(HeroPos[this.fight_pos].pos)
this.BUFFCOMP.heathed()