From b24117740b10ec638b7df9eda3de563995079b72 Mon Sep 17 00:00:00 2001 From: Luca Junge Date: Fri, 20 Sep 2024 19:32:32 +0200 Subject: [PATCH] cleanup, folder restructure and ui restructure --- globals/inventory.gd | 4 +- icon.svg | 1 - icon.svg.import | 37 --- project.godot | 2 +- resources/monster_stats.gd | 12 +- resources/{ => monsters}/DebugMonster1.tres | 0 resources/{ => monsters}/DebugMonster2.tres | 0 resources/{ => monsters}/DebugMonster3.tres | 0 scenes/game.gd | 12 + scenes/game.tscn | 14 + scenes/main.tscn | 289 ------------------ {scripts => scenes/monster}/monster.gd | 0 scenes/{ => monster}/monster.tscn | 8 +- .../monster_spawnpoint}/monster_spawnpoint.gd | 2 +- .../monster_spawnpoint.tscn | 4 +- {scripts => scenes/player}/player.gd | 0 scenes/{ => player}/player.tscn | 8 +- scenes/ui/ingame_controls.gd | 7 + scenes/ui/ingame_controls.tscn | 73 +++++ scenes/ui/main_menu.tscn | 67 ++++ scenes/ui/monster_list.tscn | 71 +++++ scenes/ui/monster_list_entry.gd | 28 ++ scenes/ui/monster_list_entry.tscn | 107 +++++++ scenes/ui/ui.gd | 22 ++ scenes/ui/ui.tscn | 30 ++ scenes/{ => worlds}/debug_level.tscn | 6 +- scripts/inventory.gd | 13 - scripts/monster_list.gd | 23 +- 28 files changed, 473 insertions(+), 367 deletions(-) delete mode 100644 icon.svg delete mode 100644 icon.svg.import rename resources/{ => monsters}/DebugMonster1.tres (100%) rename resources/{ => monsters}/DebugMonster2.tres (100%) rename resources/{ => monsters}/DebugMonster3.tres (100%) create mode 100644 scenes/game.gd create mode 100644 scenes/game.tscn delete mode 100644 scenes/main.tscn rename {scripts => scenes/monster}/monster.gd (100%) rename scenes/{ => monster}/monster.tscn (71%) rename {scripts => scenes/monster_spawnpoint}/monster_spawnpoint.gd (97%) rename scenes/{ => monster_spawnpoint}/monster_spawnpoint.tscn (86%) rename {scripts => scenes/player}/player.gd (100%) rename scenes/{ => player}/player.tscn (80%) create mode 100644 scenes/ui/ingame_controls.gd create mode 100644 scenes/ui/ingame_controls.tscn create mode 100644 scenes/ui/main_menu.tscn create mode 100644 scenes/ui/monster_list.tscn create mode 100644 scenes/ui/monster_list_entry.gd create mode 100644 scenes/ui/monster_list_entry.tscn create mode 100644 scenes/ui/ui.gd create mode 100644 scenes/ui/ui.tscn rename scenes/{ => worlds}/debug_level.tscn (92%) delete mode 100644 scripts/inventory.gd diff --git a/globals/inventory.gd b/globals/inventory.gd index acfdfa3..ed0eefe 100644 --- a/globals/inventory.gd +++ b/globals/inventory.gd @@ -12,8 +12,8 @@ func _ready() -> void: func setup_new_inventory() -> void: var stats = MonsterStats.new() - stats.manual_init() + stats.manual_init("Bat", 2) monsters.append(stats) # debug timeout to wait for the debug UI - await get_tree().create_timer(1.0).timeout + await get_tree().create_timer(2.0).timeout inventory_changed.emit() diff --git a/icon.svg b/icon.svg deleted file mode 100644 index 9d8b7fa..0000000 --- a/icon.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/icon.svg.import b/icon.svg.import deleted file mode 100644 index 1e23455..0000000 --- a/icon.svg.import +++ /dev/null @@ -1,37 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://b6pcv758bw37x" -path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://icon.svg" -dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] - -[params] - -compress/mode=0 -compress/high_quality=false -compress/lossy_quality=0.7 -compress/hdr_compression=1 -compress/normal_map=0 -compress/channel_pack=0 -mipmaps/generate=false -mipmaps/limit=-1 -roughness/mode=0 -roughness/src_normal="" -process/fix_alpha_border=true -process/premult_alpha=false -process/normal_map_invert_y=false -process/hdr_as_srgb=false -process/hdr_clamp_exposure=false -process/size_limit=0 -detect_3d/compress_to=1 -svg/scale=1.0 -editor/scale_with_editor_scale=false -editor/convert_colors_with_editor_theme=false diff --git a/project.godot b/project.godot index 107ff9e..41ea2fe 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="monsterfangen" -run/main_scene="res://scenes/main.tscn" +run/main_scene="res://scenes/game.tscn" config/features=PackedStringArray("4.3", "Mobile") boot_splash/image="res://assets/logo/logo.png" config/icon="res://assets/logo/logo.png" diff --git a/resources/monster_stats.gd b/resources/monster_stats.gd index 9d34eb5..99228b5 100644 --- a/resources/monster_stats.gd +++ b/resources/monster_stats.gd @@ -9,6 +9,7 @@ var spitzname: String = "" @export var base_attack: int = 10 @export var base_defense: int = 10 @export var base_speed: int = 10 +@export var base_experience_for_next_level: int = 50 @export var model: PackedScene var health: int @@ -16,13 +17,20 @@ var max_health: int var attack: int var defense: int var speed: int +var experience: int +var experience_for_next_level: int func _init() -> void: - max_health = base_health + 1.05 * level + max_health = roundi(base_health + 1.05 * level) health = max_health attack = base_attack defense = base_defense speed = base_speed + experience = 0 + experience_for_next_level = roundi(base_experience_for_next_level + 1.10 * level) + print(health, max_health) -func manual_init() -> void: +func manual_init(p_name: String, p_level: int) -> void: print("TODO: Manual init") + name = p_name + level = p_level diff --git a/resources/DebugMonster1.tres b/resources/monsters/DebugMonster1.tres similarity index 100% rename from resources/DebugMonster1.tres rename to resources/monsters/DebugMonster1.tres diff --git a/resources/DebugMonster2.tres b/resources/monsters/DebugMonster2.tres similarity index 100% rename from resources/DebugMonster2.tres rename to resources/monsters/DebugMonster2.tres diff --git a/resources/DebugMonster3.tres b/resources/monsters/DebugMonster3.tres similarity index 100% rename from resources/DebugMonster3.tres rename to resources/monsters/DebugMonster3.tres diff --git a/scenes/game.gd b/scenes/game.gd new file mode 100644 index 0000000..5822057 --- /dev/null +++ b/scenes/game.gd @@ -0,0 +1,12 @@ +extends Node3D + +@onready var ui: UI = $UI + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + # Update the UI when the Inventory (global) changes + Inventory.inventory_changed.connect(ui._update_ui) + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass diff --git a/scenes/game.tscn b/scenes/game.tscn new file mode 100644 index 0000000..e2831da --- /dev/null +++ b/scenes/game.tscn @@ -0,0 +1,14 @@ +[gd_scene load_steps=4 format=3 uid="uid://cswuap81n7t3f"] + +[ext_resource type="PackedScene" uid="uid://p8agd0dfam0p" path="res://scenes/worlds/debug_level.tscn" id="1_j851n"] +[ext_resource type="Script" path="res://scenes/game.gd" id="1_mfbtr"] +[ext_resource type="PackedScene" uid="uid://b5y7pdfe6ougf" path="res://scenes/ui/ui.tscn" id="2_ynhuf"] + +[node name="Game" type="Node3D"] +script = ExtResource("1_mfbtr") + +[node name="CurrentLevel" type="Node3D" parent="."] + +[node name="DebugLevel" parent="CurrentLevel" instance=ExtResource("1_j851n")] + +[node name="UI" parent="." instance=ExtResource("2_ynhuf")] diff --git a/scenes/main.tscn b/scenes/main.tscn deleted file mode 100644 index fb22792..0000000 --- a/scenes/main.tscn +++ /dev/null @@ -1,289 +0,0 @@ -[gd_scene load_steps=14 format=3 uid="uid://cswuap81n7t3f"] - -[ext_resource type="Texture2D" uid="uid://b6ylra30qxf30" path="res://assets/logo/logo.png" id="1_fpt28"] -[ext_resource type="PackedScene" uid="uid://p8agd0dfam0p" path="res://scenes/debug_level.tscn" id="1_j851n"] -[ext_resource type="Script" path="res://scripts/inventory.gd" id="2_0mkyf"] -[ext_resource type="Script" path="res://scripts/joystick.gd" id="4_6b5cb"] -[ext_resource type="FontFile" uid="uid://bjaavdnopfh0q" path="res://assets/fonts/aoboshi_one/AoboshiOne-Regular.ttf" id="4_33gx1"] -[ext_resource type="Texture2D" uid="uid://8anyvhkcy4ng" path="res://assets/textures/Xbox Series/Vector/xbox_button_a.svg" id="5_pwhwh"] -[ext_resource type="Texture2D" uid="uid://2vxx2waofxpw" path="res://assets/textures/Xbox Series/Vector/xbox_button_menu_outline.svg" id="6_78vsk"] -[ext_resource type="Script" path="res://scripts/monster_list.gd" id="6_shxjx"] -[ext_resource type="Script" path="res://scripts/camera_controls.gd" id="6_u5aqx"] -[ext_resource type="Texture2D" uid="uid://c737p2osplq2o" path="res://assets/textures/Xbox Series/Vector/xbox_button_x_outline.svg" id="7_rroeh"] - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_kl7kg"] -bg_color = Color(0.8, 0.8, 0.8, 1) -corner_radius_top_left = 10 -corner_radius_top_right = 10 -corner_radius_bottom_right = 10 -corner_radius_bottom_left = 10 - -[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_0o2ai"] - -[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_wyqgq"] -bg_color = Color(0, 0, 0, 0.196078) -corner_radius_top_left = 999 -corner_radius_top_right = 999 -corner_radius_bottom_right = 999 -corner_radius_bottom_left = 999 - -[node name="Main" type="Node3D"] - -[node name="CurrentLevel" type="Node3D" parent="."] - -[node name="DebugLevel" parent="CurrentLevel" instance=ExtResource("1_j851n")] - -[node name="CanvasLayer" type="CanvasLayer" parent="."] - -[node name="Inventory" type="Control" parent="CanvasLayer"] -layout_mode = 3 -anchors_preset = 10 -anchor_right = 1.0 -grow_horizontal = 2 -script = ExtResource("2_0mkyf") - -[node name="MonsterList" type="VBoxContainer" parent="CanvasLayer/Inventory"] -layout_mode = 1 -anchors_preset = 1 -anchor_left = 1.0 -anchor_right = 1.0 -offset_left = -137.0 -offset_bottom = 40.0 -grow_horizontal = 0 -theme_override_constants/separation = 10 - -[node name="Monster1" type="Label" parent="CanvasLayer/Inventory/MonsterList"] -layout_mode = 2 -text = "Monster 1: empty" - -[node name="Monster2" type="Label" parent="CanvasLayer/Inventory/MonsterList"] -layout_mode = 2 -text = "Monster 2: empty" - -[node name="Monster3" type="Label" parent="CanvasLayer/Inventory/MonsterList"] -layout_mode = 2 -text = "Monster 3: empty" - -[node name="Monster4" type="Label" parent="CanvasLayer/Inventory/MonsterList"] -layout_mode = 2 -text = "Monster 4: empty" - -[node name="Monster5" type="Label" parent="CanvasLayer/Inventory/MonsterList"] -layout_mode = 2 -text = "Monster 5: empty" - -[node name="Monster6" type="Label" parent="CanvasLayer/Inventory/MonsterList"] -layout_mode = 2 -text = "Monster 6: empty" - -[node name="MainMenu" type="Control" parent="CanvasLayer"] -visible = false -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 - -[node name="VBoxContainer" type="VBoxContainer" parent="CanvasLayer/MainMenu"] -layout_mode = 1 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -theme_override_constants/separation = 50 - -[node name="Logo" type="TextureRect" parent="CanvasLayer/MainMenu/VBoxContainer"] -layout_mode = 2 -texture = ExtResource("1_fpt28") -expand_mode = 4 -stretch_mode = 5 - -[node name="Label" type="Label" parent="CanvasLayer/MainMenu/VBoxContainer/Logo"] -layout_mode = 1 -anchors_preset = 12 -anchor_top = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_top = -23.0 -grow_horizontal = 2 -grow_vertical = 0 -theme_override_colors/font_color = Color(0.945573, 0.745802, 0.348774, 1) -theme_override_colors/font_outline_color = Color(0, 0, 0, 1) -theme_override_constants/outline_size = 30 -theme_override_fonts/font = ExtResource("4_33gx1") -theme_override_font_sizes/font_size = 70 -text = "MONSTER -FANGEN" -horizontal_alignment = 1 -max_lines_visible = 2 - -[node name="MenuButtons" type="VBoxContainer" parent="CanvasLayer/MainMenu/VBoxContainer"] -layout_mode = 2 -size_flags_horizontal = 4 - -[node name="NewGameButton" type="Button" parent="CanvasLayer/MainMenu/VBoxContainer/MenuButtons"] -layout_mode = 2 -text = "New Game" - -[node name="ContinueGameButton" type="Button" parent="CanvasLayer/MainMenu/VBoxContainer/MenuButtons"] -layout_mode = 2 -text = "Continue" - -[node name="OptionsButton" type="Button" parent="CanvasLayer/MainMenu/VBoxContainer/MenuButtons"] -layout_mode = 2 -text = "Options" - -[node name="ExitButton" type="Button" parent="CanvasLayer/MainMenu/VBoxContainer/MenuButtons"] -layout_mode = 2 -text = "Exit" - -[node name="ControlsLayer" type="CanvasLayer" parent="."] - -[node name="CameraControls" type="Control" parent="ControlsLayer"] -layout_mode = 3 -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -script = ExtResource("6_u5aqx") - -[node name="MonsterList" type="MarginContainer" parent="ControlsLayer"] -anchors_preset = 15 -anchor_right = 1.0 -anchor_bottom = 1.0 -grow_horizontal = 2 -grow_vertical = 2 -script = ExtResource("6_shxjx") - -[node name="MarginContainer" type="MarginContainer" parent="ControlsLayer/MonsterList"] -layout_mode = 2 -theme_override_constants/margin_left = 40 -theme_override_constants/margin_top = 40 -theme_override_constants/margin_right = 40 -theme_override_constants/margin_bottom = 40 - -[node name="PanelContainer" type="PanelContainer" parent="ControlsLayer/MonsterList/MarginContainer"] -layout_mode = 2 -theme_override_styles/panel = SubResource("StyleBoxFlat_kl7kg") - -[node name="VBoxContainer" type="VBoxContainer" parent="ControlsLayer/MonsterList/MarginContainer/PanelContainer"] -layout_mode = 2 - -[node name="Control" type="HBoxContainer" parent="ControlsLayer/MonsterList/MarginContainer/PanelContainer/VBoxContainer"] -layout_mode = 2 - -[node name="Label" type="Label" parent="ControlsLayer/MonsterList/MarginContainer/PanelContainer/VBoxContainer/Control"] -layout_mode = 2 -size_flags_horizontal = 3 -theme_override_fonts/font = ExtResource("4_33gx1") -theme_override_font_sizes/font_size = 50 -text = "Your Monsters" -horizontal_alignment = 1 -vertical_alignment = 1 - -[node name="CloseButton" type="Button" parent="ControlsLayer/MonsterList/MarginContainer/PanelContainer/VBoxContainer/Control"] -unique_name_in_owner = true -layout_mode = 2 -size_flags_horizontal = 8 -icon = ExtResource("7_rroeh") -flat = true - -[node name="MarginContainer" type="MarginContainer" parent="ControlsLayer/MonsterList/MarginContainer/PanelContainer/VBoxContainer"] -layout_mode = 2 -theme_override_constants/margin_left = 20 -theme_override_constants/margin_right = 20 - -[node name="MonsterListEntry" type="HBoxContainer" parent="ControlsLayer/MonsterList/MarginContainer/PanelContainer/VBoxContainer/MarginContainer"] -layout_mode = 2 - -[node name="TextureRect" type="TextureRect" parent="ControlsLayer/MonsterList/MarginContainer/PanelContainer/VBoxContainer/MarginContainer/MonsterListEntry"] -custom_minimum_size = Vector2(70, 70) -layout_mode = 2 -texture = ExtResource("1_fpt28") -expand_mode = 2 - -[node name="MonsterID" type="Label" parent="ControlsLayer/MonsterList/MarginContainer/PanelContainer/VBoxContainer/MarginContainer/MonsterListEntry"] -layout_mode = 2 -size_flags_vertical = 1 -text = "ID" -vertical_alignment = 1 - -[node name="MonsterName" type="Label" parent="ControlsLayer/MonsterList/MarginContainer/PanelContainer/VBoxContainer/MarginContainer/MonsterListEntry"] -layout_mode = 2 -size_flags_vertical = 1 -text = "Name" -vertical_alignment = 1 - -[node name="MonsterLevel" type="Label" parent="ControlsLayer/MonsterList/MarginContainer/PanelContainer/VBoxContainer/MarginContainer/MonsterListEntry"] -layout_mode = 2 -size_flags_vertical = 1 -text = "Lvl" -vertical_alignment = 1 - -[node name="MonsterHealth" type="Label" parent="ControlsLayer/MonsterList/MarginContainer/PanelContainer/VBoxContainer/MarginContainer/MonsterListEntry"] -layout_mode = 2 -size_flags_vertical = 1 -text = "Health" -vertical_alignment = 1 - -[node name="ProgressBar" type="ProgressBar" parent="ControlsLayer/MonsterList/MarginContainer/PanelContainer/VBoxContainer/MarginContainer/MonsterListEntry"] -layout_mode = 2 -size_flags_horizontal = 3 -size_flags_vertical = 4 - -[node name="Button" type="Button" parent="ControlsLayer/MonsterList/MarginContainer/PanelContainer/VBoxContainer/MarginContainer/MonsterListEntry"] -custom_minimum_size = Vector2(30, 30) -layout_mode = 2 -size_flags_horizontal = 10 -icon = ExtResource("6_78vsk") -flat = true -icon_alignment = 1 - -[node name="MarginContainer" type="MarginContainer" parent="ControlsLayer"] -anchors_preset = 12 -anchor_top = 1.0 -anchor_right = 1.0 -anchor_bottom = 1.0 -offset_top = -376.0 -grow_horizontal = 2 -grow_vertical = 0 -theme_override_constants/margin_left = 30 -theme_override_constants/margin_bottom = 30 - -[node name="VBoxContainer2" type="VBoxContainer" parent="ControlsLayer/MarginContainer"] -layout_mode = 2 -size_flags_horizontal = 3 -size_flags_vertical = 3 - -[node name="MenuButton" type="Button" parent="ControlsLayer/MarginContainer/VBoxContainer2"] -custom_minimum_size = Vector2(150, 150) -layout_mode = 2 -size_flags_horizontal = 0 -theme_override_styles/focus = SubResource("StyleBoxEmpty_0o2ai") -icon = ExtResource("6_78vsk") -flat = true -icon_alignment = 1 -expand_icon = true - -[node name="Panel" type="Panel" parent="ControlsLayer/MarginContainer/VBoxContainer2"] -custom_minimum_size = Vector2(300, 300) -layout_mode = 2 -size_flags_horizontal = 0 -theme_override_styles/panel = SubResource("StyleBoxFlat_wyqgq") -script = ExtResource("4_6b5cb") - -[node name="Thumbstick" type="TextureRect" parent="ControlsLayer/MarginContainer/VBoxContainer2/Panel"] -self_modulate = Color(0, 0, 0, 0.392157) -custom_minimum_size = Vector2(100, 100) -layout_mode = 0 -offset_right = 40.0 -offset_bottom = 40.0 -texture = ExtResource("5_pwhwh") - -[connection signal="gui_input" from="ControlsLayer/CameraControls" to="ControlsLayer/CameraControls" method="_on_gui_input"] -[connection signal="pressed" from="ControlsLayer/MonsterList/MarginContainer/PanelContainer/VBoxContainer/Control/CloseButton" to="ControlsLayer/MonsterList" method="_on_close_button_pressed"] -[connection signal="gui_input" from="ControlsLayer/MarginContainer/VBoxContainer2/Panel" to="ControlsLayer/MarginContainer/VBoxContainer2/Panel" method="_on_gui_input"] -[connection signal="resized" from="ControlsLayer/MarginContainer/VBoxContainer2/Panel" to="ControlsLayer/MarginContainer/VBoxContainer2/Panel" method="_on_resized"] diff --git a/scripts/monster.gd b/scenes/monster/monster.gd similarity index 100% rename from scripts/monster.gd rename to scenes/monster/monster.gd diff --git a/scenes/monster.tscn b/scenes/monster/monster.tscn similarity index 71% rename from scenes/monster.tscn rename to scenes/monster/monster.tscn index 27af6e4..901d16c 100644 --- a/scenes/monster.tscn +++ b/scenes/monster/monster.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=5 format=3 uid="uid://cytaswycabcel"] -[ext_resource type="Script" path="res://scripts/monster.gd" id="1_13xtk"] -[ext_resource type="Material" uid="uid://ctul3e67rcq23" path="res://materials/CollisionDebugMaterial.tres" id="3_k6auu"] +[ext_resource type="Script" path="res://scenes/monster/monster.gd" id="1_5gfkg"] +[ext_resource type="Material" uid="uid://ctul3e67rcq23" path="res://materials/CollisionDebugMaterial.tres" id="2_bf2kb"] [sub_resource type="SphereShape3D" id="SphereShape3D_tjvna"] radius = 0.4 @@ -11,7 +11,7 @@ radius = 0.4 height = 0.8 [node name="Monster" type="CharacterBody3D"] -script = ExtResource("1_13xtk") +script = ExtResource("1_5gfkg") [node name="CollisionShape3D" type="CollisionShape3D" parent="."] shape = SubResource("SphereShape3D_tjvna") @@ -19,4 +19,4 @@ shape = SubResource("SphereShape3D_tjvna") [node name="CollisionVisualizer" type="MeshInstance3D" parent="."] mesh = SubResource("SphereMesh_aou7a") skeleton = NodePath("") -surface_material_override/0 = ExtResource("3_k6auu") +surface_material_override/0 = ExtResource("2_bf2kb") diff --git a/scripts/monster_spawnpoint.gd b/scenes/monster_spawnpoint/monster_spawnpoint.gd similarity index 97% rename from scripts/monster_spawnpoint.gd rename to scenes/monster_spawnpoint/monster_spawnpoint.gd index f29e2b9..6b0c2d6 100644 --- a/scripts/monster_spawnpoint.gd +++ b/scenes/monster_spawnpoint/monster_spawnpoint.gd @@ -1,7 +1,7 @@ class_name MonsterSpawnpoint extends Node3D -@onready var monster_tscn = preload("res://scenes/monster.tscn") +@onready var monster_tscn = preload("res://scenes/monster/monster.tscn") # a spawnpoint that can spawn monsters # monsters are only spawned, if the player is not looking diff --git a/scenes/monster_spawnpoint.tscn b/scenes/monster_spawnpoint/monster_spawnpoint.tscn similarity index 86% rename from scenes/monster_spawnpoint.tscn rename to scenes/monster_spawnpoint/monster_spawnpoint.tscn index ab242b5..c38a45c 100644 --- a/scenes/monster_spawnpoint.tscn +++ b/scenes/monster_spawnpoint/monster_spawnpoint.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://dawpmu4vvv3rs"] -[ext_resource type="Script" path="res://scripts/monster_spawnpoint.gd" id="1_eyon3"] +[ext_resource type="Script" path="res://scenes/monster_spawnpoint/monster_spawnpoint.gd" id="1_p2vfw"] [sub_resource type="SphereMesh" id="SphereMesh_phb77"] radius = 0.4 @@ -13,7 +13,7 @@ metallic = 1.0 roughness = 0.25 [node name="MonsterSpawnpoint" type="Node3D"] -script = ExtResource("1_eyon3") +script = ExtResource("1_p2vfw") [node name="Diamond" type="MeshInstance3D" parent="."] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0) diff --git a/scripts/player.gd b/scenes/player/player.gd similarity index 100% rename from scripts/player.gd rename to scenes/player/player.gd diff --git a/scenes/player.tscn b/scenes/player/player.tscn similarity index 80% rename from scenes/player.tscn rename to scenes/player/player.tscn index 74ba8fc..784a0a0 100644 --- a/scenes/player.tscn +++ b/scenes/player/player.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=4 format=3 uid="uid://be5bc5gjbo875"] -[ext_resource type="Script" path="res://scripts/player.gd" id="1_3fea3"] -[ext_resource type="PackedScene" uid="uid://cy36aygvs66pn" path="res://assets/models/gobot/gobot_skin.tscn" id="2_vivad"] +[ext_resource type="Script" path="res://scenes/player/player.gd" id="1_mv2yl"] +[ext_resource type="PackedScene" uid="uid://cy36aygvs66pn" path="res://assets/models/gobot/gobot_skin.tscn" id="2_a4t6w"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_xuba7"] height = 1.7 @@ -10,9 +10,9 @@ height = 1.7 axis_lock_angular_x = true axis_lock_angular_y = true axis_lock_angular_z = true -script = ExtResource("1_3fea3") +script = ExtResource("1_mv2yl") -[node name="GobotSkin" parent="." instance=ExtResource("2_vivad")] +[node name="GobotSkin" parent="." instance=ExtResource("2_a4t6w")] transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0) [node name="CollisionShape3D" type="CollisionShape3D" parent="."] diff --git a/scenes/ui/ingame_controls.gd b/scenes/ui/ingame_controls.gd new file mode 100644 index 0000000..b84275b --- /dev/null +++ b/scenes/ui/ingame_controls.gd @@ -0,0 +1,7 @@ +extends MarginContainer +class_name IngameControls + +signal menu_button_clicked + +func _on_menu_button_pressed() -> void: + menu_button_clicked.emit() diff --git a/scenes/ui/ingame_controls.tscn b/scenes/ui/ingame_controls.tscn new file mode 100644 index 0000000..51dfcd7 --- /dev/null +++ b/scenes/ui/ingame_controls.tscn @@ -0,0 +1,73 @@ +[gd_scene load_steps=7 format=3 uid="uid://1anjhvi173g3"] + +[ext_resource type="Script" path="res://scenes/ui/ingame_controls.gd" id="1_iw1sp"] +[ext_resource type="Texture2D" uid="uid://2vxx2waofxpw" path="res://assets/textures/Xbox Series/Vector/xbox_button_menu_outline.svg" id="1_wr5sh"] +[ext_resource type="Script" path="res://scripts/joystick.gd" id="2_pyri2"] +[ext_resource type="Texture2D" uid="uid://8anyvhkcy4ng" path="res://assets/textures/Xbox Series/Vector/xbox_button_a.svg" id="3_lgi8v"] + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_uoef2"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_nfkty"] +bg_color = Color(0, 0, 0, 0.196078) +corner_radius_top_left = 999 +corner_radius_top_right = 999 +corner_radius_bottom_right = 999 +corner_radius_bottom_left = 999 + +[node name="IngameControls" type="MarginContainer"] +anchors_preset = 12 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = -484.0 +grow_horizontal = 2 +grow_vertical = 0 +theme_override_constants/margin_left = 30 +theme_override_constants/margin_bottom = 30 +script = ExtResource("1_iw1sp") + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 3 +theme_override_constants/separation = 32 + +[node name="MenuButton" type="Button" parent="VBoxContainer"] +self_modulate = Color(0, 0, 0, 0.392157) +custom_minimum_size = Vector2(200, 200) +layout_mode = 2 +size_flags_horizontal = 0 +theme_override_styles/focus = SubResource("StyleBoxEmpty_uoef2") +icon = ExtResource("1_wr5sh") +flat = true +icon_alignment = 1 +expand_icon = true + +[node name="JoystickPanel" type="Panel" parent="VBoxContainer"] +custom_minimum_size = Vector2(400, 400) +layout_mode = 2 +size_flags_horizontal = 0 +theme_override_styles/panel = SubResource("StyleBoxFlat_nfkty") +script = ExtResource("2_pyri2") + +[node name="Thumbstick" type="TextureRect" parent="VBoxContainer/JoystickPanel"] +self_modulate = Color(0, 0, 0, 0.392157) +custom_minimum_size = Vector2(200, 200) +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -32.0 +offset_top = -32.0 +offset_right = 32.0 +offset_bottom = 32.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = ExtResource("3_lgi8v") +stretch_mode = 5 + +[connection signal="pressed" from="VBoxContainer/MenuButton" to="." method="_on_menu_button_pressed"] +[connection signal="gui_input" from="VBoxContainer/JoystickPanel" to="VBoxContainer/JoystickPanel" method="_on_gui_input"] +[connection signal="resized" from="VBoxContainer/JoystickPanel" to="VBoxContainer/JoystickPanel" method="_on_resized"] diff --git a/scenes/ui/main_menu.tscn b/scenes/ui/main_menu.tscn new file mode 100644 index 0000000..5e45fa4 --- /dev/null +++ b/scenes/ui/main_menu.tscn @@ -0,0 +1,67 @@ +[gd_scene load_steps=3 format=3 uid="uid://dt00rjsodtady"] + +[ext_resource type="Texture2D" uid="uid://b6ylra30qxf30" path="res://assets/logo/logo.png" id="1_1fmce"] +[ext_resource type="FontFile" uid="uid://bjaavdnopfh0q" path="res://assets/fonts/aoboshi_one/AoboshiOne-Regular.ttf" id="2_aqmkw"] + +[node name="MainMenu" type="Control"] +visible = false +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +theme_override_constants/separation = 50 + +[node name="Logo" type="TextureRect" parent="VBoxContainer"] +layout_mode = 2 +texture = ExtResource("1_1fmce") +expand_mode = 4 +stretch_mode = 5 + +[node name="Label" type="Label" parent="VBoxContainer/Logo"] +layout_mode = 1 +anchors_preset = 12 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = -23.0 +grow_horizontal = 2 +grow_vertical = 0 +theme_override_colors/font_color = Color(0.945573, 0.745802, 0.348774, 1) +theme_override_colors/font_outline_color = Color(0, 0, 0, 1) +theme_override_constants/outline_size = 30 +theme_override_fonts/font = ExtResource("2_aqmkw") +theme_override_font_sizes/font_size = 70 +text = "MONSTER +FANGEN" +horizontal_alignment = 1 +max_lines_visible = 2 + +[node name="MenuButtons" type="VBoxContainer" parent="VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 4 + +[node name="NewGameButton" type="Button" parent="VBoxContainer/MenuButtons"] +layout_mode = 2 +text = "New Game" + +[node name="ContinueGameButton" type="Button" parent="VBoxContainer/MenuButtons"] +layout_mode = 2 +text = "Continue" + +[node name="OptionsButton" type="Button" parent="VBoxContainer/MenuButtons"] +layout_mode = 2 +text = "Options" + +[node name="ExitButton" type="Button" parent="VBoxContainer/MenuButtons"] +layout_mode = 2 +text = "Exit" diff --git a/scenes/ui/monster_list.tscn b/scenes/ui/monster_list.tscn new file mode 100644 index 0000000..62db6f2 --- /dev/null +++ b/scenes/ui/monster_list.tscn @@ -0,0 +1,71 @@ +[gd_scene load_steps=5 format=3 uid="uid://bbvbnrcjatkrb"] + +[ext_resource type="Script" path="res://scripts/monster_list.gd" id="1_jk76e"] +[ext_resource type="FontFile" uid="uid://bjaavdnopfh0q" path="res://assets/fonts/aoboshi_one/AoboshiOne-Regular.ttf" id="2_hunv3"] +[ext_resource type="Texture2D" uid="uid://c737p2osplq2o" path="res://assets/textures/Xbox Series/Vector/xbox_button_x_outline.svg" id="3_08jy5"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_co4a0"] +bg_color = Color(0.9, 0.9, 0.9, 1) +corner_radius_top_left = 64 +corner_radius_top_right = 64 +corner_radius_bottom_right = 64 +corner_radius_bottom_left = 64 + +[node name="MonsterList" type="MarginContainer"] +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_jk76e") + +[node name="MarginContainer" type="MarginContainer" parent="."] +layout_mode = 2 +theme_override_constants/margin_left = 100 +theme_override_constants/margin_top = 150 +theme_override_constants/margin_right = 100 +theme_override_constants/margin_bottom = 100 + +[node name="PanelContainer" type="PanelContainer" parent="MarginContainer"] +layout_mode = 2 +theme_override_styles/panel = SubResource("StyleBoxFlat_co4a0") + +[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/PanelContainer"] +layout_mode = 2 + +[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/PanelContainer/VBoxContainer"] +layout_mode = 2 +theme_override_constants/margin_top = 32 + +[node name="Label" type="Label" parent="MarginContainer/PanelContainer/VBoxContainer/MarginContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +theme_override_colors/font_color = Color(0, 0, 0, 1) +theme_override_fonts/font = ExtResource("2_hunv3") +theme_override_font_sizes/font_size = 50 +text = "Your Monsters" +horizontal_alignment = 1 +vertical_alignment = 1 + +[node name="MonsterListEntryContainer" type="MarginContainer" parent="MarginContainer/PanelContainer/VBoxContainer"] +layout_mode = 2 +size_flags_vertical = 2 +theme_override_constants/margin_left = 20 +theme_override_constants/margin_right = 20 + +[node name="MarginContainer2" type="MarginContainer" parent="MarginContainer/PanelContainer/VBoxContainer"] +layout_mode = 2 +theme_override_constants/margin_bottom = 32 + +[node name="CloseButton" type="Button" parent="MarginContainer/PanelContainer/VBoxContainer/MarginContainer2"] +unique_name_in_owner = true +self_modulate = Color(0, 0, 0, 1) +custom_minimum_size = Vector2(150, 150) +layout_mode = 2 +size_flags_horizontal = 4 +icon = ExtResource("3_08jy5") +flat = true +icon_alignment = 1 +expand_icon = true + +[connection signal="pressed" from="MarginContainer/PanelContainer/VBoxContainer/MarginContainer2/CloseButton" to="." method="_on_close_button_pressed"] diff --git a/scenes/ui/monster_list_entry.gd b/scenes/ui/monster_list_entry.gd new file mode 100644 index 0000000..d68b06a --- /dev/null +++ b/scenes/ui/monster_list_entry.gd @@ -0,0 +1,28 @@ +extends HBoxContainer +class_name MonsterListEntry + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass + +func populate(monster) -> void: + # thumbnail + # id + # name + # level + # health + # healthprogress + # experience + %MonsterID.text = str(0) + %MonsterName.text = monster.name + %MonsterLevel.text = "Lvl. %s" % monster.level + %HealthProgressBar.value = monster.health + %HealthProgressBar.max_value = monster.max_health + %ExperienceProgressBar.value = monster.experience + %ExperienceProgressBar.max_value = monster.experience_for_next_level diff --git a/scenes/ui/monster_list_entry.tscn b/scenes/ui/monster_list_entry.tscn new file mode 100644 index 0000000..d2d23ce --- /dev/null +++ b/scenes/ui/monster_list_entry.tscn @@ -0,0 +1,107 @@ +[gd_scene load_steps=9 format=3 uid="uid://brp2sljqnkuhe"] + +[ext_resource type="Texture2D" uid="uid://b6ylra30qxf30" path="res://assets/logo/logo.png" id="1_16gb7"] +[ext_resource type="Script" path="res://scenes/ui/monster_list_entry.gd" id="1_spojl"] +[ext_resource type="Texture2D" uid="uid://2vxx2waofxpw" path="res://assets/textures/Xbox Series/Vector/xbox_button_menu_outline.svg" id="2_5n4ar"] + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_s3mod"] +content_margin_top = 24.0 +bg_color = Color(0.4, 0.5, 0.455, 1) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_nb1sm"] +bg_color = Color(0, 0.843137, 0.466667, 1) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_fkb5g"] +content_margin_top = 12.0 +bg_color = Color(0.4, 0.466667, 0.5, 1) + +[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_b4pov"] +bg_color = Color(0, 0.56, 0.84, 1) + +[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_x2rfb"] + +[node name="MonsterListEntry" type="HBoxContainer"] +anchors_preset = 10 +anchor_right = 1.0 +offset_bottom = 72.0 +grow_horizontal = 2 +script = ExtResource("1_spojl") + +[node name="Thumbnail" type="TextureRect" parent="."] +unique_name_in_owner = true +custom_minimum_size = Vector2(70, 70) +layout_mode = 2 +texture = ExtResource("1_16gb7") +expand_mode = 3 + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 4 + +[node name="NameAndLevelContainer" type="HBoxContainer" parent="VBoxContainer"] +layout_mode = 2 +theme_override_constants/separation = 10 + +[node name="MonsterID" type="Label" parent="VBoxContainer/NameAndLevelContainer"] +unique_name_in_owner = true +visible = false +layout_mode = 2 +theme_override_colors/font_color = Color(0, 0, 0, 1) +text = "ID" +vertical_alignment = 1 + +[node name="MonsterName" type="Label" parent="VBoxContainer/NameAndLevelContainer"] +unique_name_in_owner = true +layout_mode = 2 +theme_override_colors/font_color = Color(0, 0, 0, 1) +theme_override_font_sizes/font_size = 40 +text = "Name" +vertical_alignment = 1 + +[node name="MonsterLevel" type="Label" parent="VBoxContainer/NameAndLevelContainer"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_vertical = 8 +theme_override_colors/font_color = Color(0, 0, 0, 1) +theme_override_font_sizes/font_size = 40 +text = "Lvl" +vertical_alignment = 1 + +[node name="ProgressBarContainer" type="VBoxContainer" parent="VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 4 +theme_override_constants/separation = 0 + +[node name="HealthProgressBar" type="ProgressBar" parent="VBoxContainer/ProgressBarContainer"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 4 +theme_override_styles/background = SubResource("StyleBoxFlat_s3mod") +theme_override_styles/fill = SubResource("StyleBoxFlat_nb1sm") +step = 1.0 +rounded = true +show_percentage = false + +[node name="ExperienceProgressBar" type="ProgressBar" parent="VBoxContainer/ProgressBarContainer"] +unique_name_in_owner = true +layout_mode = 2 +theme_override_styles/background = SubResource("StyleBoxFlat_fkb5g") +theme_override_styles/fill = SubResource("StyleBoxFlat_b4pov") +step = 1.0 +rounded = true +show_percentage = false + +[node name="SwapPositionButton" type="Button" parent="."] +unique_name_in_owner = true +self_modulate = Color(0, 0, 0, 1) +custom_minimum_size = Vector2(150, 150) +layout_mode = 2 +size_flags_horizontal = 8 +theme_override_styles/focus = SubResource("StyleBoxEmpty_x2rfb") +icon = ExtResource("2_5n4ar") +flat = true +icon_alignment = 1 +expand_icon = true diff --git a/scenes/ui/ui.gd b/scenes/ui/ui.gd new file mode 100644 index 0000000..ca5945c --- /dev/null +++ b/scenes/ui/ui.gd @@ -0,0 +1,22 @@ +extends CanvasLayer +class_name UI + +@onready var monster_list: MarginContainer = %MonsterList + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass + +func _on_ingame_controls_menu_button_clicked() -> void: + monster_list.visible = true + +# Updates the whole UI +func _update_ui() -> void: + # Updating the monster list + monster_list._update_monster_list() + + print("UI updated") diff --git a/scenes/ui/ui.tscn b/scenes/ui/ui.tscn new file mode 100644 index 0000000..73b9af6 --- /dev/null +++ b/scenes/ui/ui.tscn @@ -0,0 +1,30 @@ +[gd_scene load_steps=6 format=3 uid="uid://b5y7pdfe6ougf"] + +[ext_resource type="Script" path="res://scenes/ui/ui.gd" id="1_vyi3s"] +[ext_resource type="Script" path="res://scripts/camera_controls.gd" id="1_x56x6"] +[ext_resource type="PackedScene" uid="uid://dt00rjsodtady" path="res://scenes/ui/main_menu.tscn" id="3_tcmm8"] +[ext_resource type="PackedScene" uid="uid://1anjhvi173g3" path="res://scenes/ui/ingame_controls.tscn" id="4_likk0"] +[ext_resource type="PackedScene" uid="uid://bbvbnrcjatkrb" path="res://scenes/ui/monster_list.tscn" id="5_qjqu1"] + +[node name="UI" type="CanvasLayer"] +script = ExtResource("1_vyi3s") + +[node name="CameraControlArea" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("1_x56x6") + +[node name="MainMenu" parent="." instance=ExtResource("3_tcmm8")] + +[node name="IngameControls" parent="." instance=ExtResource("4_likk0")] + +[node name="MonsterList" parent="." instance=ExtResource("5_qjqu1")] +unique_name_in_owner = true +visible = false + +[connection signal="gui_input" from="CameraControlArea" to="CameraControlArea" method="_on_gui_input"] +[connection signal="menu_button_clicked" from="IngameControls" to="." method="_on_ingame_controls_menu_button_clicked"] diff --git a/scenes/debug_level.tscn b/scenes/worlds/debug_level.tscn similarity index 92% rename from scenes/debug_level.tscn rename to scenes/worlds/debug_level.tscn index 2ef56f9..64997b4 100644 --- a/scenes/debug_level.tscn +++ b/scenes/worlds/debug_level.tscn @@ -1,9 +1,9 @@ [gd_scene load_steps=11 format=3 uid="uid://p8agd0dfam0p"] -[ext_resource type="PackedScene" uid="uid://be5bc5gjbo875" path="res://scenes/player.tscn" id="1_ra6oo"] -[ext_resource type="PackedScene" uid="uid://dawpmu4vvv3rs" path="res://scenes/monster_spawnpoint.tscn" id="3_esgto"] +[ext_resource type="PackedScene" uid="uid://be5bc5gjbo875" path="res://scenes/player/player.tscn" id="1_ra6oo"] +[ext_resource type="PackedScene" uid="uid://dawpmu4vvv3rs" path="res://scenes/monster_spawnpoint/monster_spawnpoint.tscn" id="3_esgto"] [ext_resource type="Script" path="res://resources/monster_stats.gd" id="3_iktqp"] -[ext_resource type="Resource" uid="uid://ym438vedcdyl" path="res://resources/DebugMonster1.tres" id="4_3y7gi"] +[ext_resource type="Resource" uid="uid://ym438vedcdyl" path="res://resources/monsters/DebugMonster1.tres" id="4_3y7gi"] [sub_resource type="PlaneMesh" id="PlaneMesh_wak6a"] size = Vector2(1000, 1000) diff --git a/scripts/inventory.gd b/scripts/inventory.gd deleted file mode 100644 index b732637..0000000 --- a/scripts/inventory.gd +++ /dev/null @@ -1,13 +0,0 @@ -extends Control - - -# Called when the node enters the scene tree for the first time. -func _ready() -> void: - Inventory.connect("inventory_changed", update_inventory) - pass # Replace with function body. - -func update_inventory() -> void: - var m = Inventory.monsters[0] - var string = "%s Lvl %s, %s/%s" % [m.name, m.level, m.health, m.max_health] - $MonsterList/Monster1.text = string - print("Updating inventory") diff --git a/scripts/monster_list.gd b/scripts/monster_list.gd index 4639361..2a616cd 100644 --- a/scripts/monster_list.gd +++ b/scripts/monster_list.gd @@ -1,16 +1,23 @@ extends MarginContainer +class_name MonsterList +@onready var monster_list_entry_container: MarginContainer = $MarginContainer/PanelContainer/VBoxContainer/MonsterListEntryContainer +@onready var monster_list_entry = preload("res://scenes/ui/monster_list_entry.tscn") -# Called when the node enters the scene tree for the first time. func _ready() -> void: - pass # Replace with function body. - - -# Called every frame. 'delta' is the elapsed time since the previous frame. -func _process(delta: float) -> void: - pass - + visible = false func _on_close_button_pressed() -> void: visible = false pass # Replace with function body. + +func _update_monster_list() -> void: + for i in Inventory.monsters.size(): + var monster = Inventory.monsters[i] + var entry = monster_list_entry.instantiate() + + # populate the new entry + entry.populate(Inventory.monsters[i]) + + # add it to the list + monster_list_entry_container.add_child(entry)