import { _decorator, Component, Node, RigidBody2D, tween, Vec3 } from 'cc'; import { SkillCom } from './SkillCom'; import { HeroViewComp } from '../hero/HeroViewComp'; import { smc } from '../common/SingletonModuleComp'; import { HeroModelComp } from '../hero/HeroModelComp'; import { ecs } from '../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS'; import { BoxSet } from '../common/config/BoxSet'; import { MonModelComp } from '../hero/MonModelComp'; import { SkillSet } from '../common/config/SkillSet'; const { ccclass, property } = _decorator; @ccclass('CdCom') export class CdCom extends Component { cd:number = 0; base:SkillCom = null time:number = 0; rigid:RigidBody2D = null start() { this.base =this.node.getComponent(SkillCom) this.rigid = this.getComponent(RigidBody2D); } update(deltaTime: number) { if(smc.mission.pause) return this.cd+=deltaTime if(this.cd>=this.base.cd){ if(this.base.is_destroy) return // this.node.setPosition(v3(-1000,0,0)) this.rigid.sleep() this.rigid.wakeUp() if(this.base.tg==2) this.do_all_buff() this.cd=0 } } do_all_buff(){ let heros:any = ecs.query(ecs.allOf(HeroModelComp)); if(this.base.box_group==BoxSet.MONSTER) heros = ecs.query(ecs.allOf(MonModelComp)); for (let i = 0; i < heros.length; i++) { let hero:any = heros[i].HeroView; // if (hero.in_grave) continue if(SkillSet[this.base.s_uuid].hp > 0){ //buff加血 // let increase_hp=Math.floor(this.base.hp/(this.base.in_time/this.base.cd)) let increase_hp=Math.floor(this.base.hp) hero.add_hp(increase_hp) } if(SkillSet[this.base.s_uuid].apup > 0){ //buff加攻击 // let increase_atk=Math.floor(this.base.apup/(this.base.in_time/this.base.cd)) let increase_atk=Math.floor(this.base.apup) hero.add_ap(increase_atk) } if(SkillSet[this.base.s_uuid].shield > 0){ //buff护盾 hero.add_shield(this.base.shield) } if(SkillSet[this.base.s_uuid].mhp > 0){ //hp最大值 hero.add_hp_max(this.base.mhp) } } } }