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.
50 lines
1.5 KiB
50 lines
1.5 KiB
|
1 week ago
|
import { _decorator, Component, isValid, Node } from 'cc';
|
||
|
|
import { SpecialSkillAddBuffType } from '../BattleDataManager';
|
||
|
|
const { ccclass, property } = _decorator;
|
||
|
|
type MonsterLike = { removeBuff: (t: any) => void };
|
||
|
|
|
||
|
|
@ccclass('BuffControlSchedule')
|
||
|
|
export class BuffControlSchedule 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.removeSelf()
|
||
|
|
this._monsterComp?.removeBuff(SpecialSkillAddBuffType.control)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
resetControlBuff(interval, repeatCount) {
|
||
|
|
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.enabled = false;
|
||
|
|
}
|
||
|
|
onDestroy() {
|
||
|
|
// console.log('BuffControlSchedule组件已被移除');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|