-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlayerManager.gd
53 lines (37 loc) · 987 Bytes
/
PlayerManager.gd
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
extends Node
signal rapid
signal life_lost
signal expansion
signal pause
signal restart
func spawnPlayer(path, spawn, speed):
var player_resource = load(path)
var player = player_resource.instance()
player.speed = speed
player.start = spawn
player.connect("rapid", self, "rapid")
player.connect("life_lost", self, "life_lost")
player.connect("expansion", self, "expansion")
player.connect("pause", self, "pause")
player.connect("restart", self, "restart")
player.connect("damage", self, "do_damage")
self.add_child(player)
func despawnPlayer():
for player in self.get_children():
self.remove_child(player)
func rapid():
emit_signal("rapid")
func life_lost():
emit_signal("life_lost")
func expansion(nb = 0):
emit_signal("expansion", nb)
func pause():
emit_signal("pause")
func restart():
emit_signal("restart")
func do_damage():
for player in self.get_children():
player.do_damage()
func stop():
for player in self.get_children():
player.stop()