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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
| class Group extends Phaser.GameObjects.Group
{
constructor(scene, x, y, key)
{
super(scene, x, y, key);
this.scene = scene;
if (this.scene)
{
this.scene.physics.world.enable(this);
this.scene.add.existing(this);
}
}
*[Symbol.iterator]()
{
if (this.getChildren())
{
for (let i = 0; i < this.getChildren().length; i++)
{
yield this.getChildren()[i];
}
}
}
update(time, delta)
{
for (let child of this)
{
if (child.update)
{
child.update(time, delta);
}
}
}
set(key=undefined, value=undefined, defaults=undefined)
{
if (value === undefined)
{
return defaults;
}
else
{
this[key] = value;
return this[key];
}
}
patch()
{
if (this.scene.ship)
{
this.scene.physics.add.collider(this.scene.ship, this.getChildren(), this.scene.ship.collideShipEnemy, null, this.scene.ship);
if (this.scene.ship.bullets)
{
this.scene.physics.add.collider(this.scene.ship.bullets, this.getChildren(), this.scene.ship.collideBulletEnemy, null, this.scene.ship);
}
for (let child of this)
{
this.scene.physics.add.collider(this.scene.ship, child, this.scene.ship.collideShipEnemy, null, this.scene.ship);
if (this.scene.ship.bullets && child.shootable)
{
this.scene.physics.add.collider(this.scene.ship.bullets, child, this.scene.ship.collideBulletEnemyBullet, null, this.scene.ship);
}
if (child.projectile)
{
this.scene.physics.add.collider(this.scene.ship, child.projectile, this.scene.ship.collideShipEnemy, null, this.scene.ship);
}
}
}
return this;
}
done()
{
return this.getChildren().length === 0;
}
getChildrenHead()
{
return this.getChildren()[this.getChildren().length - 1];
}
}
export default Group;
|