BigBombView.ts
2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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;
}
}