Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scene loader for the map #93

Merged
merged 42 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
ec18f22
Add a boolean to check if the player can move on the map
Turtyo Apr 10, 2024
71fda48
Add on_event_started/ended functions
Turtyo Apr 10, 2024
95065ad
Add the loader for the events
Turtyo Apr 11, 2024
b2eeea3
Add functions to handle start and end of events
Turtyo Apr 11, 2024
b1e30f8
Add comment to know where to put the loading of the next scene on the…
Turtyo Apr 11, 2024
b06541c
Remove SceneController as everything is done by the SceneManager
Turtyo Apr 13, 2024
92fe141
Rename CombatResult in EventResult
Turtyo Apr 13, 2024
1468346
Change on_event_end signal to on_event and on_defeat
Turtyo Apr 15, 2024
4ed8649
Refactor a part of code, add a switch_scene boolean useful for tests
Turtyo Apr 15, 2024
8d87eea
Change the goto_scene_map function
Turtyo Apr 15, 2024
e5945e4
Write functions for the Events
Turtyo Apr 15, 2024
84b02a9
Export the enemy manager to be able to write groups of enemies to loa…
Turtyo Apr 15, 2024
0d625bd
Some doc for the player position
Turtyo Apr 15, 2024
47ff3c3
Add basic test scenes for the different events
Turtyo Apr 15, 2024
8a345b2
Merge branch 'main' into 87-map-loader
Turtyo Apr 15, 2024
33f5827
Trigger the on_event_ended when the on_event_win signal is emitted
Turtyo Apr 16, 2024
95261bd
Fix tests not working by disconnecting functions from signals
Turtyo Apr 16, 2024
4fc792b
Merge branch 'main' into 87-map-loader
Turtyo Apr 18, 2024
e00d5be
Little indentation problem
Turtyo Apr 18, 2024
5556e4a
Make the map and deck button in a separate scene to be used as overlay
Turtyo Apr 19, 2024
64ee362
Update the Map and Card UI to display for the parent of the parent
Turtyo Apr 19, 2024
f8ec088
Update scenes
Turtyo Apr 19, 2024
178824f
Fix Random event not instantiating other events
Turtyo Apr 19, 2024
0be3f62
Remove the need to add the DEBUG_VAR to a list at the end
Turtyo Apr 19, 2024
b6b9628
Change the first scene loaded after the main menu to be the map
Turtyo Apr 19, 2024
726e6ad
Add a skip button for placeholder scenes
Turtyo Apr 19, 2024
04c01ee
Scene manager loops while the actual event is Random
Turtyo Apr 21, 2024
98941b7
Add comments and doc
Turtyo Apr 21, 2024
33931cf
Merge branch 'main' into 87-map-loader
Turtyo Apr 22, 2024
137beeb
Main menu as main scene
Turtyo Apr 23, 2024
476cd5f
Add an event dialogue
Turtyo Apr 23, 2024
04c0010
Add information to event dialogue to properly load the dialogue
Turtyo Apr 25, 2024
b87316f
Add overlay to dialogue scene
Turtyo Apr 25, 2024
20a1e55
Change the dialogue so it resumes to normal flow after jump, finish b…
Turtyo Apr 25, 2024
1b5487e
Remove unneeded code to always show dialogue scene
Turtyo Apr 25, 2024
e0408db
Update EventRandom so that EventDialogue can be a possible outcome
Turtyo Apr 25, 2024
56b1e0d
Merge branch 'main' into 87-map-loader
Turtyo Apr 25, 2024
7f6b87f
Fix showing deck crashing game when not in combat
Turtyo Apr 28, 2024
9d6ddad
Update tests
Turtyo Apr 28, 2024
0d0aa88
Remove duplicate comment
Turtyo May 3, 2024
acafb99
Add a comment to explain the =>< syntax in dialogue files
Turtyo May 3, 2024
a2f397c
Change defeat condition to use <= 0 instead of == 0
Turtyo May 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions #Scenes/Events/heal/0.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[gd_scene load_steps=3 format=3 uid="uid://lsl3jisfwkv3"]

[ext_resource type="PackedScene" uid="uid://bam77cwf4emyr" path="res://#Scenes/TopBarOverlay.tscn" id="1_cp1mw"]
[ext_resource type="Script" path="res://#Scenes/Events/skipEventButton.gd" id="2_1m5v4"]

[node name="Control" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2

[node name="TextEdit" type="TextEdit" parent="."]
layout_mode = 0
offset_right = 1276.0
offset_bottom = 715.0
theme_override_font_sizes/font_size = 100
placeholder_text = "This is a placeholder
heal event"

[node name="TopBarOverlay" parent="." instance=ExtResource("1_cp1mw")]
layout_mode = 1

[node name="SkipEventButton" type="Button" parent="."]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -280.0
offset_top = -220.0
offset_right = -80.0
offset_bottom = -140.0
grow_horizontal = 0
grow_vertical = 0
theme_override_font_sizes/font_size = 26
text = "Skip this event"
script = ExtResource("2_1m5v4")

[connection signal="pressed" from="SkipEventButton" to="SkipEventButton" method="_on_pressed"]
178 changes: 178 additions & 0 deletions #Scenes/Events/mob/0.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
[gd_scene load_steps=15 format=3 uid="uid://sg1wi7uqvv25"]

[ext_resource type="Script" path="res://#Scenes/SceneScripts/TestingScene.gd" id="1_nmgwp"]
[ext_resource type="PackedScene" uid="uid://bcpmrmofcilbn" path="res://Core/Battler.tscn" id="2_e6pjn"]
[ext_resource type="Script" path="res://Managers/MapManager.gd" id="3_fnmf8"]
[ext_resource type="PackedScene" uid="uid://clmg3l3n28x38" path="res://Entity/Player/Player.tscn" id="4_ss8ob"]
[ext_resource type="Script" path="res://#Scenes/SceneScripts/TestingScene_UIcontrol.gd" id="5_8ejph"]
[ext_resource type="PackedScene" uid="uid://dpjfy4pv0vxst" path="res://Cards/CardContainer.tscn" id="6_dwemq"]
[ext_resource type="Script" path="res://UI/EndTurnButton.gd" id="7_sxid7"]
[ext_resource type="Texture2D" uid="uid://bl5v3bgnntoc5" path="res://Art/Card_layout/energy_count.png" id="8_tfcxf"]
[ext_resource type="Script" path="res://UI/EnergyLabel.gd" id="9_nw86y"]
[ext_resource type="Texture2D" uid="uid://caemucaya30wh" path="res://Art/Card_layout/draw_pile.png" id="10_ebsh6"]
[ext_resource type="Script" path="res://UI/DrawPileUISetter.gd" id="11_l52d7"]
[ext_resource type="Texture2D" uid="uid://d4muqvs3etnr8" path="res://Art/Card_layout/discard_pile.png" id="12_0nlrw"]
[ext_resource type="Script" path="res://UI/DiscardPileUISetter.gd" id="13_8nsar"]
[ext_resource type="PackedScene" uid="uid://bam77cwf4emyr" path="res://#Scenes/TopBarOverlay.tscn" id="14_os5i4"]

[node name="TestingScene" type="Node2D"]
script = ExtResource("1_nmgwp")
metadata/_edit_vertical_guides_ = [1216.0]

[node name="Battler" parent="." instance=ExtResource("2_e6pjn")]

[node name="TestMap" type="Node2D" parent="."]
script = ExtResource("3_fnmf8")

[node name="Player" parent="." instance=ExtResource("4_ss8ob")]
position = Vector2(595, 284)

[node name="CanvasLayer" type="CanvasLayer" parent="."]

[node name="UIControl" type="Control" parent="CanvasLayer"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 2
script = ExtResource("5_8ejph")

[node name="CardContainer" parent="CanvasLayer/UIControl" node_paths=PackedStringArray("draw_pile_ui", "discard_pile_ui") instance=ExtResource("6_dwemq")]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 0
starting_hand_size = 10
max_hand_width = 900.0
min_card_separation = 90.0
max_card_separation = 120.0
hover_offset_max = 100.0
max_rotation = 40.0
draw_pile_ui = NodePath("../DrawPile")
discard_pile_ui = NodePath("../DiscardPile")
play_at_height = 500.0

[node name="EndTurnButton" type="Button" parent="CanvasLayer/UIControl"]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -145.0
offset_top = -141.0
offset_right = -35.0
offset_bottom = -109.0
grow_horizontal = 0
grow_vertical = 0
text = "end turn"
script = ExtResource("7_sxid7")

[node name="TextureRect" type="TextureRect" parent="CanvasLayer/UIControl"]
layout_mode = 1
anchors_preset = -1
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = 17.0
offset_top = -159.0
offset_right = 257.0
offset_bottom = 32.0
scale = Vector2(0.38, 0.38)
texture = ExtResource("8_tfcxf")

[node name="EnergyLabel" type="Label" parent="CanvasLayer/UIControl/TextureRect"]
layout_mode = 0
offset_left = 82.1705
offset_top = 72.8682
offset_right = 92.1705
offset_bottom = 95.8682
scale = Vector2(3.93058, 3.1094)
text = "0"
horizontal_alignment = 1
vertical_alignment = 1
script = ExtResource("9_nw86y")

[node name="DrawPile" type="TextureButton" parent="CanvasLayer/UIControl" node_paths=PackedStringArray("pile_count_label")]
layout_mode = 1
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_left = 30.0
offset_top = -69.0
offset_right = 70.0
offset_bottom = -29.0
grow_vertical = 0
texture_normal = ExtResource("10_ebsh6")
texture_pressed = ExtResource("10_ebsh6")
texture_hover = ExtResource("10_ebsh6")
texture_disabled = ExtResource("10_ebsh6")
texture_focused = ExtResource("10_ebsh6")
stretch_mode = 0
script = ExtResource("11_l52d7")
pile_count_label = NodePath("DrawPileCount")

[node name="DrawPileCount" type="Label" parent="CanvasLayer/UIControl/DrawPile"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
text = "0"
horizontal_alignment = 1
vertical_alignment = 1

[node name="DiscardPile" type="TextureButton" parent="CanvasLayer/UIControl" node_paths=PackedStringArray("pile_count_label")]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -64.0
offset_top = -72.0
offset_right = -24.0
offset_bottom = -32.0
grow_horizontal = 0
grow_vertical = 0
texture_normal = ExtResource("12_0nlrw")
texture_pressed = ExtResource("12_0nlrw")
texture_hover = ExtResource("12_0nlrw")
texture_disabled = ExtResource("12_0nlrw")
texture_focused = ExtResource("12_0nlrw")
stretch_mode = 0
script = ExtResource("13_8nsar")
pile_count_label = NodePath("DrawPileCount")

[node name="DrawPileCount" type="Label" parent="CanvasLayer/UIControl/DiscardPile"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
text = "0"
horizontal_alignment = 1
vertical_alignment = 1

[node name="back_to_main_menu" type="Button" parent="CanvasLayer/UIControl"]
layout_mode = 0
offset_left = 29.0
offset_top = 22.0
offset_right = 148.0
offset_bottom = 86.0
theme_override_font_sizes/font_size = 20
text = "Go back to
main menu"

[node name="TopBarOverlay" parent="CanvasLayer/UIControl" instance=ExtResource("14_os5i4")]
layout_mode = 1

[connection signal="pressed" from="CanvasLayer/UIControl/EndTurnButton" to="CanvasLayer/UIControl/EndTurnButton" method="_on_pressed"]
[connection signal="pressed" from="CanvasLayer/UIControl/back_to_main_menu" to="CanvasLayer/UIControl" method="_on_back_to_main_menu_pressed"]
42 changes: 42 additions & 0 deletions #Scenes/Events/shop/0.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[gd_scene load_steps=3 format=3 uid="uid://b8hbst1klk5ng"]

[ext_resource type="PackedScene" uid="uid://bam77cwf4emyr" path="res://#Scenes/TopBarOverlay.tscn" id="1_7gwvp"]
[ext_resource type="Script" path="res://#Scenes/Events/skipEventButton.gd" id="2_owx5q"]

[node name="Control" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2

[node name="TextEdit" type="TextEdit" parent="."]
layout_mode = 0
offset_right = 1276.0
offset_bottom = 715.0
theme_override_font_sizes/font_size = 100
placeholder_text = "This is a placeholder
shop event"

[node name="TopBarOverlay" parent="." instance=ExtResource("1_7gwvp")]
layout_mode = 1

[node name="SkipEventButton" type="Button" parent="."]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -280.0
offset_top = -220.0
offset_right = -80.0
offset_bottom = -140.0
grow_horizontal = 0
grow_vertical = 0
theme_override_font_sizes/font_size = 26
text = "Skip this event"
script = ExtResource("2_owx5q")

[connection signal="pressed" from="SkipEventButton" to="SkipEventButton" method="_on_pressed"]
11 changes: 11 additions & 0 deletions #Scenes/Events/skipEventButton.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extends Button
## Code for the button that allows the player to skip the event in placeholder scenes

## Enable / Disable the button based on the debug variable DEBUG_SKIP_EVENT
func _ready() -> void:
self.disabled = not DebugVar.DEBUG_SKIP_EVENT


## Activate the event ending function when the button is pressed
func _on_pressed() -> void:
PlayerManager.player_room.room_event.on_event_ended()
4 changes: 3 additions & 1 deletion #Scenes/MapUI.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[gd_scene load_steps=4 format=3 uid="uid://ki060lfrgty4"]
[gd_scene load_steps=5 format=3 uid="uid://ki060lfrgty4"]

[ext_resource type="Script" path="res://UI/MapUI.gd" id="1_enf2f"]
[ext_resource type="Script" path="res://addons/SmoothScroll/SmoothScrollContainer.gd" id="2_2gata"]
[ext_resource type="Texture2D" uid="uid://c73bts0oimblj" path="res://Art/Map/room_icon_with_player.png" id="2_rl2ub"]
[ext_resource type="Script" path="res://#Scenes/mapReturnButton.gd" id="4_pgiix"]

[node name="MapUi" type="Control" node_paths=PackedStringArray("color_rect", "scroll_container", "room_container", "room_addition_node", "torch_confirmation_dialog", "cant_set_torch_dialog")]
layout_mode = 3
Expand Down Expand Up @@ -71,6 +72,7 @@ offset_top = 550.0
offset_right = 65.0
offset_bottom = 581.0
text = "Return"
script = ExtResource("4_pgiix")

[node name="TorchPlacementConfirmationDialog2" type="ConfirmationDialog" parent="."]
title = ""
Expand Down
12 changes: 9 additions & 3 deletions #Scenes/SceneScripts/MainMenu.gd
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
extends Control
## Control the flow from the main menu



## What happens when the start button is pressed
func _on_start_pressed() -> void:
SceneManager.goto_scene("res://#Scenes/TestingScene.tscn")
if not PlayerManager.is_player_initial_position_set:
SceneManager.goto_scene("res://#Scenes/MapUI.tscn")
else:
# TODO : load the last scene the player was in
pass


## Scene to be loaded when option button is pressed
func _on_options_pressed() -> void:
SceneManager.goto_scene("res://#Scenes/OptionsMenu.tscn")


## Kill the game when the quit button is pressed
func _on_quit_pressed() -> void:
get_tree().quit()
39 changes: 3 additions & 36 deletions #Scenes/TestingScene.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=18 format=3 uid="uid://b60uabg68ra1l"]
[gd_scene load_steps=15 format=3 uid="uid://b60uabg68ra1l"]

[ext_resource type="Script" path="res://#Scenes/SceneScripts/TestingScene.gd" id="1_ji0t8"]
[ext_resource type="Script" path="res://Managers/MapManager.gd" id="2_50npk"]
Expand All @@ -11,12 +11,9 @@
[ext_resource type="Texture2D" uid="uid://caemucaya30wh" path="res://Art/Card_layout/draw_pile.png" id="11_pw70x"]
[ext_resource type="Texture2D" uid="uid://d4muqvs3etnr8" path="res://Art/Card_layout/discard_pile.png" id="12_kxw48"]
[ext_resource type="Script" path="res://UI/EndTurnButton.gd" id="14_dpe64"]
[ext_resource type="PackedScene" uid="uid://bam77cwf4emyr" path="res://#Scenes/TopBarOverlay.tscn" id="14_e54tj"]
[ext_resource type="Script" path="res://UI/EnergyLabel.gd" id="14_nckre"]
[ext_resource type="Texture2D" uid="uid://hqkt8t1v2f5h" path="res://Art/Card_layout/deck_pile.png" id="18_b54hn"]
[ext_resource type="Texture2D" uid="uid://bl5v3bgnntoc5" path="res://Art/Card_layout/energy_count.png" id="19_spyxg"]
[ext_resource type="Script" path="res://UI/DeckPileUISetter.gd" id="19_ucc6f"]
[ext_resource type="Texture2D" uid="uid://cjlatwiw7r80d" path="res://Art/Map/icon.png" id="20_tiho6"]
[ext_resource type="Script" path="res://UI/MapButton.gd" id="22_druf4"]

[node name="TestingScene" type="Node2D"]
script = ExtResource("1_ji0t8")
Expand Down Expand Up @@ -164,38 +161,8 @@ text = "0"
horizontal_alignment = 1
vertical_alignment = 1

[node name="DeckPile" type="TextureButton" parent="CanvasLayer/UIControl"]
[node name="TopBarOverlay" parent="CanvasLayer/UIControl" instance=ExtResource("14_e54tj")]
layout_mode = 1
anchors_preset = -1
anchor_left = 1.00078
anchor_right = 1.00078
offset_left = -62.0
offset_top = 35.0
offset_right = -22.0
offset_bottom = 75.0
texture_normal = ExtResource("18_b54hn")
texture_pressed = ExtResource("18_b54hn")
texture_hover = ExtResource("18_b54hn")
texture_disabled = ExtResource("18_b54hn")
texture_focused = ExtResource("18_b54hn")
stretch_mode = 0
script = ExtResource("19_ucc6f")
metadata/_edit_use_anchors_ = true

[node name="MapIcon" type="TextureButton" parent="CanvasLayer/UIControl"]
layout_mode = 0
offset_left = 1174.0
offset_top = 31.0
offset_right = 1214.0
offset_bottom = 71.0
texture_normal = ExtResource("20_tiho6")
texture_pressed = ExtResource("20_tiho6")
texture_hover = ExtResource("20_tiho6")
texture_disabled = ExtResource("20_tiho6")
texture_focused = ExtResource("20_tiho6")
ignore_texture_size = true
stretch_mode = 0
script = ExtResource("22_druf4")

[node name="back_to_main_menu" type="Button" parent="CanvasLayer/UIControl"]
layout_mode = 0
Expand Down
Loading
Loading