import { _decorator, Component, Node, Vec3 } from 'cc'; import { Monster } from '../Monster'; const { ccclass } = _decorator; /** * 持续伤害:到达目标后以间隔在半径内结算。 * 每跳与「碰撞命中」一致走 Monster.attackByWeapon,从而带上控制、冰棍减速、跳跳糖感电、 * specialSkillInfo 与 specialSkillAddBuff(减速、燃烧、眩晕等)及扣血。 */ @ccclass('SustainSchedule') export class SustainSchedule extends Component { _dt: number = 0; _weaponid: number = 0; /** 预留:与 Cola 等区域脚本一致时可传伤害倍率;直线持续在 SkillBase 侧传 1(allAtk 已含表内倍率) */ _damageTimes: number = 1; _addBuffInterval: number = 1; _repeatCount: number = 1; _bombPos: Vec3 = null; _damageRadius: number = 0; curRepeatCount: number = 0; _buttleNode: Node = null; _continueTime: number = 0; _continueTimeDt: number = 0; /** 发射方块的俄罗斯方块等级,参与 getWeaponAddProperty */ _tetriLevel: number = 1; update(deltaTime: number): void { const battle = gg.game?.CurentBattle; if (!battle?.canUpdateFrame?.()) return; this._dt += deltaTime * battle.TimeScale; this._continueTimeDt += deltaTime * battle.TimeScale; if (this._continueTimeDt >= this._continueTime) { this.removeSelf(); return; } if (this._dt < this._addBuffInterval) return; this._dt = 0; this.curRepeatCount++; const bombMonsters = battle.MonsterSpawner.getMonstersInArea(this.node.worldPosition, this._damageRadius); const bullet = this._buttleNode?.isValid ? this._buttleNode : undefined; for (let i = 0; i < bombMonsters.length; i++) { const monster = bombMonsters[i]; const monsterComp = monster.getComponent(Monster); if (!monsterComp || monsterComp.IsDead) continue; monsterComp.attackByWeapon(this._weaponid, bullet, this._tetriLevel); } } resetSustainAreaEffe( bombPos: Vec3, damageRadius: number, damageTimes: number, weaponid: number, damageInterval: number, repeatCount: number, continueT: number, buttleNode: Node, tetriLevel: number = 1, ): void { this._dt = 0; this._continueTimeDt = 0; this.curRepeatCount = 0; this._addBuffInterval = Math.max(0.05, damageInterval); this._repeatCount = Math.max(1, repeatCount); this._weaponid = weaponid; this._damageTimes = damageTimes; this._bombPos = bombPos; this._damageRadius = damageRadius; this._buttleNode = buttleNode; this._continueTime = Math.max(this._addBuffInterval, continueT); this._tetriLevel = tetriLevel > 0 ? tetriLevel : 1; } removeSelf(): void { const n = this._buttleNode; if (n?.isValid) { const sk = n.getComponent('Skill') as { removeBullet?: () => void } | null; sk?.removeBullet?.(); } if (this.isValid) { this.destroy(); } } onDestroy(): void { // noop } }