Add FastForward feature

This commit is contained in:
Moe Poi ~ 2023-10-29 14:26:02 +07:00
parent 60d6960e9b
commit 9834279628
12 changed files with 160 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View file

@ -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

Binary file not shown.

After

Width:  |  Height:  |  Size: 6 KiB

View file

@ -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

View file

@ -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"]

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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)
$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)