diff --git a/assets/icons/fast-forward-active.png b/assets/icons/fast-forward-active.png new file mode 100644 index 0000000..7d518b2 Binary files /dev/null and b/assets/icons/fast-forward-active.png differ diff --git a/assets/icons/fast-forward-active.png.import b/assets/icons/fast-forward-active.png.import new file mode 100644 index 0000000..763294b --- /dev/null +++ b/assets/icons/fast-forward-active.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bvp2h27uot6em" +path="res://.godot/imported/fast-forward-active.png-d1a61c84aae4913cdafebb409a334385.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/icons/fast-forward-active.png" +dest_files=["res://.godot/imported/fast-forward-active.png-d1a61c84aae4913cdafebb409a334385.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/assets/icons/fast-forward.png b/assets/icons/fast-forward.png new file mode 100644 index 0000000..c0288aa Binary files /dev/null and b/assets/icons/fast-forward.png differ diff --git a/assets/icons/fast-forward.png.import b/assets/icons/fast-forward.png.import new file mode 100644 index 0000000..1cf7540 --- /dev/null +++ b/assets/icons/fast-forward.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bn8pc3vkskcny" +path="res://.godot/imported/fast-forward.png-c42cc7b642a148b0f7534c6ec8d4790f.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/icons/fast-forward.png" +dest_files=["res://.godot/imported/fast-forward.png-c42cc7b642a148b0f7534c6ec8d4790f.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/scenes/ui/game_stats.tscn b/scenes/ui/game_stats.tscn index 2b84bb8..9c78a1e 100644 --- a/scenes/ui/game_stats.tscn +++ b/scenes/ui/game_stats.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=5 format=3 uid="uid://cy88k4uxt1v37"] +[gd_scene load_steps=6 format=3 uid="uid://cy88k4uxt1v37"] [ext_resource type="Texture2D" uid="uid://d2d7ab8q2vik4" path="res://assets/icons/label_bg.png" id="1_1gxsd"] [ext_resource type="Script" path="res://scripts/ui/game_stats.gd" id="1_ui7x4"] [ext_resource type="Texture2D" uid="uid://derifasksdfub" path="res://assets/icons/pause.png" id="2_imq5h"] [ext_resource type="Texture2D" uid="uid://e8dmiy1xr5g3" path="res://assets/icons/health.png" id="3_r1i66"] +[ext_resource type="Texture2D" uid="uid://bn8pc3vkskcny" path="res://assets/icons/fast-forward.png" id="4_frnkw"] [node name="GameStats" type="Control"] layout_mode = 3 @@ -61,6 +62,31 @@ grow_vertical = 2 scale = Vector2(0.015, 0.015) texture_normal = ExtResource("2_imq5h") +[node name="FastForward" type="NinePatchRect" parent="."] +layout_mode = 0 +offset_left = 918.0 +offset_top = 9.0 +offset_right = 955.0 +offset_bottom = 44.0 +texture = ExtResource("1_1gxsd") + +[node name="FastForwardButton" type="TextureButton" parent="FastForward"] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -15.5 +offset_top = -15.5 +offset_right = 2032.5 +offset_bottom = 2032.5 +grow_horizontal = 2 +grow_vertical = 2 +scale = Vector2(0.015, 0.015) +texture_normal = ExtResource("4_frnkw") +stretch_mode = 5 + [node name="Health" type="NinePatchRect" parent="."] layout_mode = 1 anchors_preset = 4 @@ -107,3 +133,6 @@ texture = ExtResource("3_r1i66") [connection signal="mouse_entered" from="Pause/PauseButton" to="." method="_on_pause_button_hold"] [connection signal="mouse_exited" from="Pause/PauseButton" to="." method="_on_pause_button_release"] [connection signal="pressed" from="Pause/PauseButton" to="." method="_on_pause_button_pressed"] +[connection signal="mouse_entered" from="FastForward/FastForwardButton" to="." method="_on_fast_forward_button_hold"] +[connection signal="mouse_exited" from="FastForward/FastForwardButton" to="." method="_on_fast_forward_button_release"] +[connection signal="pressed" from="FastForward/FastForwardButton" to="." method="_on_fast_forward_button_pressed"] diff --git a/scripts/stages/1/game_manager.gd b/scripts/stages/1/game_manager.gd index cad6938..efa3b5c 100644 --- a/scripts/stages/1/game_manager.gd +++ b/scripts/stages/1/game_manager.gd @@ -21,6 +21,7 @@ func _ready(): # Connect to Signal $CanvasLayer/GameStats.connect("on_paused", on_game_paused) $CanvasLayer/PauseMenu.connect("on_resume", on_game_resume) + $CanvasLayer/GameStats.connect("on_fast_forward", on_game_fast_forward) $CanvasLayer/GameStats.set_resource(data['resource']) var bases = $Bases.get_children() for base in bases: @@ -45,6 +46,12 @@ func on_game_resume(): data['paused'] = !data['paused'] get_tree().paused = data['paused'] $CanvasLayer/PauseMenu.hide_menu() + +func on_game_fast_forward(): + if Engine.get_time_scale() == 1.0: + Engine.time_scale = 2.0 + else: + Engine.time_scale = 1.0 func on_tower_placement(pos, tower_placement_id): var tower_id = null diff --git a/scripts/stages/2/game_manager.gd b/scripts/stages/2/game_manager.gd index 16d7ae8..e6b2a56 100644 --- a/scripts/stages/2/game_manager.gd +++ b/scripts/stages/2/game_manager.gd @@ -20,6 +20,7 @@ func _ready(): # Connect to Signal $CanvasLayer/GameStats.connect("on_paused", on_game_paused) $CanvasLayer/PauseMenu.connect("on_resume", on_game_resume) + $CanvasLayer/GameStats.connect("on_fast_forward", on_game_fast_forward) $CanvasLayer/GameStats.set_resource(data['resource']) var bases = $Bases.get_children() for base in bases: @@ -44,6 +45,12 @@ func on_game_resume(): data['paused'] = !data['paused'] get_tree().paused = data['paused'] $CanvasLayer/PauseMenu.hide_menu() + +func on_game_fast_forward(): + if Engine.get_time_scale() == 1.0: + Engine.time_scale = 2.0 + else: + Engine.time_scale = 1.0 func on_tower_placement(pos, tower_placement_id): var tower_id = null diff --git a/scripts/stages/3/game_manager.gd b/scripts/stages/3/game_manager.gd index c5ce368..151bac2 100644 --- a/scripts/stages/3/game_manager.gd +++ b/scripts/stages/3/game_manager.gd @@ -20,6 +20,7 @@ func _ready(): # Connect to Signal $CanvasLayer/GameStats.connect("on_paused", on_game_paused) $CanvasLayer/PauseMenu.connect("on_resume", on_game_resume) + $CanvasLayer/GameStats.connect("on_fast_forward", on_game_fast_forward) $CanvasLayer/GameStats.set_resource(data['resource']) var bases = $Bases.get_children() for base in bases: @@ -44,6 +45,12 @@ func on_game_resume(): data['paused'] = !data['paused'] get_tree().paused = data['paused'] $CanvasLayer/PauseMenu.hide_menu() + +func on_game_fast_forward(): + if Engine.get_time_scale() == 1.0: + Engine.time_scale = 2.0 + else: + Engine.time_scale = 1.0 func on_tower_placement(pos, tower_placement_id): var tower_id = null diff --git a/scripts/stages/4/game_manager.gd b/scripts/stages/4/game_manager.gd index b8dd276..31db7bd 100644 --- a/scripts/stages/4/game_manager.gd +++ b/scripts/stages/4/game_manager.gd @@ -20,6 +20,7 @@ func _ready(): # Connect to Signal $CanvasLayer/GameStats.connect("on_paused", on_game_paused) $CanvasLayer/PauseMenu.connect("on_resume", on_game_resume) + $CanvasLayer/GameStats.connect("on_fast_forward", on_game_fast_forward) $CanvasLayer/GameStats.set_resource(data['resource']) var bases = $Bases.get_children() for base in bases: @@ -44,6 +45,12 @@ func on_game_resume(): data['paused'] = !data['paused'] get_tree().paused = data['paused'] $CanvasLayer/PauseMenu.hide_menu() + +func on_game_fast_forward(): + if Engine.get_time_scale() == 1.0: + Engine.time_scale = 2.0 + else: + Engine.time_scale = 1.0 func on_tower_placement(pos, tower_placement_id): var tower_id = null diff --git a/scripts/stages/5/game_manager.gd b/scripts/stages/5/game_manager.gd index 732d558..144d156 100644 --- a/scripts/stages/5/game_manager.gd +++ b/scripts/stages/5/game_manager.gd @@ -20,6 +20,7 @@ func _ready(): # Connect to Signal $CanvasLayer/GameStats.connect("on_paused", on_game_paused) $CanvasLayer/PauseMenu.connect("on_resume", on_game_resume) + $CanvasLayer/GameStats.connect("on_fast_forward", on_game_fast_forward) $CanvasLayer/GameStats.set_resource(data['resource']) var bases = $Bases.get_children() for base in bases: @@ -44,6 +45,12 @@ func on_game_resume(): data['paused'] = !data['paused'] get_tree().paused = data['paused'] $CanvasLayer/PauseMenu.hide_menu() + +func on_game_fast_forward(): + if Engine.get_time_scale() == 1.0: + Engine.time_scale = 2.0 + else: + Engine.time_scale = 1.0 func on_tower_placement(pos, tower_placement_id): var tower_id = null diff --git a/scripts/stages/6/game_manager.gd b/scripts/stages/6/game_manager.gd index 410e36b..f876df1 100644 --- a/scripts/stages/6/game_manager.gd +++ b/scripts/stages/6/game_manager.gd @@ -20,6 +20,7 @@ func _ready(): # Connect to Signal $CanvasLayer/GameStats.connect("on_paused", on_game_paused) $CanvasLayer/PauseMenu.connect("on_resume", on_game_resume) + $CanvasLayer/GameStats.connect("on_fast_forward", on_game_fast_forward) $CanvasLayer/GameStats.set_resource(data['resource']) var bases = $Bases.get_children() for base in bases: @@ -44,6 +45,12 @@ func on_game_resume(): data['paused'] = !data['paused'] get_tree().paused = data['paused'] $CanvasLayer/PauseMenu.hide_menu() + +func on_game_fast_forward(): + if Engine.get_time_scale() == 1.0: + Engine.time_scale = 2.0 + else: + Engine.time_scale = 1.0 func on_tower_placement(pos, tower_placement_id): var tower_id = null diff --git a/scripts/ui/game_stats.gd b/scripts/ui/game_stats.gd index 30e91e5..17d85db 100644 --- a/scripts/ui/game_stats.gd +++ b/scripts/ui/game_stats.gd @@ -1,6 +1,9 @@ extends Control signal on_paused() +signal on_fast_forward() + +var is_active: bool = false func set_resource(value): $Resources/Label.text = str(value) @@ -20,4 +23,20 @@ func _on_pause_button_hold(): $Pause/PauseButton.modulate = Color(0.615686, 0.615686, 0.615686, 1) func _on_pause_button_release(): - $Pause/PauseButton.modulate = Color(1, 1, 1, 1) \ No newline at end of file + $Pause/PauseButton.modulate = Color(1, 1, 1, 1) + +func _on_fast_forward_button_pressed(): + if is_active: + $FastForward/FastForwardButton.set_texture_normal(load("res://assets/icons/fast-forward.png")) + is_active = false + else: + $FastForward/FastForwardButton.set_texture_normal(load("res://assets/icons/fast-forward-active.png")) + is_active = true + + on_fast_forward.emit() + +func _on_fast_forward_button_hold(): + $FastForward/FastForwardButton.modulate = Color(0.615686, 0.615686, 0.615686, 1) + +func _on_fast_forward_button_release(): + $FastForward/FastForwardButton.modulate = Color(1, 1, 1, 1) \ No newline at end of file