Repository navigation
Expand file tree
/
Copy pathlevel_manager.gd
More file actions
94 lines (79 loc) · 3.44 KB
/
Copy pathlevel_manager.gd
File metadata and controls
94 lines (79 loc) · 3.44 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
extends Node
class_name LevelManager
## Emitted when level changes
signal level_changed(level_num: int, level_name: String)
@export var current_level: int = 1
var locomotive: Node2D
var ice_generator: Node2D
var passenger_ui: CanvasLayer
func _ready() -> void:
# Find dependencies in current scene
locomotive = get_node_or_null("../Train/Locomotive") as Node2D
ice_generator = get_node_or_null("../IceGenerator") as Node2D
passenger_ui = get_node_or_null("../PassengerUI") as CanvasLayer
load_level(current_level)
func _process(_delta: float) -> void:
# Level jump shortcut keys (Keys 1, 2, 3, 4, 5) for rapid testing
if Input.is_physical_key_pressed(KEY_1): load_level(1)
elif Input.is_physical_key_pressed(KEY_2): load_level(2)
elif Input.is_physical_key_pressed(KEY_3): load_level(3)
elif Input.is_physical_key_pressed(KEY_4): load_level(4)
elif Input.is_physical_key_pressed(KEY_5): load_level(5)
## Advance to the next level automatically upon completing a level
func advance_to_next_level() -> void:
if current_level < 5:
load_level(current_level + 1)
else:
load_level(1) # Loop back to tutorial upon completing Level 5
func load_level(level_num: int) -> void:
current_level = clampi(level_num, 1, 5)
var level_name := ""
if not locomotive:
push_error("No locomotive!")
if not locomotive.has_method("set_train_type"):
push_error("No set_train_type!")
if not ice_generator:
ice_generator = get_node_or_null("../IceGenerator") as Node2D
match current_level:
1:
level_name = "Level 1: The Calm Fjord (Tutorial)"
if locomotive:
if locomotive.has_method("set_train_type"): locomotive.set_train_type(Locomotive.TrainType.VINTAGE_STEAM) # 0 = Vintage Steam
locomotive.bump_penalty_multiplier = 0.3 # 70% penalty discount for tutorial
if ice_generator:
ice_generator.thin_ice_chance = 0.05
ice_generator.water_gap_chance = 0.0
2:
level_name = "Level 2: Pine Forest Crossing"
if locomotive:
if locomotive.has_method("set_train_type"): locomotive.set_train_type(Locomotive.TrainType.X2000_SERIES) # 1 = X2000 Series
locomotive.bump_penalty_multiplier = 0.6 # 40% penalty discount for Level 2
if ice_generator:
ice_generator.thin_ice_chance = 0.20
ice_generator.water_gap_chance = 0.05
3:
level_name = "Level 3: Midnight Blizzard Pass"
if locomotive:
if locomotive.has_method("set_train_type"): locomotive.set_train_type(Locomotive.TrainType.X2000_SERIES) # 1 = X2000 Series
locomotive.bump_penalty_multiplier = 1.0 # Standard penalty
if ice_generator:
ice_generator.thin_ice_chance = 0.35
ice_generator.water_gap_chance = 0.10
4:
level_name = "Level 4: Fragile Bridge Crossing"
if locomotive:
if locomotive.has_method("set_train_type"): locomotive.set_train_type(Locomotive.TrainType.BULLET_TRAIN) # 2 = Bullet Train
locomotive.bump_penalty_multiplier = 1.3
if ice_generator:
ice_generator.thin_ice_chance = 0.45
ice_generator.water_gap_chance = 0.15
5:
level_name = "Level 5: The Dawn Dash (Final Run)"
if locomotive:
if locomotive.has_method("set_train_type"): locomotive.set_train_type(Locomotive.TrainType.BULLET_TRAIN) # 2 = Bullet Train
locomotive.bump_penalty_multiplier = 1.5
if ice_generator:
ice_generator.thin_ice_chance = 0.55
ice_generator.water_gap_chance = 0.20
level_changed.emit(current_level, level_name)
print("Loaded %s (Penalty Multiplier: %.1fx)" % [level_name, locomotive.bump_penalty_multiplier if locomotive else 1.0])