-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwaypoint.gd
55 lines (43 loc) · 1.43 KB
/
waypoint.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
54
55
extends StaticBody2D
export(bool) var is_goal = false
export(bool) var play_sfx = true
export(bool) var spawn_abilities = false
var faded = false
const continue_button = preload("res://buttons/finish_stage_button.tscn")
const ability_button = preload("res://buttons/ability_button.tscn")
func _ready():
add_to_group("goal")
func _on_aggro_aggro(_entity):
# don't fade twice!
if not faded:
faded = true
if play_sfx:
$checkpoint_ding.play()
# non-goals fade out
if is_goal:
get_tree().call_group("goal", "goal")
else:
$collision_shape_2d.disabled = true
$tween.interpolate_property(self, "modulate", Color.white, Color(1,1,1,0), 0.3, Tween.TRANS_LINEAR, Tween.EASE_IN)
$tween.start()
yield(get_tree().create_timer(0.5), "timeout")
queue_free()
func triggers_aggro():
return true
func goal():
if is_goal:
var inst = continue_button.instance()
inst.global_position = $continue_button.global_position
get_parent().add_child(inst)
inst.global_position = $continue_button.global_position
# abilities
if spawn_abilities:
spawn_abilities = false
global.ability_budget += 1
var abilities : Array = global.get_random_abilites(2)
print(abilities)
for button_position in $ability_button_positions.get_children():
var ab_button = ability_button.instance()
ab_button.ability = abilities.pop_front()
add_child(ab_button)
ab_button.global_position = button_position.global_position