Added victory screen
This commit is contained in:
+30
-4
@@ -18,24 +18,26 @@ var _current_area_map_scene : AreaMap
|
||||
|
||||
@onready var pause_screen : Control = $PauseScreen
|
||||
@onready var game_over_screen : Control = $GameOverScreen
|
||||
@onready var victory_screen : Control = $VictoryScreen
|
||||
@onready var world_generator : WorldGenerator = $WorldGenerator
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
pause_screen.hide()
|
||||
victory_screen.hide()
|
||||
game_over_screen.hide()
|
||||
|
||||
start_game(SaveManager.game_data)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("pause"):
|
||||
var is_game_over := victory_screen.visible or game_over_screen.visible
|
||||
if event.is_action_pressed("pause") and not is_game_over:
|
||||
pause_screen.show()
|
||||
get_tree().paused = true
|
||||
|
||||
|
||||
func start_game(game_data: GameData) -> void:
|
||||
|
||||
if not _fill_data(game_data):
|
||||
print("Can't process game data")
|
||||
_show_main_menu()
|
||||
@@ -56,6 +58,10 @@ func _initialize_new_game() -> void:
|
||||
func _fill_data(game_data: GameData) -> bool:
|
||||
data = world_generator.generate(game_data.game_seed.hash())
|
||||
|
||||
return _set_currents(game_data)
|
||||
|
||||
|
||||
func _set_currents(game_data: GameData) -> bool:
|
||||
if game_data.current_area_index >= data.areas.size(): return false
|
||||
current_area = data.areas[game_data.current_area_index]
|
||||
|
||||
@@ -68,6 +74,22 @@ func _fill_data(game_data: GameData) -> bool:
|
||||
return true
|
||||
|
||||
|
||||
func _process_to_next_area() -> void:
|
||||
SaveManager.game_data.current_area_index += 1
|
||||
SaveManager.game_data.current_stage_index = 0
|
||||
SaveManager.game_data.current_sector_index = 0
|
||||
|
||||
print(SaveManager.game_data.current_area_index)
|
||||
|
||||
if SaveManager.game_data.current_area_index >= data.areas.size():
|
||||
SaveManager.delete_game_data()
|
||||
victory_screen.show()
|
||||
else:
|
||||
SaveManager.save()
|
||||
_set_currents(SaveManager.game_data)
|
||||
_create_game_map()
|
||||
|
||||
|
||||
func _create_game_map() -> void:
|
||||
if _current_area_map_scene != null: _current_area_map_scene.queue_free()
|
||||
|
||||
@@ -121,13 +143,17 @@ func _on_passage_player_died() -> void:
|
||||
|
||||
|
||||
func _on_passage_completion() -> void:
|
||||
_current_passage_scene.queue_free()
|
||||
var projectiles := get_tree().get_nodes_in_group("projectiles")
|
||||
for projectile in projectiles:
|
||||
projectile.queue_free()
|
||||
|
||||
current_sector = current_passage.next_sector
|
||||
_update_data_indexes()
|
||||
_show_map()
|
||||
if current_sector.next_passages.size() == 0:
|
||||
_process_to_next_area()
|
||||
else:
|
||||
_update_data_indexes()
|
||||
_show_map()
|
||||
|
||||
|
||||
func _update_data_indexes() -> void:
|
||||
|
||||
+9
-1
@@ -1,8 +1,9 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://dl7m4rqyj8mck"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://dl7m4rqyj8mck"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://1wfu4iuddo25" path="res://game/game.gd" id="1_l1rk1"]
|
||||
[ext_resource type="PackedScene" uid="uid://d34nh3lc1gpb" path="res://menu/pause_screen.tscn" id="2_h7iqs"]
|
||||
[ext_resource type="PackedScene" uid="uid://duxm8n62j2qt6" path="res://menu/game_over_screen.tscn" id="4_4fuuu"]
|
||||
[ext_resource type="PackedScene" uid="uid://bdcs2ff85qjs4" path="res://menu/victory_screen.tscn" id="4_dxrkv"]
|
||||
[ext_resource type="PackedScene" uid="uid://ggf76ayl53bb" path="res://game/world/generators/world_generator.tscn" id="5_dxrkv"]
|
||||
|
||||
[node name="Game" type="Node2D"]
|
||||
@@ -12,6 +13,12 @@ script = ExtResource("1_l1rk1")
|
||||
process_mode = 2
|
||||
z_index = 100
|
||||
|
||||
[node name="VictoryScreen" parent="." instance=ExtResource("4_dxrkv")]
|
||||
offset_left = 320.0
|
||||
offset_top = 172.0
|
||||
offset_right = 320.0
|
||||
offset_bottom = 172.0
|
||||
|
||||
[node name="GameOverScreen" parent="." instance=ExtResource("4_4fuuu")]
|
||||
z_index = 100
|
||||
anchors_preset = 8
|
||||
@@ -28,4 +35,5 @@ offset_bottom = 172.0
|
||||
|
||||
[connection signal="continue_game" from="PauseScreen" to="." method="_on_pause_screen_continue_game"]
|
||||
[connection signal="show_main_menu" from="PauseScreen" to="." method="_show_main_menu"]
|
||||
[connection signal="show_main_menu" from="VictoryScreen" to="." method="_show_main_menu"]
|
||||
[connection signal="show_main_menu" from="GameOverScreen" to="." method="_show_main_menu"]
|
||||
|
||||
@@ -9,7 +9,7 @@ action = &"ui_cancel"
|
||||
[sub_resource type="Shortcut" id="Shortcut_s4s14"]
|
||||
events = [SubResource("InputEventAction_g2smo")]
|
||||
|
||||
[node name="SeedSelection" type="Control"]
|
||||
[node name="SeedSelectionMenu" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
extends Control
|
||||
|
||||
|
||||
signal show_main_menu
|
||||
|
||||
|
||||
@onready var main_menu_button : Button = $%MainMenuButton
|
||||
@onready var button_focus_timer : Timer = $ButtonFocusTimer
|
||||
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
main_menu_button.grab_focus()
|
||||
|
||||
|
||||
func _on_main_menu_button_pressed() -> void:
|
||||
show_main_menu.emit()
|
||||
|
||||
|
||||
func _on_visibility_changed() -> void:
|
||||
if visible and button_focus_timer:
|
||||
button_focus_timer.start()
|
||||
@@ -0,0 +1 @@
|
||||
uid://b0p1ewlw18ijg
|
||||
@@ -0,0 +1,45 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://bdcs2ff85qjs4"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b0p1ewlw18ijg" path="res://menu/victory_screen.gd" id="1_asigk"]
|
||||
[ext_resource type="Theme" uid="uid://dtnd3tqllufey" path="res://images/menu_button.tres" id="2_wb4d8"]
|
||||
|
||||
[node name="VictoryScreen" 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_asigk")
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="CenterContainer/VBoxContainer"]
|
||||
z_index = 100
|
||||
layout_mode = 2
|
||||
text = "Victory!"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="MainMenuButton" type="Button" parent="CenterContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
z_index = 100
|
||||
layout_mode = 2
|
||||
mouse_filter = 2
|
||||
theme = ExtResource("2_wb4d8")
|
||||
text = "Main Menu"
|
||||
|
||||
[node name="ButtonFocusTimer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
|
||||
[connection signal="pressed" from="CenterContainer/VBoxContainer/MainMenuButton" to="." method="_on_main_menu_button_pressed"]
|
||||
[connection signal="timeout" from="ButtonFocusTimer" to="." method="_on_timer_timeout"]
|
||||
Reference in New Issue
Block a user