diff options
Diffstat (limited to 'Archipelago/effects.gd')
-rw-r--r-- | Archipelago/effects.gd | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/Archipelago/effects.gd b/Archipelago/effects.gd new file mode 100644 index 0000000..7d7e0fe --- /dev/null +++ b/Archipelago/effects.gd | |||
@@ -0,0 +1,89 @@ | |||
1 | extends Node | ||
2 | |||
3 | var effect_running = false | ||
4 | var slowness_remaining = 0 | ||
5 | var iceland_remaining = 0 | ||
6 | |||
7 | var orig_env | ||
8 | var orig_walk | ||
9 | var orig_run | ||
10 | |||
11 | |||
12 | func _ready(): | ||
13 | orig_env = get_tree().get_root().get_node("Spatial/player/pivot/camera").environment | ||
14 | orig_walk = get_tree().get_root().get_node("Spatial/player").walk_speed | ||
15 | orig_run = get_tree().get_root().get_node("Spatial/player").run_speed | ||
16 | |||
17 | var label = Label.new() | ||
18 | label.set_name("label") | ||
19 | label.margin_right = 1920.0 - 20.0 | ||
20 | label.margin_top = 20.0 | ||
21 | label.align = Label.ALIGN_RIGHT | ||
22 | label.valign = Label.VALIGN_TOP | ||
23 | |||
24 | var dynamic_font = DynamicFont.new() | ||
25 | dynamic_font.font_data = load("res://fonts/Lingo.ttf") | ||
26 | dynamic_font.size = 36 | ||
27 | dynamic_font.outline_color = Color(0, 0, 0, 1) | ||
28 | dynamic_font.outline_size = 2 | ||
29 | label.add_font_override("font", dynamic_font) | ||
30 | |||
31 | add_child(label) | ||
32 | |||
33 | |||
34 | func trigger_slowness_trap(): | ||
35 | if slowness_remaining == 0: | ||
36 | var player = get_tree().get_root().get_node("Spatial/player") | ||
37 | player.walk_speed = orig_walk / 2.0 | ||
38 | player.run_speed = orig_run / 2.0 | ||
39 | |||
40 | slowness_remaining += 30 | ||
41 | |||
42 | if not effect_running: | ||
43 | _process_effects() | ||
44 | |||
45 | |||
46 | func trigger_iceland_trap(): | ||
47 | if iceland_remaining == 0: | ||
48 | get_tree().get_root().get_node("Spatial/player/pivot/camera").set_environment( | ||
49 | load("res://environments/level_iceland.tres") | ||
50 | ) | ||
51 | |||
52 | iceland_remaining += 30 | ||
53 | |||
54 | if not effect_running: | ||
55 | _process_effects() | ||
56 | |||
57 | |||
58 | func _process_effects(): | ||
59 | effect_running = true | ||
60 | |||
61 | while slowness_remaining > 0 or iceland_remaining > 0: | ||
62 | var text = "" | ||
63 | if slowness_remaining > 0: | ||
64 | text += "Slowness: %d seconds" % slowness_remaining | ||
65 | if iceland_remaining > 0: | ||
66 | if not text.empty(): | ||
67 | text += "\n" | ||
68 | text += "Iceland: %d seconds" % iceland_remaining | ||
69 | self.get_node("label").text = text | ||
70 | |||
71 | yield(get_tree().create_timer(1.0), "timeout") | ||
72 | |||
73 | if slowness_remaining > 0: | ||
74 | slowness_remaining -= 1 | ||
75 | |||
76 | if slowness_remaining == 0: | ||
77 | var player = get_tree().get_root().get_node("Spatial/player") | ||
78 | player.walk_speed = orig_walk | ||
79 | player.run_speed = orig_run | ||
80 | |||
81 | if iceland_remaining > 0: | ||
82 | iceland_remaining -= 1 | ||
83 | |||
84 | if iceland_remaining == 0: | ||
85 | get_tree().get_root().get_node("Spatial/player/pivot/camera").set_environment( | ||
86 | orig_env | ||
87 | ) | ||
88 | |||
89 | effect_running = false | ||