From 8ef7cc250729bc62229bee4eaaec56d285ee2813 Mon Sep 17 00:00:00 2001 From: INoro Date: Sat, 10 Dec 2022 20:44:43 +0100 Subject: [PATCH] Leo - Train pickup function --- menu/main_menu.tscn | 13 ++++++++----- scripts/Train.gd | 12 ++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/menu/main_menu.tscn b/menu/main_menu.tscn index d285d37..0c6fa65 100644 --- a/menu/main_menu.tscn +++ b/menu/main_menu.tscn @@ -34,27 +34,27 @@ grow_horizontal = 2 grow_vertical = 2 [node name="Start" type="Button" parent="VBoxContainer"] -offset_right = 72.0 +offset_right = 87.0 offset_bottom = 31.0 text = "Start " [node name="Tutorial" type="Button" parent="VBoxContainer"] offset_top = 35.0 -offset_right = 72.0 +offset_right = 87.0 offset_bottom = 66.0 text = "Tutorial " [node name="Settings" type="Button" parent="VBoxContainer"] offset_top = 70.0 -offset_right = 72.0 +offset_right = 87.0 offset_bottom = 101.0 text = "Volume:" [node name="VolSlider" type="HSlider" parent="VBoxContainer"] offset_top = 105.0 -offset_right = 72.0 +offset_right = 87.0 offset_bottom = 121.0 min_value = -30.0 max_value = 0.0 @@ -62,11 +62,14 @@ script = ExtResource("2_h85ei") [node name="Quit" type="Button" parent="VBoxContainer"] offset_top = 125.0 -offset_right = 72.0 +offset_right = 87.0 offset_bottom = 156.0 text = "Quit" [node name="FullScreen" type="Button" parent="VBoxContainer"] +offset_top = 160.0 +offset_right = 87.0 +offset_bottom = 191.0 text = "Fullscreen" [connection signal="pressed" from="VBoxContainer/Start" to="." method="_on_start_pressed"] diff --git a/scripts/Train.gd b/scripts/Train.gd index c0228a5..d52c2d9 100644 --- a/scripts/Train.gd +++ b/scripts/Train.gd @@ -33,3 +33,15 @@ func is_dead(): game_over.emit() return true return false + +func on_pickup(type, amount): + for s in STORAGES: + if s.currentType == type: + if s.currentStashValue + amount <= s.maxStashValue: + s.currentStashValue += amount + else: + s.currentStashValue = s.maxStashValue + + return + +