Demo: Link game to showcase and vice versa

This commit is contained in:
Serhii Snitsaruk 2024-02-04 23:07:13 +01:00
parent f54c86f9fc
commit dae96feeb9
8 changed files with 88 additions and 60 deletions

View File

@ -81,3 +81,7 @@ func _on_agent_death() -> void:
func _on_player_death() -> void: func _on_player_death() -> void:
await get_tree().create_timer(3.0).timeout await get_tree().create_timer(3.0).timeout
get_tree().reload_current_scene() get_tree().reload_current_scene()
func _on_switch_to_showcase_pressed() -> void:
get_tree().change_scene_to_file("res://demo/scenes/showcase.tscn")

View File

@ -1,39 +1,39 @@
[gd_scene load_steps=15 format=3 uid="uid://clyhgbpfpmtw7"] [gd_scene load_steps=15 format=3 uid="uid://clyhgbpfpmtw7"]
[ext_resource type="Script" path="res://demo/scenes/demo.gd" id="1_foif6"] [ext_resource type="Script" path="res://demo/scenes/game.gd" id="1_qw71e"]
[ext_resource type="PackedScene" uid="uid://bsig1usigbbuy" path="res://demo/scenes/arena.tscn" id="1_rab6h"] [ext_resource type="Theme" uid="uid://boqtjf88xcpu4" path="res://demo/assets/ui.theme" id="2_r21q3"]
[ext_resource type="Theme" uid="uid://boqtjf88xcpu4" path="res://demo/assets/ui.theme" id="2_e6mlj"] [ext_resource type="Texture2D" uid="uid://tyu0ua1ju38l" path="res://demo/assets/logo.png" id="3_g0us4"]
[ext_resource type="PackedScene" uid="uid://bpd1wmw2f7bvg" path="res://demo/props/gong.tscn" id="3_nbeay"] [ext_resource type="FontFile" uid="uid://d25vkmce7mhlt" path="res://demo/assets/fonts/knewave_regular.ttf" id="4_w0vii"]
[ext_resource type="Texture2D" uid="uid://tyu0ua1ju38l" path="res://demo/assets/logo.png" id="3_t7by8"] [ext_resource type="Script" path="res://demo/scenes/base/toggle_fullscreen.gd" id="5_m16ov"]
[ext_resource type="FontFile" uid="uid://d25vkmce7mhlt" path="res://demo/assets/fonts/knewave_regular.ttf" id="4_xx6j3"] [ext_resource type="Texture2D" uid="uid://dlw15foygohrk" path="res://demo/assets/hp_under.png" id="6_622dk"]
[ext_resource type="Script" path="res://demo/scenes/toggle_fullscreen.gd" id="5_2oy30"] [ext_resource type="Texture2D" uid="uid://cls8jtnu413o8" path="res://demo/assets/hp_over.png" id="7_430mt"]
[ext_resource type="PackedScene" uid="uid://d07ag5dcje13i" path="res://demo/agents/player/player.tscn" id="5_cmgoj"] [ext_resource type="Texture2D" uid="uid://hnwi23oef752" path="res://demo/assets/hp_bar.png" id="8_invih"]
[ext_resource type="Texture2D" uid="uid://dlw15foygohrk" path="res://demo/assets/hp_under.png" id="6_3dtym"] [ext_resource type="PackedScene" uid="uid://bsig1usigbbuy" path="res://demo/scenes/base/arena.tscn" id="9_k3uu1"]
[ext_resource type="Texture2D" uid="uid://cls8jtnu413o8" path="res://demo/assets/hp_over.png" id="7_3xolo"] [ext_resource type="PackedScene" uid="uid://bpd1wmw2f7bvg" path="res://demo/props/gong.tscn" id="10_tftjb"]
[ext_resource type="Texture2D" uid="uid://hnwi23oef752" path="res://demo/assets/hp_bar.png" id="8_ee1p0"] [ext_resource type="PackedScene" uid="uid://d07ag5dcje13i" path="res://demo/agents/player/player.tscn" id="11_bndob"]
[sub_resource type="LabelSettings" id="LabelSettings_628x3"] [sub_resource type="LabelSettings" id="LabelSettings_628x3"]
font = ExtResource("4_xx6j3") font = ExtResource("4_w0vii")
font_size = 36 font_size = 36
font_color = Color(1, 1, 0.239216, 1) font_color = Color(1, 1, 0.239216, 1)
outline_size = 20 outline_size = 20
outline_color = Color(0.211521, 0.23888, 0.290166, 1) outline_color = Color(0.211521, 0.23888, 0.290166, 1)
[sub_resource type="LabelSettings" id="LabelSettings_0r6iv"] [sub_resource type="LabelSettings" id="LabelSettings_0r6iv"]
font = ExtResource("4_xx6j3") font = ExtResource("4_w0vii")
font_size = 37 font_size = 37
outline_size = 15 outline_size = 15
outline_color = Color(0.211521, 0.23888, 0.290166, 1) outline_color = Color(0.211521, 0.23888, 0.290166, 1)
[sub_resource type="LabelSettings" id="LabelSettings_qvxvp"] [sub_resource type="LabelSettings" id="LabelSettings_qvxvp"]
font = ExtResource("4_xx6j3") font = ExtResource("4_w0vii")
font_size = 33 font_size = 33
outline_size = 11 outline_size = 11
outline_color = Color(0.258915, 0.234974, 0.191974, 1) outline_color = Color(0.258915, 0.234974, 0.191974, 1)
[node name="Demo" type="Node2D"] [node name="Demo" type="Node2D"]
y_sort_enabled = true y_sort_enabled = true
script = ExtResource("1_foif6") script = ExtResource("1_qw71e")
[node name="UI Layer" type="CanvasLayer" parent="."] [node name="UI Layer" type="CanvasLayer" parent="."]
@ -44,7 +44,7 @@ anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
theme = ExtResource("2_e6mlj") theme = ExtResource("2_r21q3")
[node name="Logo" type="TextureRect" parent="UI Layer/Control"] [node name="Logo" type="TextureRect" parent="UI Layer/Control"]
layout_mode = 1 layout_mode = 1
@ -59,7 +59,7 @@ offset_right = -1643.0
offset_bottom = -45.0 offset_bottom = -45.0
grow_horizontal = 0 grow_horizontal = 0
grow_vertical = 0 grow_vertical = 0
texture = ExtResource("3_t7by8") texture = ExtResource("3_g0us4")
[node name="Demo project" type="Label" parent="UI Layer/Control/Logo"] [node name="Demo project" type="Label" parent="UI Layer/Control/Logo"]
layout_mode = 1 layout_mode = 1
@ -79,22 +79,6 @@ label_settings = SubResource("LabelSettings_628x3")
horizontal_alignment = 2 horizontal_alignment = 2
vertical_alignment = 1 vertical_alignment = 1
[node name="ToggleFullscreen" type="Button" parent="UI Layer/Control"]
layout_mode = 1
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -214.0
offset_top = 30.0
offset_right = -31.0
offset_bottom = 75.0
grow_horizontal = 0
focus_mode = 0
theme_override_fonts/font = ExtResource("4_xx6j3")
theme_override_font_sizes/font_size = 22
text = "Toggle Fullscreen"
script = ExtResource("5_2oy30")
[node name="VBoxContainer" type="VBoxContainer" parent="UI Layer/Control"] [node name="VBoxContainer" type="VBoxContainer" parent="UI Layer/Control"]
layout_mode = 1 layout_mode = 1
anchors_preset = 3 anchors_preset = 3
@ -116,6 +100,29 @@ Attack ENTER or F
Dodge SPACE" Dodge SPACE"
label_settings = SubResource("LabelSettings_0r6iv") label_settings = SubResource("LabelSettings_0r6iv")
[node name="HBoxContainer" type="HBoxContainer" parent="UI Layer/Control"]
layout_mode = 0
offset_left = 1512.0
offset_top = 29.0
offset_right = 1912.0
offset_bottom = 74.0
[node name="ToggleFullscreen" type="Button" parent="UI Layer/Control/HBoxContainer"]
layout_mode = 2
focus_mode = 0
theme_override_fonts/font = ExtResource("4_w0vii")
theme_override_font_sizes/font_size = 22
text = "Toggle Fullscreen"
script = ExtResource("5_m16ov")
[node name="Switch to Showcase" type="Button" parent="UI Layer/Control/HBoxContainer"]
layout_mode = 2
focus_mode = 0
theme_override_fonts/font = ExtResource("4_w0vii")
theme_override_font_sizes/font_size = 22
text = "Switch to Showcase
"
[node name="HPBar" type="TextureProgressBar" parent="UI Layer/Control"] [node name="HPBar" type="TextureProgressBar" parent="UI Layer/Control"]
unique_name_in_owner = true unique_name_in_owner = true
layout_mode = 0 layout_mode = 0
@ -124,9 +131,9 @@ offset_top = 24.0
offset_right = 405.0 offset_right = 405.0
offset_bottom = 84.0 offset_bottom = 84.0
value = 100.0 value = 100.0
texture_under = ExtResource("6_3dtym") texture_under = ExtResource("6_622dk")
texture_over = ExtResource("7_3xolo") texture_over = ExtResource("7_430mt")
texture_progress = ExtResource("8_ee1p0") texture_progress = ExtResource("8_invih")
[node name="RoundCounter" type="Label" parent="UI Layer/Control"] [node name="RoundCounter" type="Label" parent="UI Layer/Control"]
unique_name_in_owner = true unique_name_in_owner = true
@ -138,12 +145,12 @@ offset_bottom = 81.0
text = "Round: 0/1" text = "Round: 0/1"
label_settings = SubResource("LabelSettings_qvxvp") label_settings = SubResource("LabelSettings_qvxvp")
[node name="Arena" parent="." instance=ExtResource("1_rab6h")] [node name="Arena" parent="." instance=ExtResource("9_k3uu1")]
[node name="Gong" parent="." instance=ExtResource("3_nbeay")] [node name="Gong" parent="." instance=ExtResource("10_tftjb")]
position = Vector2(923, -21) position = Vector2(923, -21)
[node name="Player" parent="." instance=ExtResource("5_cmgoj")] [node name="Player" parent="." instance=ExtResource("11_bndob")]
position = Vector2(843, 455) position = Vector2(843, 455)
[node name="Camera2D" type="Camera2D" parent="Player"] [node name="Camera2D" type="Camera2D" parent="Player"]
@ -187,4 +194,5 @@ position = Vector2(629, 417)
[node name="SpawnPosition10" type="Marker2D" parent="SpawnPoints"] [node name="SpawnPosition10" type="Marker2D" parent="SpawnPoints"]
position = Vector2(1859, 3) position = Vector2(1859, 3)
[connection signal="pressed" from="UI Layer/Control/HBoxContainer/Switch to Showcase" to="." method="_on_switch_to_showcase_pressed"]
[connection signal="gong_struck" from="Gong" to="." method="_on_gong_gong_struck"] [connection signal="gong_struck" from="Gong" to="." method="_on_gong_gong_struck"]

View File

@ -78,3 +78,7 @@ func _on_agent_selection_id_pressed(id: int) -> void:
agent_selection.text = bt_player.behavior_tree.resource_path.get_file() agent_selection.text = bt_player.behavior_tree.resource_path.get_file()
previous.disabled = id == 0 previous.disabled = id == 0
next.disabled = id == (agent_files.size()-1) next.disabled = id == (agent_files.size()-1)
func _on_switch_to_game_pressed() -> void:
get_tree().change_scene_to_file("res://demo/scenes/game.tscn")

View File

@ -1,22 +1,22 @@
[gd_scene load_steps=11 format=3 uid="uid://b3ae14mc2ty3y"] [gd_scene load_steps=11 format=3 uid="uid://b3ae14mc2ty3y"]
[ext_resource type="Script" path="res://demo/scenes/agent_showcase.gd" id="1_frr2n"] [ext_resource type="Script" path="res://demo/scenes/showcase.gd" id="1_l12ql"]
[ext_resource type="Theme" uid="uid://boqtjf88xcpu4" path="res://demo/assets/ui.theme" id="2_hb4lh"] [ext_resource type="Theme" uid="uid://boqtjf88xcpu4" path="res://demo/assets/ui.theme" id="2_3d7dj"]
[ext_resource type="Texture2D" uid="uid://tyu0ua1ju38l" path="res://demo/assets/logo.png" id="3_v6wtt"] [ext_resource type="FontFile" uid="uid://d25vkmce7mhlt" path="res://demo/assets/fonts/knewave_regular.ttf" id="3_7vli5"]
[ext_resource type="FontFile" uid="uid://d25vkmce7mhlt" path="res://demo/assets/fonts/knewave_regular.ttf" id="4_tju7a"] [ext_resource type="FontFile" uid="uid://n231m6uqsq6x" path="res://demo/assets/fonts/junction_bold.otf" id="4_7ubu6"]
[ext_resource type="FontFile" uid="uid://n231m6uqsq6x" path="res://demo/assets/fonts/junction_bold.otf" id="5_0fprc"] [ext_resource type="Texture2D" uid="uid://tyu0ua1ju38l" path="res://demo/assets/logo.png" id="5_rwygb"]
[ext_resource type="PackedScene" uid="uid://bsig1usigbbuy" path="res://demo/scenes/arena.tscn" id="6_6awy2"] [ext_resource type="Script" path="res://demo/scenes/base/toggle_fullscreen.gd" id="6_uggpo"]
[ext_resource type="Script" path="res://demo/scenes/toggle_fullscreen.gd" id="6_y6c7b"] [ext_resource type="PackedScene" uid="uid://bsig1usigbbuy" path="res://demo/scenes/base/arena.tscn" id="7_42nq6"]
[ext_resource type="PackedScene" uid="uid://c5fhe3tulhlco" path="res://demo/props/dummy.tscn" id="7_ao7an"] [ext_resource type="PackedScene" uid="uid://c5fhe3tulhlco" path="res://demo/props/dummy.tscn" id="8_apshw"]
[sub_resource type="LabelSettings" id="LabelSettings_3uhve"] [sub_resource type="LabelSettings" id="LabelSettings_3uhve"]
font = ExtResource("4_tju7a") font = ExtResource("3_7vli5")
font_size = 29 font_size = 29
outline_size = 10 outline_size = 10
outline_color = Color(0.145083, 0.168536, 0.203708, 1) outline_color = Color(0.145083, 0.168536, 0.203708, 1)
[sub_resource type="LabelSettings" id="LabelSettings_la4ui"] [sub_resource type="LabelSettings" id="LabelSettings_la4ui"]
font = ExtResource("4_tju7a") font = ExtResource("3_7vli5")
font_size = 36 font_size = 36
font_color = Color(1, 1, 0.239216, 1) font_color = Color(1, 1, 0.239216, 1)
outline_size = 20 outline_size = 20
@ -24,7 +24,7 @@ outline_color = Color(0.211521, 0.23888, 0.290166, 1)
[node name="AgentShowcase" type="Node2D"] [node name="AgentShowcase" type="Node2D"]
y_sort_enabled = true y_sort_enabled = true
script = ExtResource("1_frr2n") script = ExtResource("1_l12ql")
metadata/_edit_horizontal_guides_ = [1019.0] metadata/_edit_horizontal_guides_ = [1019.0]
[node name="UI Layer" type="CanvasLayer" parent="."] [node name="UI Layer" type="CanvasLayer" parent="."]
@ -36,7 +36,7 @@ anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
theme = ExtResource("2_hb4lh") theme = ExtResource("2_3d7dj")
[node name="Panel" type="Panel" parent="UI Layer/Control"] [node name="Panel" type="Panel" parent="UI Layer/Control"]
custom_minimum_size = Vector2(600, 0) custom_minimum_size = Vector2(600, 0)
@ -87,7 +87,7 @@ unique_name_in_owner = true
custom_minimum_size = Vector2(400, 50) custom_minimum_size = Vector2(400, 50)
layout_mode = 2 layout_mode = 2
size_flags_horizontal = 3 size_flags_horizontal = 3
theme_override_fonts/font = ExtResource("5_0fprc") theme_override_fonts/font = ExtResource("4_7ubu6")
theme_override_font_sizes/font_size = 30 theme_override_font_sizes/font_size = 30
text = "02_agent_imp.tres text = "02_agent_imp.tres
" "
@ -128,7 +128,7 @@ offset_right = -1643.0
offset_bottom = -45.0 offset_bottom = -45.0
grow_horizontal = 0 grow_horizontal = 0
grow_vertical = 0 grow_vertical = 0
texture = ExtResource("3_v6wtt") texture = ExtResource("5_rwygb")
[node name="Demo project" type="Label" parent="UI Layer/Control/Logo"] [node name="Demo project" type="Label" parent="UI Layer/Control/Logo"]
layout_mode = 1 layout_mode = 1
@ -148,17 +148,27 @@ label_settings = SubResource("LabelSettings_la4ui")
horizontal_alignment = 2 horizontal_alignment = 2
vertical_alignment = 1 vertical_alignment = 1
[node name="ToggleFullscreen" type="Button" parent="UI Layer/Control"] [node name="HBoxContainer" type="HBoxContainer" parent="UI Layer/Control"]
layout_mode = 0 layout_mode = 0
offset_left = 8.0 offset_left = 8.0
offset_top = 8.0 offset_top = 8.0
offset_right = 120.0 offset_right = 191.0
offset_bottom = 53.0 offset_bottom = 53.0
[node name="ToggleFullscreen" type="Button" parent="UI Layer/Control/HBoxContainer"]
layout_mode = 2
focus_mode = 0 focus_mode = 0
theme_override_fonts/font = ExtResource("4_tju7a") theme_override_fonts/font = ExtResource("3_7vli5")
theme_override_font_sizes/font_size = 22 theme_override_font_sizes/font_size = 22
text = "Toggle Fullscreen" text = "Toggle Fullscreen"
script = ExtResource("6_y6c7b") script = ExtResource("6_uggpo")
[node name="SwitchToGame" type="Button" parent="UI Layer/Control/HBoxContainer"]
layout_mode = 2
focus_mode = 0
theme_override_fonts/font = ExtResource("3_7vli5")
theme_override_font_sizes/font_size = 22
text = "Switch to Game"
[node name="Camera2D" type="Camera2D" parent="."] [node name="Camera2D" type="Camera2D" parent="."]
position = Vector2(400, 0) position = Vector2(400, 0)
@ -172,8 +182,10 @@ drag_top_margin = 0.1
drag_right_margin = 0.0 drag_right_margin = 0.0
drag_bottom_margin = 0.1 drag_bottom_margin = 0.1
[node name="Arena" parent="." instance=ExtResource("6_6awy2")] [node name="Arena" parent="." instance=ExtResource("7_42nq6")]
metadata/_edit_lock_ = true metadata/_edit_lock_ = true
[node name="Dummy" parent="." instance=ExtResource("7_ao7an")] [node name="Dummy" parent="." instance=ExtResource("8_apshw")]
position = Vector2(1106, 423) position = Vector2(1106, 423)
[connection signal="pressed" from="UI Layer/Control/HBoxContainer/SwitchToGame" to="." method="_on_switch_to_game_pressed"]

View File

@ -11,7 +11,7 @@ config_version=5
[application] [application]
config/name="LimboAI Demo" config/name="LimboAI Demo"
run/main_scene="res://demo/scenes/demo.tscn" run/main_scene="res://demo/scenes/showcase.tscn"
config/features=PackedStringArray("4.2", "Forward Plus") config/features=PackedStringArray("4.2", "Forward Plus")
config/icon="res://demo/icon.svg" config/icon="res://demo/icon.svg"