add simple main menu and persistence of zone time
This commit is contained in:
parent
d1f24f3dd1
commit
db865e2ab9
@ -11,7 +11,7 @@ config_version=5
|
||||
[application]
|
||||
|
||||
config/name="Semi-Idle ARPG"
|
||||
run/main_scene="res://scenes/combatUIScene.tscn"
|
||||
run/main_scene="res://scenes/main_menu.tscn"
|
||||
config/features=PackedStringArray("4.3", "Forward Plus")
|
||||
config/icon="res://assets/icon.svg"
|
||||
|
||||
|
44
scenes/main_menu.tscn
Normal file
44
scenes/main_menu.tscn
Normal file
@ -0,0 +1,44 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://de7bjfpfgrnuv"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/main_menu.gd" id="1_2lfxk"]
|
||||
|
||||
[node name="MainMenu" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_2lfxk")
|
||||
|
||||
[node name="MenuButtons" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -68.5
|
||||
offset_top = -50.5
|
||||
offset_right = 68.5
|
||||
offset_bottom = 50.5
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="PlayButton" type="Button" parent="MenuButtons"]
|
||||
layout_mode = 2
|
||||
text = "Play
|
||||
"
|
||||
|
||||
[node name="TestButton" type="Button" parent="MenuButtons"]
|
||||
layout_mode = 2
|
||||
text = "Test
|
||||
"
|
||||
|
||||
[node name="ExitButton" type="Button" parent="MenuButtons"]
|
||||
layout_mode = 2
|
||||
text = "Exit"
|
||||
|
||||
[connection signal="pressed" from="MenuButtons/PlayButton" to="." method="_on_play_button_pressed"]
|
||||
[connection signal="pressed" from="MenuButtons/TestButton" to="." method="_on_test_button_pressed"]
|
||||
[connection signal="pressed" from="MenuButtons/ExitButton" to="." method="_on_exit_button_pressed"]
|
@ -60,10 +60,11 @@ func _update_player_health(change: int) -> void:
|
||||
if current_health <= 0:
|
||||
$PlayerHealthBar/PlayerHealthCurrent.text = str(0)
|
||||
$PlayerHealthBar.value = 0
|
||||
print("You died.")
|
||||
# TODO: change to scene transition after slowing for a couple seconds
|
||||
# Engine.time_scale = 0.0001
|
||||
print("You died.")
|
||||
get_tree().paused = true
|
||||
# get_tree().paused = true
|
||||
get_tree().change_scene_to_file("res://scenes/main_menu.tscn")
|
||||
elif current_health >= max_health:
|
||||
$PlayerHealthBar/PlayerHealthCurrent.text = str(max_health)
|
||||
$PlayerHealthBar.value = max_health
|
||||
|
@ -11,3 +11,5 @@ var max_health := constitution * 100
|
||||
var max_resource := 100
|
||||
var current_resource := max_resource
|
||||
var weapon_type: Globals.Weapon.WeaponType
|
||||
|
||||
var zone_duration := 0
|
||||
|
@ -10,9 +10,6 @@ var totalAreas := 0
|
||||
|
||||
var worldArea: WorldArea
|
||||
var currentAreaQuest: Quest
|
||||
var start_zone_time: float
|
||||
var start_area_time: float
|
||||
var current_zone_duration: float
|
||||
var current_area_duration: float
|
||||
|
||||
|
||||
@ -25,8 +22,7 @@ func _ready() -> void:
|
||||
SignalBus.quest_completed.connect(_on_quest_completed)
|
||||
|
||||
_create_area()
|
||||
start_zone_time = Time.get_unix_time_from_system()
|
||||
start_area_time = Time.get_unix_time_from_system()
|
||||
current_area_duration = 0
|
||||
|
||||
|
||||
# func _process(_delta: float) -> void:
|
||||
@ -50,7 +46,8 @@ func _on_button_test_pressed() -> void:
|
||||
|
||||
|
||||
func _on_button_exit_pressed() -> void:
|
||||
get_tree().quit()
|
||||
# get_tree().quit()
|
||||
get_tree().change_scene_to_file("res://scenes/main_menu.tscn")
|
||||
|
||||
|
||||
func _go_next_area() -> void:
|
||||
@ -68,7 +65,7 @@ func _go_next_area() -> void:
|
||||
# Globals.debug_print("gna new area created")
|
||||
# _continue_button_hide()
|
||||
Globals.fade_node(%UITop/ContinueButton, "out", 0.1)
|
||||
start_area_time = Time.get_unix_time_from_system()
|
||||
current_area_duration = 0
|
||||
canContinue = false
|
||||
|
||||
|
||||
@ -91,7 +88,7 @@ func _on_continue_button_pressed() -> void:
|
||||
func _on_clock_timer_timeout() -> void:
|
||||
var current_time = Time.get_unix_time_from_system()
|
||||
%SystemClock.text = Time.get_time_string_from_unix_time(current_time)
|
||||
current_zone_duration = current_time - start_zone_time
|
||||
%ZTVal.text = Globals.elapsed_time_format(Globals.elapsed_time(current_zone_duration))
|
||||
current_area_duration = current_time - start_area_time
|
||||
PlayerState.zone_duration += 1
|
||||
%ZTVal.text = Globals.elapsed_time_format(Globals.elapsed_time(PlayerState.zone_duration))
|
||||
current_area_duration += 1
|
||||
%ATVal.text = Globals.elapsed_time_format(Globals.elapsed_time(current_area_duration))
|
||||
|
13
scripts/main_menu.gd
Normal file
13
scripts/main_menu.gd
Normal file
@ -0,0 +1,13 @@
|
||||
extends Control
|
||||
|
||||
|
||||
func _on_play_button_pressed() -> void:
|
||||
get_tree().change_scene_to_file("res://scenes/combatUIScene.tscn")
|
||||
|
||||
|
||||
func _on_exit_button_pressed() -> void:
|
||||
get_tree().quit()
|
||||
|
||||
|
||||
func _on_test_button_pressed() -> void:
|
||||
pass # Replace with function body.
|
Loading…
Reference in New Issue
Block a user