buff 改为固定时间消失,不再根据cd 保持

This commit is contained in:
2025-01-13 09:07:16 +08:00
parent 19780877ea
commit 82b68e4f87
2 changed files with 155 additions and 146 deletions

View File

@@ -1,4 +1,4 @@
import { _decorator, Component, instantiate, Label, Node, Prefab, ProgressBar, v3 } from 'cc';
import { _decorator, Component, instantiate, Label, Node, Prefab, ProgressBar, tween, v3, Vec3 } from 'cc';
import { HeroViewComp } from './HeroViewComp';
import { oops } from 'db://oops-framework/core/Oops';
import { ecs } from 'db://oops-framework/libs/ecs/ECS';
@@ -33,7 +33,7 @@ export class BuffComp extends Component {
start() {
this.heroView = this.node.getComponent(HeroViewComp);
this.in_fired(10,0)
this.show_ap(10)
// this.node.getChildByName("top").getChildByName("buff").getChildByName("ap").active = false;
// this.node.getChildByName("top").getChildByName("buff").getChildByName("cd").active = false;
// this.node.getChildByName("top").getChildByName("buff").getChildByName("def").active = false;
@@ -43,66 +43,6 @@ export class BuffComp extends Component {
update(deltaTime: number) {
if(smc.mission.pause) return
if(this.ap_cd > 0 ) this.ap_cd -= deltaTime;
if(this.ap_cd <= 0 && this.node.getChildByName("top").getChildByName("buff").getChildByName("ap").active){
this.node.getChildByName("top").getChildByName("buff").getChildByName("ap").active = false;
}
if(this.cd_cd > 0 ) this.cd_cd -= deltaTime;
if(this.cd_cd <= 0 && this.node.getChildByName("top").getChildByName("buff").getChildByName("cd").active) {
this.node.getChildByName("top").getChildByName("buff").getChildByName("cd").active = false;
}
if(this.def_cd > 0 ) this.def_cd -= deltaTime;
if(this.def_cd <= 0 && this.node.getChildByName("top").getChildByName("buff").getChildByName("def").active){
this.node.getChildByName("top").getChildByName("buff").getChildByName("def").active = false;
}
if(this.hp_cd > 0 ) this.hp_cd -= deltaTime;
if(this.hp_cd <= 0 && this.node.getChildByName("top").getChildByName("buff").getChildByName("hp").active){
this.node.getChildByName("top").getChildByName("buff").getChildByName("hp").active = false;
}
if(this.crit_cd > 0 ) this.crit_cd -= deltaTime;
if(this.crit_cd <= 0 && this.node.getChildByName("top").getChildByName("buff").getChildByName("crit").active){
this.node.getChildByName("top").getChildByName("buff").getChildByName("crit").active = false;
}
if(this.deap_cd > 0 ) this.deap_cd -= deltaTime;
if(this.deap_cd <= 0 && this.node.getChildByName("top").getChildByName("buff").getChildByName("deap").active){
this.node.getChildByName("top").getChildByName("buff").getChildByName("deap").active = false;
}
if(this.decd_cd > 0 ) this.decd_cd -= deltaTime;
if(this.decd_cd <= 0 && this.node.getChildByName("top").getChildByName("buff").getChildByName("decd").active) {
this.node.getChildByName("top").getChildByName("buff").getChildByName("decd").active = false;
}
if(this.dedef_cd > 0 ) this.dedef_cd -= deltaTime;
if(this.dedef_cd <= 0 && this.node.getChildByName("top").getChildByName("buff").getChildByName("dedef").active){
this.node.getChildByName("top").getChildByName("buff").getChildByName("dedef").active = false;
}
if(this.dehp_cd > 0 ) this.dehp_cd -= deltaTime;
if(this.dehp_cd <= 0 && this.node.getChildByName("top").getChildByName("buff").getChildByName("dehp").active){
this.node.getChildByName("top").getChildByName("buff").getChildByName("dehp").active = false;
}
if(this.decrit_cd > 0 ) this.decrit_cd -= deltaTime;
if(this.decrit_cd <= 0 && this.node.getChildByName("top").getChildByName("buff").getChildByName("decrit").active){
this.node.getChildByName("top").getChildByName("buff").getChildByName("decrit").active = false;
}
if(this.wind_cd > 0 ) this.wind_cd -= deltaTime;
if(this.wind_cd <= 0 && this.node.getChildByName("wind").active){
@@ -127,44 +67,113 @@ export class BuffComp extends Component {
show_ap(t:number=2){
this.ap_cd = t;
this.node.getChildByName("top").getChildByName("buff").getChildByName("ap").active = true;
console.log("show_ap",this.node.getChildByName("top").getChildByName("buff").getChildByName("ap"))
let node = this.node.getChildByName("top").getChildByName("buff").getChildByName("ap")
this.scheduleOnce(()=>{
tween(node).to( 0.1,
{ position: new Vec3(node.position.x,node.position.y+50) },
{ onComplete:()=>{ node.position=v3(0,0);node.active = false; }, }
).start();
}, 1);
}
show_cd(t:number=2){
this.cd_cd = t;
this.node.getChildByName("top").getChildByName("buff").getChildByName("cd").active = true;
let node = this.node.getChildByName("top").getChildByName("buff").getChildByName("cd")
this.scheduleOnce(()=>{
tween(node).to( 0.1,
{ position: new Vec3(node.position.x,node.position.y+50) },
{ onComplete:()=>{ node.position=v3(0,0);node.active = false; }, }
).start();
}, 1);
}
show_def(t:number=2){
this.def_cd = t;
this.node.getChildByName("top").getChildByName("buff").getChildByName("def").active = true;
let node = this.node.getChildByName("top").getChildByName("buff").getChildByName("def")
this.scheduleOnce(()=>{
tween(node).to( 0.1,
{ position: new Vec3(node.position.x,node.position.y+50) },
{ onComplete:()=>{ node.position=v3(0,0);node.active = false; }, }
).start();
}, 1);
}
show_hp(t:number=2){
this.hp_cd = t;
this.node.getChildByName("top").getChildByName("buff").getChildByName("hp").active = true;
let node = this.node.getChildByName("top").getChildByName("buff").getChildByName("hp")
this.scheduleOnce(()=>{
tween(node).to( 0.1,
{ position: new Vec3(node.position.x,node.position.y+50) },
{ onComplete:()=>{ node.position=v3(0,0);node.active = false; }, }
).start();
}, 1);
}
show_crit(t:number=2){
this.crit_cd = t;
this.node.getChildByName("top").getChildByName("buff").getChildByName("crit").active = true;
let node = this.node.getChildByName("top").getChildByName("buff").getChildByName("crit")
this.scheduleOnce(()=>{
tween(node).to( 0.1,
{ position: new Vec3(node.position.x,node.position.y+50) },
{ onComplete:()=>{ node.position=v3(0,0);node.active = false; }, }
).start();
}, 1);
}
show_debuff_ap(t:number=2){
this.deap_cd = t;
this.node.getChildByName("top").getChildByName("buff").getChildByName("ap").active = true;
console.log("show_ap",this.node.getChildByName("top").getChildByName("buff").getChildByName("ap"))
this.node.getChildByName("top").getChildByName("buff").getChildByName("deap").active = true;
let node = this.node.getChildByName("top").getChildByName("buff").getChildByName("deap")
this.scheduleOnce(()=>{
tween(node).to( 0.1,
{ position: new Vec3(node.position.x,node.position.y+50) },
{ onComplete:()=>{ node.position=v3(0,0);node.active = false; }, }
).start();
}, 1);
}
show_debuff_cd(t:number=2){
this.decd_cd = t;
this.node.getChildByName("top").getChildByName("buff").getChildByName("cd").active = true;
this.node.getChildByName("top").getChildByName("buff").getChildByName("decd").active = true;
let node = this.node.getChildByName("top").getChildByName("buff").getChildByName("decd")
this.scheduleOnce(()=>{
tween(node).to( 0.1,
{ position: new Vec3(node.position.x,node.position.y+50) },
{ onComplete:()=>{ node.position=v3(0,0);node.active = false; }, }
).start();
}, 1);
}
show_debuff_def(t:number=2){
this.dedef_cd = t;
this.node.getChildByName("top").getChildByName("buff").getChildByName("def").active = true;
this.node.getChildByName("top").getChildByName("buff").getChildByName("dedef").active = true;
let node = this.node.getChildByName("top").getChildByName("buff").getChildByName("dedef")
this.scheduleOnce(()=>{
tween(node).to( 0.1,
{ position: new Vec3(node.position.x,node.position.y+50) },
{ onComplete:()=>{ node.position=v3(0,0);node.active = false; }, }
).start();
}, 1);
}
show_debuff_hp(t:number=2){
this.dehp_cd = t;
this.node.getChildByName("top").getChildByName("buff").getChildByName("hp").active = true;
this.node.getChildByName("top").getChildByName("buff").getChildByName("dehp").active = true;
let node = this.node.getChildByName("top").getChildByName("buff").getChildByName("dehp")
this.scheduleOnce(()=>{
tween(node).to( 0.1,
{ position: new Vec3(node.position.x,node.position.y+50) },
{ onComplete:()=>{ node.position=v3(0,0);node.active = false; }, }
).start();
}, 1);
}
show_debuff_crit(t:number=2){
this.decrit_cd = t;
this.node.getChildByName("top").getChildByName("buff").getChildByName("crit").active = true;
this.node.getChildByName("top").getChildByName("buff").getChildByName("decrit").active = true;
let node = this.node.getChildByName("top").getChildByName("buff").getChildByName("decrit")
this.scheduleOnce(()=>{
tween(node).to( 0.1,
{ position: new Vec3(node.position.x,node.position.y+50) },
{ onComplete:()=>{ node.position=v3(0,0);node.active = false; }, }
).start();
}, 1);
}