This commit is contained in:
2024-09-11 18:00:43 +08:00
parent ef4e502adf
commit 4501876c37
44 changed files with 518 additions and 4634 deletions

View File

@@ -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);