import { _decorator, Component, instantiate, Label, Node, Prefab, ProgressBar, v3 } from 'cc'; import { HeroViewComp } from './HeroViewComp'; import { oops } from 'db://oops-framework/core/Oops'; import { ecs } from 'db://oops-framework/libs/ecs/ECS'; import { Tooltip } from '../skills/Tooltip'; import { timedCom } from '../skills/timedCom'; import { smc } from '../common/SingletonModuleComp'; const { ccclass, property } = _decorator; @ccclass('BuffComp') export class BuffComp extends Component { heroView: any=null; ap_node:any=null; cd_node:any=null; def_node:any=null; hp_node:any=null; crit_node:any=null; ap_cd:number=0; cd_cd:number=0; def_cd:number=0; hp_cd:number=0; crit_cd:number=0; deap_cd:number=0; decd_cd:number=0; dedef_cd:number=0; dehp_cd:number=0; decrit_cd:number=0; buff_cd:number=0; wind_cd:number=0; speek_time:number=0; start() { this.heroView = this.node.getComponent(HeroViewComp); // 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; // this.node.getChildByName("top").getChildByName("buff").getChildByName("hp").active = false; // this.node.getChildByName("top").getChildByName("buff").getChildByName("crit").active = false; } 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){ this.node.getChildByName("wind").active = false; } if(this.buff_cd > 0 ) this.buff_cd -= deltaTime; if(this.buff_cd <= 0 && this.node.getChildByName("buff").active){ this.node.getChildByName("buff").active = false; } this.hp_show() this.in_speek(deltaTime) if(this.heroView.shield > 0){ this.node.getChildByName("shielded").active=true }else{ this.node.getChildByName("shielded").active=false } } 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")) } show_cd(t:number=2){ this.cd_cd = t; this.node.getChildByName("top").getChildByName("buff").getChildByName("cd").active = true; } show_def(t:number=2){ this.def_cd = t; this.node.getChildByName("top").getChildByName("buff").getChildByName("def").active = true; } show_hp(t:number=2){ this.hp_cd = t; this.node.getChildByName("top").getChildByName("buff").getChildByName("hp").active = true; } show_crit(t:number=2){ this.crit_cd = t; this.node.getChildByName("top").getChildByName("buff").getChildByName("crit").active = true; } 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")) } show_debuff_cd(t:number=2){ this.decd_cd = t; this.node.getChildByName("top").getChildByName("buff").getChildByName("cd").active = true; } show_debuff_def(t:number=2){ this.dedef_cd = t; this.node.getChildByName("top").getChildByName("buff").getChildByName("def").active = true; } show_debuff_hp(t:number=2){ this.dehp_cd = t; this.node.getChildByName("top").getChildByName("buff").getChildByName("hp").active = true; } show_debuff_crit(t:number=2){ this.decrit_cd = t; this.node.getChildByName("top").getChildByName("buff").getChildByName("crit").active = true; } show_wind(t:number=1){ this.wind_cd = t; this.node.getChildByName("wind").active = true; } show_buff(t:number=1){ this.buff_cd = t; this.node.getChildByName("buff").active = true; } hp_show(){ let hp_progress= this.heroView.hp/this.heroView.rhp_max; this.node.getChildByName("top").getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress; if(this.heroView.hp == this.heroView.rhp_max){ this.node.getChildByName("top").getChildByName("hp").active = false; } else{ this.node.getChildByName("top").getChildByName("hp").active = true; } } max_show(){ this.node.getChildByName("max").active=true this.scheduleOnce(()=>{ this.node.getChildByName("max").active=false },0.8) } dead(){ var path = "game/skills/dead"; var prefab: Prefab = oops.res.get(path, Prefab)!; var node = instantiate(prefab); let pos = v3(this.node.position.x,this.node.position.y+30,this.node.position.z); node.parent = this.node; node.setPosition(pos); } in_atked() { var path = "game/skills/atked"; var prefab: Prefab = oops.res.get(path, Prefab)!; var node = instantiate(prefab); let pos =v3(15,30); node.setPosition(pos) node.parent = this.node; } in_iced(t:number=1,ap:number=0) { var path = "game/skills/iced"; var prefab: Prefab = oops.res.get(path, Prefab)!; var node = instantiate(prefab); node.getComponent(timedCom).time = t; node.getComponent(timedCom).ap = ap; node.parent = this.node; } in_fired(t:number=1,ap:number=0) { var path = "game/skills/fired"; var prefab: Prefab = oops.res.get(path, Prefab)!; var node = instantiate(prefab); node.getComponent(timedCom).time = t; node.getComponent(timedCom).ap = ap; node.parent = this.node; } in_yun(t:number=1,ap:number=0) { var path = "game/skills/yun"; var prefab: Prefab = oops.res.get(path, Prefab)!; var node = instantiate(prefab); node.setPosition(v3(0,90)); node.getComponent(timedCom).time = t; node.getComponent(timedCom).ap = ap; node.parent = this.node; } to_speek(words:string,time:number=0.5){ this.speek_time=0.5 this.node.getChildByName("tooltip").active=true this.node.getChildByName("tooltip").getChildByName("words").getComponent(Label)!.string = words } in_speek(dt: number){ if(this.speek_time <= 0){ return; } this.speek_time -= dt; if(this.speek_time <= 0){ this.speek_time = 0; this.node.getChildByName("tooltip").getChildByName("words").getComponent(Label)!.string = ""; this.node.getChildByName("tooltip").active=false; } } tooltip(type:number=1,value:string="",s_uuid:number=1001,y:number=90){ // console.log("tooltip",type); let tip =ecs.getEntity(Tooltip); let pos = v3(0,0); pos.y=pos.y+y; tip.load(pos,type,value,s_uuid,this.node); } heathed(){ this.node.getChildByName("heathed").active=true } }