import { SoundManager } from "../component/SoundManager"; import { GlobalEvent, SoundName } from "../Global"; import { getGlobalNode, ObjType } from "../kernel/battle/BattleConst"; import { BigBombBlockData } from "../kernel/battle/map/BigBombBlockData"; import { MapView } from "../kernel/battle/map/MapView"; import RectBlockView from "./RectBlockView"; const { ccclass, property } = cc._decorator; @ccclass export default class BigBombView extends RectBlockView { private _spine: sp.Skeleton; init(owner: BigBombBlockData, mapView: MapView): void { super.init(owner, mapView); this._imgEffect.active = true; this._spine = this._imgEffect.getChildByName('sp').getComponent(sp.Skeleton); if (owner.type == ObjType.BIG_BOMB_33) { this._imgEffect.scale = 1.5; } } onBeginContact(contact: cc.PhysicsContact, selfCollider: cc.Collider, otherCollider: cc.Collider): void { if (this._spine.animation == 'boom') { return; //已触发了爆炸,屏蔽碰撞 } if (otherCollider.node.name == "ball") { this._spine.setCompleteListener(() => { this._spine.setAnimation(0, 'stay', true); }); if (this._spine.animation != 'hit') { this._spine.setAnimation(0, 'hit', false); } } super.onBeginContact(contact, selfCollider, otherCollider); } bomb() { this.setColliderEnable(false); this._spine.setAnimation(0, 'boom', false); this._spine.setCompleteListener(() => { (this._owner as BigBombBlockData).onBombFinish(); }) this.scheduleOnce(() => { SoundManager.ins.playEffect(SoundName.BOMB); getGlobalNode().emit(GlobalEvent.SHAKE, false); }, 1.5); getGlobalNode().emit(GlobalEvent.SHAKE, true); } protected onVisibleChange(): void { super.onVisibleChange(); this._img.active = false; this._imgEffect.active = this._visible; } }