/** * 碎碎冰落地后持续范围伤害 */ import { _decorator, Component, UITransform, v3, Vec3 } from 'cc'; import { IWeaponProperty } from '../BattleDataManager'; import { Monster } from '../Monster'; const { ccclass, property } = _decorator; @ccclass('SnowStormContinueSchedule') export class SnowStormContinueSchedule extends Component { _dt: number = 0; _weaponid: number = 0; _addBuffInterval: number = 1; _repeatCount: number = 1; curRepeatCount: number = 0; // _allDamage:number = 0; _damageRadius: number = 0; // _isCrit:boolean = false; centerPos: Vec3 = new Vec3(); // 中心点位置 private _startDelay: number = 0; start() { } update(deltaTime: number) { if (!gg.game.CurentBattle.canUpdateFrame()) return; const scaledDt = deltaTime * gg.game.CurentBattle.TimeScale; if (this._startDelay > 0) { this._startDelay -= scaledDt; return; } this._dt += scaledDt; if (this._dt >= this._addBuffInterval) { this._dt = 0 this.curRepeatCount++ const bombMonsters = gg.game.CurentBattle.MonsterSpawner.getMonstersInArea(this.node.worldPosition, this._damageRadius); for (let i = 0; i < bombMonsters.length; i++) { const monster = bombMonsters[i]; const monsterComp = monster.getComponent(Monster); monsterComp.attackByWeapon(this._weaponid) } if (this.curRepeatCount >= this._repeatCount) { this.destroyNode() } if (bombMonsters.length > 0) { gg.audio.playEffect({ name: '彩虹飞弹命中', path: 'sound/武器音效/' }); } } } destroyNode() { //移除当前脚本 this.removeSelf() gg.res.putNode(this.node) } atkToMonster(weaponId, centerPos, weaponProperty: IWeaponProperty) { // 进入后先等 1 秒再开始造成伤害(原本由 Monster.ts 的 setTimeout 实现) this._startDelay = 0; this._weaponid = weaponId this.centerPos = centerPos.clone() this._dt = 0 this._addBuffInterval = weaponProperty.damageInterval this._repeatCount = Math.floor(weaponProperty.weaponContinueTime / weaponProperty.damageInterval) // this._allDamage = weaponProperty.allAtk this._damageRadius = weaponProperty.explodeRadius // this._isCrit = weaponProperty.isCrit } removeSelf() { this.destroy() } onDestroy() { // console.log('SnowStormContinueSchedule组件已被移除'); } }