import { _decorator, Component, instantiate, Label, Node, Prefab, ProgressBar, tween, v3, Vec3 } from 'cc'; 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'; import { BuffGet } from '../skills/BuffGet'; import { HeroViewComp } from './HeroViewComp'; import { FightConComp } from '../map/FightConComp'; import { BuffAttr, DebuffAttr } from '../common/config/SkillSet'; import { GameEvent } from '../common/config/GameEvent'; const { ccclass, property } = _decorator; @ccclass('BuffComp') export class BuffComp extends Component { top_node: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; HeroView:HeroViewComp=null! FIGHTCON:FightConComp=null! protected onLoad(): void { oops.message.on(GameEvent.UpdateVMData,this.to_update_vmdata,this) } start() { this.info_init() } info_init(){ this.HeroView=this.node.getComponent(HeroViewComp) this.FIGHTCON=this.node.parent.getComponent(FightConComp) this.top_node = this.node.getChildByName("top"); this.top_node.getChildByName("lv").active=false // this.top_node.getChildByName("hp").active=(this.node.getComponent(HeroViewComp).fac == 1 ? true : false) this.top_node.getChildByName("sboss").active= this.HeroView.is_boss this.top_node.getChildByName("lv").getChildByName("lv").getComponent(Label)!.string = this.HeroView.lv.toFixed(0) this.top_node.getChildByName("ihp").getChildByName("num").getComponent(Label)!.string = this.HeroView.hp.toFixed(0) this.top_node.getChildByName("iap").getChildByName("num").getComponent(Label)!.string = this.HeroView.ap.toFixed(0) this.top_node.getChildByName("ihp").active=false this.top_node.getChildByName("iap").active=false this.vmdata_update() } to_update_vmdata(){ this.vmdata_update(false) } update(deltaTime: number) { if(smc.mission.pause) return this.hp_show() 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.in_speek(deltaTime) // this.vmdata_update() } hp_show(){ // if(this.node.getComponent(HeroViewComp).fac == 0) return let hp=this.HeroView.hp; let hp_max=this.HeroView.hp_max; let hp_progress= hp/hp_max; this.top_node.getChildByName("hp").getComponent(ProgressBar)!.progress = hp_progress; if(this.HeroView.is_boss) return this.top_node.getChildByName("hp").active = (hp == hp_max) ? false : true; } show_shield(val:boolean){ this.node.getChildByName("shielded").active=val } vmdata_update(is_hp:boolean=false){ console.log("[BuffComp]:vmdata_update",is_hp) let buff=null let info= null if(!this.HeroView) return if(this.HeroView.is_master) {info=smc.vmdata.hero;buff=this.FIGHTCON.hero_buff} if(this.HeroView.is_friend) {info=smc.vmdata.friend;buff=this.FIGHTCON.friend_buff} if(this.HeroView.is_boss) {info=smc.vmdata.boss;buff=this.FIGHTCON.enemy_buff} //if(this.HeroView.is_kalami) {target_key="enemy";buff_key="enemy"} 不显示小怪 if(info==null) return let view_atk = 0 //临时buff let view_deatk = 0 //临时debuff if(is_hp){ info.hp=this.HeroView.hp info.hp_max=this.HeroView.hp_max*(100+buff.HP)/100 info.hp_buff=buff.HP }else{ info.hp=this.HeroView.hp info.hp_max=this.HeroView.hp_max*(100+buff.HP)/100 info.hp_buff=buff.HP for(let i=0;i(Tooltip); let pos = v3(0,10); pos.y=pos.y+y; tip.load(pos,type,value,s_uuid,this.node); } heathed(){ var path = "game/skills/heathed"; var prefab: Prefab = oops.res.get(path, Prefab)!; var node = instantiate(prefab); node.parent = this.node; } }