You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.9 KiB
56 lines
1.9 KiB
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组件已被移除');
|
|
}
|
|
}
|
|
|
|
|
|
|