-
Notifications
You must be signed in to change notification settings - Fork 0
/
Turret.gd
45 lines (38 loc) · 938 Bytes
/
Turret.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
extends PathFollow2D
class_name Turret
var foobar
var target = null
var world = null
var active = false
func _ready():
#assert(foobar)
assert(target)
assert(world)
offset = randi()
if active:
$SpawnTimer.start()
$Tween.interpolate_property(self, "modulate", modulate, Color(modulate.r, modulate.g, modulate.b, 1.0), 4.0)
$Tween.start()
func _physics_process(delta):
offset += 1
$Top.look_at(target.global_position)
func spawn():
$Top/Sprite/Particles2D.emitting = true
$ChargeUpTimer.start()
func _spawn():
var foo = foobar.instance()
foo.target = target
foo.global_position = global_position
world.add_child(foo)
func destroy():
$ChargeUpTimer.stop()
$SpawnTimer.stop()
queue_free()
func set_active(val):
active = val
if active:
$SpawnTimer.start()
else:
$Tween.interpolate_property(self, 'modulate', modulate, Color(modulate.r, modulate.g, modulate.b, 0.0), 4.0)
$Tween.start()
$SpawnTimer.stop()