消消方块阵换皮表情
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.

72 lines
2.1 KiB

1 week ago
/**
*
*/
import { _decorator, Component, sp } from 'cc';
import { IBloodBagAddHpProperty } from '../../../game/ChapterPlayTypes';
import { MapObstacle } from '../MapObstacle';
import { MapGrid } from '../MapGrid';
import { Monster } from '../Monster';
const { ccclass, property } = _decorator;
@ccclass('SingleBloodBag')
export class SingleBloodBag extends Component {
_dt: number = 0
_dtInterval: number = 0
grid: MapGrid = null
/**血包加血属性 */
bloodBagAddHpInfo: IBloodBagAddHpProperty = 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.addBloodBagAddHpBuff()
}
if (this._dt >= this.bloodBagAddHpInfo.gateExistTime) {
this._dt = 0
this.isStartTime = false
this.grid.node.getComponent(MapObstacle).remove();
}
}
init(bloodBagAddHpInfo: IBloodBagAddHpProperty, grid: MapGrid) {
this.bloodBagAddHpInfo = bloodBagAddHpInfo
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 */
addBloodBagAddHpBuff() {
let accMonsters = gg.game.CurentBattle.MonsterSpawner.getMonstersInArea(this.node.worldPosition, 30);
accMonsters.forEach(monster => {
monster.getComponent(Monster).addHP(this.bloodBagAddHpInfo.addHpCoefficient, true);
});
}
}