import { _decorator, Component, isValid, Node } from 'cc'; import { SpecialSkillAddBuffType } from '../BattleDataManager'; const { ccclass, property } = _decorator; type MonsterLike = { removeBuff: (t: any) => void }; @ccclass('BuffIceSchedule') export class BuffIceSchedule extends Component { _dt: number = 0; _interval: number = 1; _repeatCount: number = 1; 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._monsterComp?.removeBuff(SpecialSkillAddBuffType.reduceSpeed) this.removeSelf() } } } resetIceBuff(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 } removeSelf() { //this._monsterComp?.playWalk(); this.enabled = false; } }