import { GlobalEvent } from "../Global"; import { getGlobalNode } from "../kernel/battle/BattleConst"; import { MapView } from "../kernel/battle/map/MapView"; import GlobalNode from "../kernel/GlobalNode"; import { BlcokSkillViewBase } from "./BlockSkillViewBase"; import BlockView from "./BlockView"; export class BlockSkillBombView extends BlcokSkillViewBase { private _spIdleNode: cc.Node; private _spBoomNode: cc.Node; constructor(owner: BlockView, mapView: MapView) { super(owner, mapView); this._spIdleNode = cc.instantiate(mapView.prefabCollection.getChildByName('skillSpine').getChildByName('game_bomb01')); this._spBoomNode = cc.instantiate(mapView.prefabCollection.getChildByName('skillSpine').getChildByName('game_boom01')); this.onPositionChange(this._owner.owner.pixelPos.x, this._owner.owner.pixelPos.y); this._spBoomNode.active = false; this._spIdleNode.active = true; mapView.effectLayer.addChild(this._spBoomNode); mapView.effectLayer.addChild(this._spIdleNode); this._spIdleNode.getComponent(sp.Skeleton).setAnimation(0, 'animation', true); } onPositionChange(x: number, y: number): void { this._spBoomNode.setPosition(x, y); this._spIdleNode.setPosition(x, y); } onDead(): void { super.onDead(); this._spIdleNode.destroy(); this._spBoomNode.active = true; this._spBoomNode.getComponent(sp.Skeleton).setCompleteListener(() => { this._spBoomNode.destroy(); }); this._spBoomNode.getComponent(sp.Skeleton).setAnimation(0, 'animation', false); //震屏 getGlobalNode().emit(GlobalEvent.SHAKE, true); getGlobalNode().getComponent(GlobalNode).scheduleOnce(() => { getGlobalNode().emit(GlobalEvent.SHAKE, false); }, 0.3); //0.5秒后关闭 } }