about summary refs log tree commit diff stats
path: root/Archipelago/effects.gd
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2023-04-22 18:45:03 -0400
committerStar Rauchenberger <fefferburbia@gmail.com>2023-04-22 18:45:03 -0400
commit793564a44706b302921fae599f5cbe2fb8590e67 (patch)
tree48fd08034eda561dd5de50a735a8fe77462bd68f /Archipelago/effects.gd
parent7c0c676fedef3bbeb5dd04ded5a94fe8933822cf (diff)
downloadlingo-archipelago-793564a44706b302921fae599f5cbe2fb8590e67.tar.gz
lingo-archipelago-793564a44706b302921fae599f5cbe2fb8590e67.tar.bz2
lingo-archipelago-793564a44706b302921fae599f5cbe2fb8590e67.zip
Added traps
Diffstat (limited to 'Archipelago/effects.gd')
-rw-r--r--Archipelago/effects.gd89
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 @@
1extends Node
2
3var effect_running = false
4var slowness_remaining = 0
5var iceland_remaining = 0
6
7var orig_env
8var orig_walk
9var orig_run
10
11
12func _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
34func 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
46func 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
58func _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