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.
73 lines
2.2 KiB
73 lines
2.2 KiB
|
1 week ago
|
/**
|
||
|
|
* 激光武器持续攻击
|
||
|
|
*/
|
||
|
|
import { _decorator, Component, sp } from 'cc';
|
||
|
|
import { IAccelerateGateProperty } from '../../../game/ChapterPlayTypes';
|
||
|
|
import { Monster } from '../Monster';
|
||
|
|
import { MapGrid } from '../MapGrid';
|
||
|
|
import { MapObstacle } from '../MapObstacle';
|
||
|
|
const { ccclass, property } = _decorator;
|
||
|
|
|
||
|
|
@ccclass('SingleAccelerateGate')
|
||
|
|
export class SingleAccelerateGate extends Component {
|
||
|
|
|
||
|
|
grid: MapGrid = null
|
||
|
|
|
||
|
|
_dt: number = 0
|
||
|
|
_dtInterval: number = 0
|
||
|
|
|
||
|
|
/**加速门属性 */
|
||
|
|
accGateInfo: IAccelerateGateProperty = null
|
||
|
|
isStartTime: boolean = false
|
||
|
|
|
||
|
|
start() {
|
||
|
|
|
||
|
|
}
|
||
|
|
protected update(dt: number): void {
|
||
|
|
if (!gg.game.CurentBattle.canUpdateFrame()) return;
|
||
|
|
if (!this.isStartTime) {
|
||
|
|
return
|
||
|
|
}
|
||
|
|
const scaledDt = dt * gg.game.CurentBattle.TimeScale;
|
||
|
|
this._dt += scaledDt
|
||
|
|
this._dtInterval += scaledDt
|
||
|
|
if (this._dtInterval >= 0.5) {
|
||
|
|
this._dtInterval = 0
|
||
|
|
this.addAccelerateGateBuff()
|
||
|
|
}
|
||
|
|
if (this._dt >= this.accGateInfo.gateExistTime) {
|
||
|
|
this._dt = 0
|
||
|
|
this.isStartTime = false
|
||
|
|
this.grid.node.getComponent(MapObstacle).remove();
|
||
|
|
//BattleManager.Instance.obstaclePlacer.removeObs(this.node)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
init(accGateInfo: IAccelerateGateProperty,grid: MapGrid) {
|
||
|
|
this.accGateInfo = accGateInfo
|
||
|
|
this.grid = grid
|
||
|
|
let spine = this.node.getChildByName('anim')
|
||
|
|
spine.getComponent(sp.Skeleton).setAnimation(0, '石板出现', false)
|
||
|
|
this.scheduleOnce(() => {
|
||
|
|
spine.getComponent(sp.Skeleton).setAnimation(0, '石板待机', true)
|
||
|
|
this.isStartTime = true
|
||
|
|
}, 3)
|
||
|
|
}
|
||
|
|
|
||
|
|
protected onDisable(): void {
|
||
|
|
this.unscheduleAllCallbacks();
|
||
|
|
}
|
||
|
|
|
||
|
|
protected onDestroy(): void {
|
||
|
|
this.unscheduleAllCallbacks();
|
||
|
|
}
|
||
|
|
/** 添加加速门buff */
|
||
|
|
addAccelerateGateBuff() {
|
||
|
|
let accMonsters = gg.game.CurentBattle.MonsterSpawner.getMonstersInArea(this.node.worldPosition, 30);
|
||
|
|
accMonsters.forEach(monster => {
|
||
|
|
monster.getComponent(Monster).resetAccelerateBuff(this.accGateInfo.accelerateSpeed, this.accGateInfo.buffTime)
|
||
|
|
});
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|