hp buff 基本完成
This commit is contained in:
@@ -60,6 +60,7 @@ export class BuffComp extends Component {
|
||||
this.vmdata_update()
|
||||
}
|
||||
to_update_vmdata(){
|
||||
|
||||
this.vmdata_update(false)
|
||||
}
|
||||
update(deltaTime: number) {
|
||||
@@ -91,7 +92,9 @@ export class BuffComp extends Component {
|
||||
}
|
||||
|
||||
vmdata_update(is_hp:boolean=false){
|
||||
console.log("[BuffComp]:vmdata_update",is_hp)
|
||||
if(this.HeroView.is_kalami) return
|
||||
console.log("[BuffComp]:to_update_vmdata:"+this.HeroView.hero_name)
|
||||
|
||||
let buff=null
|
||||
let info= null
|
||||
if(!this.HeroView) return
|
||||
@@ -104,12 +107,12 @@ export class BuffComp extends Component {
|
||||
let view_deatk = 0 //临时debuff
|
||||
if(is_hp){
|
||||
info.hp=this.HeroView.hp
|
||||
info.hp_max=this.HeroView.hp_max*(100+buff.HP)/100
|
||||
info.hp_buff=buff.HP
|
||||
info.hp_max=this.HeroView.hp_max*(100+buff.HP)/100
|
||||
}else{
|
||||
info.hp=this.HeroView.hp
|
||||
info.hp_max=this.HeroView.hp_max*(100+buff.HP)/100
|
||||
info.hp_buff=buff.HP
|
||||
info.hp_max=this.HeroView.hp_max*(100+buff.HP)/100
|
||||
for(let i=0;i<this.HeroView.BUFF_ATKS.length;i++){
|
||||
view_atk += this.HeroView.BUFF_ATKS[i].value
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ export class Hero extends ecs.Entity {
|
||||
// console.log("hero load",pos)
|
||||
var hv = this.hero_init(uuid,node,info)
|
||||
hv.fight_pos=fight_pos
|
||||
hv.is_friend=true
|
||||
this.add(hv);
|
||||
this.addComponents<ecs.Comp>(FriendModelComp);
|
||||
// const move = this.get(BattleMoveComp);
|
||||
@@ -90,7 +91,7 @@ export class Hero extends ecs.Entity {
|
||||
hv.hero_name= hero.name;
|
||||
hv.speed =hv.ospeed = hero.speed;
|
||||
hv.dis = hero.dis;
|
||||
hv.cd = hero.a_cd
|
||||
hv.cd = hero.cd
|
||||
hv.hp= hv.hp_max =hero.hp+info.hp
|
||||
hv.ap = hero.ap+info.ap;
|
||||
hv.crit=hero.crit+info.crit
|
||||
|
||||
@@ -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; /** 角色阵营 1:hero -1 :mon */
|
||||
type: number = 0; /**角色类型 0近战-需要贴身 1远程-保持距离 2辅助 */
|
||||
fac:number=0; //阵营 0:hero 1:monster
|
||||
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()
|
||||
|
||||
@@ -59,6 +59,9 @@ export class Monster extends ecs.Entity {
|
||||
hv.fac = FacSet.MON;
|
||||
hv.type = hero.type;
|
||||
hv.is_boss = is_boss;
|
||||
if(!is_boss){
|
||||
hv.is_kalami=true
|
||||
}
|
||||
hv.box_group = box_group;
|
||||
hv.hero_uuid= uuid;
|
||||
hv.hero_name= hero.name;
|
||||
@@ -66,13 +69,14 @@ export class Monster extends ecs.Entity {
|
||||
hv.dis = hero.dis;
|
||||
hv.hp= hv.hp_max =hero.hp;
|
||||
hv.ap = hero.ap;
|
||||
hv.cd = hero.a_cd
|
||||
hv.cd = hero.cd
|
||||
hv.crit=hero.crit
|
||||
hv.crit_d=hero.crit_d
|
||||
hv.dod=hero.dod
|
||||
hv.dod_no=hero.dod_no
|
||||
hv.crit_no=hero.crit_no
|
||||
hv.atk_skill=hero.skills[0]
|
||||
|
||||
this.add(hv);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user