import { _decorator, Component, isValid, Node } from 'cc'; import { SpecialSkillAddBuffType } from '../BattleDataManager'; const { ccclass, property } = _decorator; type MonsterLike = { removeBuff: (t: any) => void }; @ccclass('BuffAccelerateSchedule') export class BuffAccelerateSchedule extends Component { _dt: number = 0; _interval: number = 1; _repeatCount: number = 1; _spineNode: Node = null; curRepeatCount: number = 0; private _monsterComp: MonsterLike | null = null; start() { } update(deltaTime: number) { if (!gg.game.CurentBattle.canUpdateFrame()) return; this._dt += deltaTime * gg.game.CurentBattle.TimeScale; if (this._dt >= this._interval) { this._dt = 0 this.curRepeatCount++ if (this.curRepeatCount >= this._repeatCount) { //移除当前脚本 if (!this._monsterComp) this._monsterComp = this.node.getComponent('Monster') as unknown as MonsterLike; this.removeSelf() if (!gg.game.CurentBattle.IsOpenRedMoon) this._spineNode.active = false this._monsterComp?.removeBuff(SpecialSkillAddBuffType.accelerate) } } } resetAccelerateBuff(interval, repeatCount, spineNode) { this.enabled = true; this._monsterComp = this.node.getComponent('Monster') as unknown as MonsterLike; this.curRepeatCount = 0 this._dt = 0 this._interval = interval this._repeatCount = repeatCount this._spineNode = spineNode } removeSelf() { // if (this._spineNode && isValid(this._spineNode) && this._spineNode.active) { // gg.res.putNode(this._spineNode); // } this.enabled = false; } onDestroy() { // console.log('BuffIceSchedule组件已被移除'); } }