dd
This commit is contained in:
@@ -84,6 +84,8 @@ export class HeroViewComp extends CCComp {
|
||||
is_stop:boolean = false;
|
||||
is_atking:boolean = false;
|
||||
|
||||
buffs:any=[];
|
||||
|
||||
onLoad() {
|
||||
this.as = this.getComponent(HeroSpine);
|
||||
this.buff=this.node.getComponent(HeroBuffComp);
|
||||
@@ -346,6 +348,14 @@ export class HeroViewComp extends CCComp {
|
||||
let hp_progress= this.hp/this.hp_max;
|
||||
this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress;
|
||||
}
|
||||
add_atk(atk: number,time:number=0){
|
||||
if(time > 0){
|
||||
let buff={atk:atk,time:time}
|
||||
this.buffs.push(buff);
|
||||
}else{
|
||||
this.atk += atk;
|
||||
}
|
||||
}
|
||||
shield_change(hp: number){
|
||||
let ls=this.shield - hp;
|
||||
if(ls <= 0){
|
||||
@@ -356,6 +366,17 @@ export class HeroViewComp extends CCComp {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
check_buffs(dt: number){
|
||||
for(let i=0;i<this.buffs.length;i++){
|
||||
let buff=this.buffs[i];
|
||||
buff.time -= dt;
|
||||
if(buff.time <= 0){
|
||||
if(buff.atk > 0)this.atk -= buff.atk;
|
||||
if(buff.shield > 0)this.shield=this.shield_max=0;
|
||||
this.buffs.splice(i,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
tooltip(type:number=1,value:string="",s_uuid:number=1001){
|
||||
// console.log("tooltip",type);
|
||||
let tip =ecs.getEntity<Tooltip>(Tooltip);
|
||||
|
||||
Reference in New Issue
Block a user