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 pause_screen : Control = $PauseScreen
|
||||||
@onready var game_over_screen : Control = $GameOverScreen
|
@onready var game_over_screen : Control = $GameOverScreen
|
||||||
|
@onready var victory_screen : Control = $VictoryScreen
|
||||||
@onready var world_generator : WorldGenerator = $WorldGenerator
|
@onready var world_generator : WorldGenerator = $WorldGenerator
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
pause_screen.hide()
|
pause_screen.hide()
|
||||||
|
victory_screen.hide()
|
||||||
game_over_screen.hide()
|
game_over_screen.hide()
|
||||||
|
|
||||||
start_game(SaveManager.game_data)
|
start_game(SaveManager.game_data)
|
||||||
|
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
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()
|
pause_screen.show()
|
||||||
get_tree().paused = true
|
get_tree().paused = true
|
||||||
|
|
||||||
|
|
||||||
func start_game(game_data: GameData) -> void:
|
func start_game(game_data: GameData) -> void:
|
||||||
|
|
||||||
if not _fill_data(game_data):
|
if not _fill_data(game_data):
|
||||||
print("Can't process game data")
|
print("Can't process game data")
|
||||||
_show_main_menu()
|
_show_main_menu()
|
||||||
@@ -56,6 +58,10 @@ func _initialize_new_game() -> void:
|
|||||||
func _fill_data(game_data: GameData) -> bool:
|
func _fill_data(game_data: GameData) -> bool:
|
||||||
data = world_generator.generate(game_data.game_seed.hash())
|
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
|
if game_data.current_area_index >= data.areas.size(): return false
|
||||||
current_area = data.areas[game_data.current_area_index]
|
current_area = data.areas[game_data.current_area_index]
|
||||||
|
|
||||||
@@ -68,6 +74,22 @@ func _fill_data(game_data: GameData) -> bool:
|
|||||||
return true
|
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:
|
func _create_game_map() -> void:
|
||||||
if _current_area_map_scene != null: _current_area_map_scene.queue_free()
|
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:
|
func _on_passage_completion() -> void:
|
||||||
|
_current_passage_scene.queue_free()
|
||||||
var projectiles := get_tree().get_nodes_in_group("projectiles")
|
var projectiles := get_tree().get_nodes_in_group("projectiles")
|
||||||
for projectile in projectiles:
|
for projectile in projectiles:
|
||||||
projectile.queue_free()
|
projectile.queue_free()
|
||||||
|
|
||||||
current_sector = current_passage.next_sector
|
current_sector = current_passage.next_sector
|
||||||
_update_data_indexes()
|
if current_sector.next_passages.size() == 0:
|
||||||
_show_map()
|
_process_to_next_area()
|
||||||
|
else:
|
||||||
|
_update_data_indexes()
|
||||||
|
_show_map()
|
||||||
|
|
||||||
|
|
||||||
func _update_data_indexes() -> void:
|
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="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://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://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"]
|
[ext_resource type="PackedScene" uid="uid://ggf76ayl53bb" path="res://game/world/generators/world_generator.tscn" id="5_dxrkv"]
|
||||||
|
|
||||||
[node name="Game" type="Node2D"]
|
[node name="Game" type="Node2D"]
|
||||||
@@ -12,6 +13,12 @@ script = ExtResource("1_l1rk1")
|
|||||||
process_mode = 2
|
process_mode = 2
|
||||||
z_index = 100
|
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")]
|
[node name="GameOverScreen" parent="." instance=ExtResource("4_4fuuu")]
|
||||||
z_index = 100
|
z_index = 100
|
||||||
anchors_preset = 8
|
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="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="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"]
|
[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"]
|
[sub_resource type="Shortcut" id="Shortcut_s4s14"]
|
||||||
events = [SubResource("InputEventAction_g2smo")]
|
events = [SubResource("InputEventAction_g2smo")]
|
||||||
|
|
||||||
[node name="SeedSelection" type="Control"]
|
[node name="SeedSelectionMenu" type="Control"]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 15
|
anchors_preset = 15
|
||||||
anchor_right = 1.0
|
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