forked from ArnovanDoesburg/Asteroid-Assault
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbomb.ts
30 lines (24 loc) · 767 Bytes
/
bomb.ts
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
class Bomb extends GameObject implements Subject {
observers : Array<Observer>;
constructor() {
super(Math.floor((Math.random() * window.innerWidth) + 1),
Math.floor((Math.random() * window.innerHeight) + 1),
0, 'bomb');
this.observers = new Array<Observer>();
}
subscribe(o: Observer): void {
this.observers.push(o);
}
unsubscribe(o: Observer): void {
let i:number = this.observers.indexOf(o);
if(i != -1) {
this.observers.splice(i, 1);
}
}
notifyObs() {
AudioManager.playSound('./../sfx/sfx_bomb.wav');
for( var i = this.observers.length-1; i >= 0; i-- ) {
this.observers[i].notify();
}
}
}