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.
61 lines
2.2 KiB
61 lines
2.2 KiB
|
1 week ago
|
import { _decorator, Component, isValid, Node } from 'cc';
|
||
|
|
import { BattleDataManager, SpecialSkillAddBuffType } from '../BattleDataManager';
|
||
|
|
const { ccclass, property } = _decorator;
|
||
|
|
type MonsterLike = { getAllBuff: () => any[]; subHP: (...args: any[]) => void; removeBuff: (t: any) => void };
|
||
|
|
|
||
|
|
@ccclass('BuffBurnSchedule')
|
||
|
|
export class BuffBurnSchedule extends Component {
|
||
|
|
_dt: number = 0;
|
||
|
|
_weaponid: number = 0;
|
||
|
|
_damageTimes: 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._monsterComp) this._monsterComp = this.node.getComponent('Monster') as unknown as MonsterLike;
|
||
|
|
if (this._monsterComp) {
|
||
|
|
const allBuff = this._monsterComp.getAllBuff()
|
||
|
|
const weaponPropertyData = BattleDataManager.getWeaponAddProperty(this._weaponid, allBuff)
|
||
|
|
this._monsterComp.subHP(this._weaponid, weaponPropertyData.allAtk * this._damageTimes, weaponPropertyData.isCrit, weaponPropertyData.addRateAtk)
|
||
|
|
if (this.curRepeatCount >= this._repeatCount) {
|
||
|
|
// 移除 buff + 禁用组件(复用),避免频繁 destroy() 造成 GC
|
||
|
|
this._monsterComp.removeBuff(SpecialSkillAddBuffType.burn)
|
||
|
|
this.removeSelf()
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
resetFireBuff(weaponid, damageTimes, interval, repeatCount) {
|
||
|
|
this.enabled = true;
|
||
|
|
this._monsterComp = this.node.getComponent('Monster') as unknown as MonsterLike;
|
||
|
|
this._dt = 0
|
||
|
|
this.curRepeatCount = 0;
|
||
|
|
this._weaponid = weaponid
|
||
|
|
this._damageTimes = damageTimes
|
||
|
|
this._interval = interval
|
||
|
|
this._repeatCount = repeatCount
|
||
|
|
}
|
||
|
|
removeSelf() {
|
||
|
|
this.enabled = false;
|
||
|
|
}
|
||
|
|
onDestroy() {
|
||
|
|
// console.log('SpecialSkillBuff组件已被移除');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|