buff 优化 heroset 不再使用json
This commit is contained in:
@@ -52,7 +52,7 @@ export class MonsterBuffComp extends CCComp {
|
||||
|
||||
}
|
||||
add_buff(uuid:number=0,eid:number=0,group:number=0){
|
||||
// console.log("add_buff",event,args,smc.skills[uuid]);
|
||||
// console.log("add_buff",smc.skills[uuid]);
|
||||
|
||||
let new_buff={
|
||||
skill_uuid:uuid,
|
||||
@@ -87,35 +87,51 @@ export class MonsterBuffComp extends CCComp {
|
||||
}
|
||||
|
||||
buff_add(buff:any){
|
||||
// console.log("buff add:",this.buffs);
|
||||
if(!this.node.isValid){ return }
|
||||
let i = 0
|
||||
if(this.buffs.length >=0){
|
||||
this.buffs.forEach((b:any,index:number)=>{
|
||||
if(b.skill_uuid==buff.skill_uuid){
|
||||
b.time=buff.time;
|
||||
this.mv.atk+=(buff.atk-b.atk);
|
||||
this.mv.hp+=(buff.hp-b.hp);
|
||||
this.mv.hp_max+=(buff.hp-b.hp);
|
||||
this.mv.shield=buff.shield-b.shield;
|
||||
if(buff.atk>0){
|
||||
this.mv.atk+=(buff.atk-b.atk);
|
||||
}
|
||||
if(buff.hp>0){
|
||||
this.mv.hp+=(buff.hp-b.hp);
|
||||
this.mv.hp_max+=(buff.hp-b.hp);
|
||||
}
|
||||
if(buff.shield>0){
|
||||
this.mv.shield=buff.shield;
|
||||
this.mv.shield_max=buff.shield;
|
||||
}
|
||||
|
||||
i=index
|
||||
}
|
||||
})
|
||||
}
|
||||
if (i==0||this.buffs.length==0) {
|
||||
this.buffs.push(buff);
|
||||
this.mv.atk+=buff.atk;
|
||||
this.mv.hp+=buff.hp;
|
||||
this.mv.hp_max+=buff.hp;
|
||||
this.mv.shield+=buff.shield;
|
||||
if(buff.atk>0){
|
||||
this.mv.atk+=buff.atk;
|
||||
}
|
||||
if(buff.hp>0){
|
||||
this.mv.hp+=buff.hp;
|
||||
this.mv.hp_max+=buff.hp;
|
||||
}
|
||||
if(buff.shield>0){
|
||||
this.mv.shield=buff.shield;
|
||||
this.mv.shield_max=buff.shield;
|
||||
}
|
||||
|
||||
}
|
||||
// console.log("buff add:"+this.mv.ent.eid,this.node);
|
||||
console.log("buff add:",this.mv);
|
||||
}
|
||||
buff_remove(index:number){
|
||||
this.mv.atk=this.mv.atk-this.buffs[index].atk;
|
||||
this.mv.hp_max=this.mv.hp_max-this.buffs[index].hp;
|
||||
this.mv.shield=this.mv.shield-this.buffs[index].shield;
|
||||
// console.log("buff remove:"+this.mv.ent.eid,this.node)
|
||||
this.mv.atk-=this.buffs[index].atk;
|
||||
this.mv.hp_max-=this.buffs[index].hp;
|
||||
// this.mv.shield=0;
|
||||
this.mv.shield_max-=this.buffs[index].shield;
|
||||
console.log("buff remove:",this.mv);
|
||||
}
|
||||
buff_update(){
|
||||
this.buffs.forEach((buff:any,index:number)=>{
|
||||
|
||||
@@ -154,6 +154,7 @@ export class MonsterViewComp extends CCComp {
|
||||
this.power_change(this.power_speed)
|
||||
}
|
||||
this.in_destroy();
|
||||
this.in_shield();
|
||||
this.in_stop(dt);
|
||||
this.in_act(dt);
|
||||
this.move(dt);
|
||||
@@ -220,6 +221,15 @@ export class MonsterViewComp extends CCComp {
|
||||
this.atk_time += dt;
|
||||
}
|
||||
}
|
||||
in_shield(){
|
||||
if(this.shield <= 0){
|
||||
this.node.getChildByName("shield").active=false
|
||||
}else{
|
||||
this.node.getChildByName("shield").active=true
|
||||
let shield_progress= this.shield/this.shield_max;
|
||||
this.node.getChildByName("shield").getComponent(ProgressBar)!.progress = shield_progress;
|
||||
}
|
||||
}
|
||||
hp_change(hp: number){
|
||||
if(this.is_dead){
|
||||
return;
|
||||
@@ -252,8 +262,6 @@ export class MonsterViewComp extends CCComp {
|
||||
this.shield = ls;
|
||||
return 0;
|
||||
}
|
||||
// let shield_progress= this.shield/this.shield_max;
|
||||
// this.node.getChildByName("shield").getComponent(ProgressBar)!.progress = shield_progress;
|
||||
}
|
||||
tooltip(type:number=1,value:string="",s_uuid:number=1001){
|
||||
// console.log("tooltip",type);
|
||||
|
||||
Reference in New Issue
Block a user