Compare commits

...

6 Commits

Author SHA1 Message Date
Martin Felis eeff59a413 Quest dialog functional. 2024-07-12 14:32:33 +02:00
Martin Felis f9ced395ce Item icons are now properly scaled. 2024-07-12 11:59:33 +02:00
Martin Felis 71550b15fe Cleanup. 2024-07-12 11:27:10 +02:00
Martin Felis d40c299964 Restructured game. 2024-07-12 11:25:59 +02:00
Martin Felis 414deaf986 Minor cleanup. 2024-07-12 11:25:21 +02:00
Martin Felis b9f8e2a751 Added wrench object 2024-07-12 11:24:51 +02:00
27 changed files with 1485 additions and 2542 deletions

199
Game.tscn
View File

@ -1,4 +1,4 @@
[gd_scene load_steps=44 format=3 uid="uid://bugqatylloxkl"]
[gd_scene load_steps=41 format=3 uid="uid://bugqatylloxkl"]
[ext_resource type="Script" path="res://Player.gd" id="1_3lyis"]
[ext_resource type="Script" path="res://World.gd" id="1_e417k"]
@ -6,17 +6,14 @@
[ext_resource type="Script" path="res://RootUI.gd" id="2_gg3gt"]
[ext_resource type="PackedScene" uid="uid://dk2wv1vem0ubw" path="res://assets/scene_props/RockA.tscn" id="3_owduk"]
[ext_resource type="PackedScene" uid="uid://dy8vjf760prhq" path="res://assets/characters/Rogue.tscn" id="4_6mbva"]
[ext_resource type="Script" path="res://model/quest_state.gd" id="4_fmwrw"]
[ext_resource type="Texture2D" uid="uid://cq8ypeagpedq" path="res://assets/kenney/ui-pack-rpg-expansion/PNG/cursorSword_bronze.png" id="4_pcyi0"]
[ext_resource type="PackedScene" uid="uid://da5r82nvypfk4" path="res://objects/PickupItem.tscn" id="4_ttv16"]
[ext_resource type="Texture2D" uid="uid://c7fu3paj3b4e8" path="res://assets/kenney/ui-pack-rpg-expansion/PNG/cursorSword_silver.png" id="5_24tqj"]
[ext_resource type="Resource" uid="uid://bn5j38jbwlj1f" path="res://data/items/stick.tres" id="6_1orlx"]
[ext_resource type="Resource" uid="uid://c1ll2snhgv3m1" path="res://data/items/treelog.tres" id="6_3vb4g"]
[ext_resource type="Texture2D" uid="uid://drpl0ql1p3pfk" path="res://assets/kenney/ui-pack-rpg-expansion/PNG/cursorSword_gold.png" id="6_uid86"]
[ext_resource type="Resource" uid="uid://coser1y1y5unl" path="res://data/items/door.tres" id="6_wnxjh"]
[ext_resource type="Script" path="res://GameUI.gd" id="7_mw21s"]
[ext_resource type="MeshLibrary" uid="uid://dcpuitbu16j1a" path="res://assets/mesh_library.tres" id="8_gh3i5"]
[ext_resource type="Theme" uid="uid://dmk7hc81l8gbw" path="res://ui/ui_theme.tres" id="8_qpuke"]
[ext_resource type="Texture2D" uid="uid://bq3b1hxl5ojh6" path="res://assets/icons/npc_emotes/attention.tres" id="10_6agi3"]
[ext_resource type="PackedScene" uid="uid://dmagdl5pi6jdj" path="res://world/level.tscn" id="11_m8tt7"]
[ext_resource type="Script" path="res://ui/inventory_dialog.gd" id="12_8cl6a"]
[ext_resource type="PackedScene" uid="uid://dp3fi0g53qrt2" path="res://ui/item_slot.tscn" id="12_v6fpp"]
[ext_resource type="PackedScene" uid="uid://2q8dhf61a7os" path="res://assets/characters/Engineer.tscn" id="13_gxr54"]
@ -101,6 +98,10 @@ environment = SubResource("Environment_v85yo")
unique_name_in_owner = true
script = ExtResource("1_3lyis")
[node name="QuestState" type="Node" parent="World/Player"]
unique_name_in_owner = true
script = ExtResource("4_fmwrw")
[node name="MeshInstance3D" type="MeshInstance3D" parent="World/Player"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.3, 0)
visible = false
@ -132,36 +133,6 @@ shape = SubResource("SphereShape3D_wrkyq")
transform = Transform3D(0.836133, 0.124138, 0.534295, -0.548527, 0.189226, 0.81444, 0, -0.974055, 0.226311, 5.06819, 4.51394, 0)
shadow_enabled = true
[node name="Entities" type="Node3D" parent="World"]
[node name="Item" parent="World/Entities" instance=ExtResource("4_ttv16")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.55623, 0, 0.612282)
item = ExtResource("6_1orlx")
[node name="Item4" parent="World/Entities" instance=ExtResource("4_ttv16")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.17514, -2.38419e-07, 0.574962)
item = ExtResource("6_wnxjh")
[node name="Item2" parent="World/Entities" instance=ExtResource("4_ttv16")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.978853, -2.38419e-07, -1.39068)
[node name="Item3" parent="World/Entities" instance=ExtResource("4_ttv16")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.28455, 0, -0.204204)
item = ExtResource("6_3vb4g")
[node name="GridMap" type="GridMap" parent="World"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0)
rotation_order = 1
mesh_library = ExtResource("8_gh3i5")
cell_size = Vector3(0.5, 0.5, 0.5)
cell_center_x = false
cell_center_y = false
cell_center_z = false
data = {
"cells": PackedInt32Array(0, 0, 14, 3, 0, 14, 6, 0, 14, 0, 65533, 14, 3, 65533, 14, 0, 3, 14, 3, 3, 14, 6, 3, 14, 6, 65533, 14, 9, 65533, 14, 6, 65530, 14, 3, 65530, 14, 0, 65530, 14, 65533, 65530, 14, 65533, 65533, 14, 65533, 0, 14, 65533, 3, 14, 65545, 1, 1441801, 65545, 4, 1441801, 65545, 65530, 1441801, 65543, 65528, 9, 65540, 65528, 9, 65537, 65528, 9, 131070, 65528, 9, 131067, 65529, 1441801, 131067, 65532, 1441801, 131067, 65535, 1441801, 131067, 2, 1441801, 131068, 65528, 9, 65544, 5, 9, 65541, 5, 9, 65538, 5, 9, 131071, 5, 9, 131068, 5, 9, 131067, 3, 1441801)
}
metadata/_editor_floor_ = Vector3(0, 1, 0)
[node name="Disabled" type="Node3D" parent="World"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1000, -1000, 0)
@ -228,6 +199,8 @@ dialogue_resource = ExtResource("15_2n7cr")
[node name="CollisionShape3D" type="CollisionShape3D" parent="World/Merchant/Actionable"]
shape = SubResource("SphereShape3D_6nrvr")
[node name="Level" parent="World" instance=ExtResource("11_m8tt7")]
[node name="RootUI" type="CanvasLayer" parent="."]
script = ExtResource("2_gg3gt")
@ -389,6 +362,80 @@ layout_mode = 2
text = "Start
"
[node name="GameMenuUI" type="PanelContainer" parent="RootUI"]
unique_name_in_owner = true
visible = false
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -199.0
offset_top = -186.0
offset_right = 199.0
offset_bottom = 186.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("8_qpuke")
[node name="MarginContainer" type="MarginContainer" parent="RootUI/GameMenuUI"]
layout_mode = 2
theme_override_constants/margin_left = 60
theme_override_constants/margin_top = 60
theme_override_constants/margin_right = 60
theme_override_constants/margin_bottom = 60
[node name="VBoxContainer" type="VBoxContainer" parent="RootUI/GameMenuUI/MarginContainer"]
layout_mode = 2
[node name="MarginContainer4" type="MarginContainer" parent="RootUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="SaveGameButton" type="Button" parent="RootUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer4"]
layout_mode = 2
text = "Save Game
"
[node name="MarginContainer2" type="MarginContainer" parent="RootUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="OptionsButton" type="Button" parent="RootUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer2"]
layout_mode = 2
text = "Options"
[node name="MarginContainer3" type="MarginContainer" parent="RootUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="BackToGameButton" type="Button" parent="RootUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer3"]
layout_mode = 2
text = "Return to Game"
[node name="HSeparator" type="HSeparator" parent="RootUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
[node name="MarginContainer5" type="MarginContainer" parent="RootUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="ToMainMenuButton" type="Button" parent="RootUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer5"]
layout_mode = 2
text = "Back to Main Menu"
[node name="GameUI" type="Control" parent="RootUI"]
unique_name_in_owner = true
layout_mode = 3
@ -624,79 +671,8 @@ text = "Backpack"
[node name="InventoryContainer" parent="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/BackpackUI/VBoxContainer" instance=ExtResource("15_5xu2a")]
unique_name_in_owner = true
layout_mode = 2
[node name="GameMenuUI" type="PanelContainer" parent="RootUI"]
unique_name_in_owner = true
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -199.0
offset_top = -134.5
offset_right = 199.0
offset_bottom = 134.5
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("8_qpuke")
[node name="MarginContainer" type="MarginContainer" parent="RootUI/GameMenuUI"]
layout_mode = 2
theme_override_constants/margin_left = 60
theme_override_constants/margin_top = 60
theme_override_constants/margin_right = 60
theme_override_constants/margin_bottom = 60
[node name="VBoxContainer" type="VBoxContainer" parent="RootUI/GameMenuUI/MarginContainer"]
layout_mode = 2
[node name="MarginContainer4" type="MarginContainer" parent="RootUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="SaveGameButton" type="Button" parent="RootUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer4"]
layout_mode = 2
text = "Save Game
"
[node name="MarginContainer2" type="MarginContainer" parent="RootUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="OptionsButton" type="Button" parent="RootUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer2"]
layout_mode = 2
text = "Options"
[node name="MarginContainer3" type="MarginContainer" parent="RootUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="BackToGameButton" type="Button" parent="RootUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer3"]
layout_mode = 2
text = "Return to Game"
[node name="HSeparator" type="HSeparator" parent="RootUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
[node name="MarginContainer5" type="MarginContainer" parent="RootUI/GameMenuUI/MarginContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
[node name="ToMainMenuButton" type="Button" parent="RootUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer5"]
layout_mode = 2
text = "Back to Main Menu"
size_flags_horizontal = 4
size_flags_vertical = 4
[node name="tree-pine2" parent="." instance=ExtResource("21_5210s")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.754677, 0, 0.0391712)
@ -713,14 +689,13 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.921204, 0, -3.30199)
[node name="mushrooms2" parent="." instance=ExtResource("25_tea3k")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.851, 0, 0.798104)
[connection signal="trigger_message" from="World/Player" to="RootUI/GameUI" method="_on_player_trigger_message"]
[connection signal="pressed" from="RootUI/MainMenuUI/MarginContainer/VBoxContainer/MarginContainer/NewGameButton" to="RootUI" method="_on_new_game_button_pressed"]
[connection signal="pressed" from="RootUI/MainMenuUI/MarginContainer/VBoxContainer/MarginContainer3/QuitButton" to="RootUI" method="_on_quit_button_pressed"]
[connection signal="pressed" from="RootUI/NewGameUI/MarginContainer/VBoxContainer/MarginContainer3/HBoxContainer/BackButton" to="RootUI" method="_to_main_menu_button_pressed"]
[connection signal="pressed" from="RootUI/NewGameUI/MarginContainer/VBoxContainer/MarginContainer3/HBoxContainer/StartGameButton" to="RootUI" method="_on_start_game_button_pressed"]
[connection signal="pressed" from="RootUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer3/BackToGameButton" to="RootUI" method="_on_start_game_button_pressed"]
[connection signal="pressed" from="RootUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer5/ToMainMenuButton" to="RootUI" method="_to_main_menu_button_pressed"]
[connection signal="timeout" from="RootUI/GameUI/MessagesContainer/MessageTimer" to="RootUI/GameUI" method="_on_message_timer_timeout"]
[connection signal="pressed" from="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/Title/CloseButton" to="RootUI/GameUI/InventoryDialog" method="_on_close_button_pressed"]
[connection signal="item_selected" from="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/Recipes/RecipeList" to="RootUI/GameUI/InventoryDialog" method="_on_recipe_list_item_selected"]
[connection signal="pressed" from="RootUI/GameUI/InventoryDialog/Panel/PanelContainer/CraftingUI/HBoxContainer/CraftResult/HBoxContainer/CraftButton" to="RootUI/GameUI/InventoryDialog" method="_on_craft_button_pressed"]
[connection signal="pressed" from="RootUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer3/BackToGameButton" to="RootUI" method="_on_start_game_button_pressed"]
[connection signal="pressed" from="RootUI/GameMenuUI/MarginContainer/VBoxContainer/MarginContainer5/ToMainMenuButton" to="RootUI" method="_to_main_menu_button_pressed"]

View File

@ -1,11 +1,6 @@
extends Control
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func _on_message_timer_timeout():
%MessagesContainer.visible = false

View File

@ -5,12 +5,13 @@ const JUMP_VELOCITY = 2.5
@onready var geometry = %Geometry
@onready var actionable_detector = %ActionableDetector
@onready var quest_state = %QuestState
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
var inventory:Inventory = Inventory.new()
var last_nonzero_velocity:Vector3 = Vector3.ZERO
var last_nonzero_velocity:Vector3 = Vector3.BACK
signal trigger_message(message:String)
@ -32,18 +33,29 @@ func _physics_process(delta):
move_and_slide()
if velocity.length_squared() > 0.1 * 0.1:
last_nonzero_velocity = velocity.normalized()
geometry.look_at(position - last_nonzero_velocity)
var ground_velocity:Vector2 = Vector2(velocity.x, velocity.z)
if ground_velocity.length_squared() > 0.1 * 0.1:
last_nonzero_velocity = Vector3(ground_velocity.x, 0, ground_velocity.y).normalized()
geometry.look_at(position - last_nonzero_velocity, Vector3.UP)
func update_quest_state() -> void:
for item:Item in inventory.get_items():
if item.name == "Wrench":
quest_state.has_wrench = true
func on_item_picked_up(item:Item):
inventory.add_item(item)
emit_signal("trigger_message", "Picked up a " + item.name)
inventory.add_item(item)
update_quest_state()
func _unhandled_input(_event: InputEvent) -> void:
if Input.is_action_just_pressed("ui_accept"):
var actionables = actionable_detector.get_overlapping_areas()
if actionables.size() > 0:
actionables[0].action()
actionables[0].action(quest_state)

View File

@ -17,6 +17,7 @@ func _ready():
_all_recipes.append(recipe)
activate_ui_panel(%GameUI)
# activate_ui_panel(%MainMenuUI)
func activate_ui_panel(ui_panel:Control):

View File

@ -16,4 +16,4 @@ visible = false
transform = Transform3D(1, -2.20965e-22, 8.47033e-22, 2.20965e-22, 1, 0, -8.47033e-22, 0, 1, 2.01948e-28, 1.21587, -1.82921e-07)
[node name="Engineer_Backpack" parent="Rig/Skeleton3D" index="3"]
transform = Transform3D(1, 1.25214e-21, -1.69407e-21, -1.25214e-21, 1, 0, 1.69407e-21, 0, 1, -3.05176e-05, 1.21587, -1.82921e-07)
transform = Transform3D(1, 1.25214e-21, -1.69407e-21, -1.25214e-21, 1, 7.17465e-43, 1.69407e-21, 1.43493e-42, 1, -3.05176e-05, 1.21587, -1.82921e-07)

View File

@ -39,24 +39,24 @@ bones/46/position = Vector3(-0.510844, 0.788312, 0.0597369)
bones/46/rotation = Quaternion(-0.758253, -1.52737e-07, 0.651961, -1.11759e-08)
[node name="Knife_Offhand" parent="Rig/Skeleton3D" index="0"]
transform = Transform3D(4.18024e-07, 0.262863, 0.964832, 0.999999, -3.99356e-07, -9.13908e-08, 4.9995e-07, 0.964833, -0.262863, 0.507764, 0.636705, -0.0185362)
transform = Transform3D(9.17323e-08, 0.262865, 0.964832, 0.999999, -5.48367e-07, 4.74853e-07, 8.68286e-07, 0.964832, -0.262865, 0.507764, 0.636705, -0.0185365)
visible = false
[node name="1H_Crossbow" parent="Rig/Skeleton3D" index="1"]
transform = Transform3D(0.988701, -0.149895, 4.88869e-07, 1.74261e-07, -3.68729e-07, -0.999999, 0.149895, 0.988701, -6.19239e-07, -0.489506, 0.745658, 0.096339)
transform = Transform3D(0.988701, -0.149894, -4.17134e-07, -8.6882e-07, -1.08398e-06, -0.999999, 0.149894, 0.988702, -1.49706e-06, -0.489506, 0.745658, 0.096339)
visible = false
[node name="2H_Crossbow" parent="Rig/Skeleton3D" index="2"]
transform = Transform3D(0.988701, -0.149895, 4.88869e-07, 1.74261e-07, -3.68729e-07, -0.999999, 0.149895, 0.988701, -6.19239e-07, -0.489506, 0.745658, 0.096339)
transform = Transform3D(0.988701, -0.149894, -4.17134e-07, -8.6882e-07, -1.08398e-06, -0.999999, 0.149894, 0.988702, -1.49706e-06, -0.489506, 0.745658, 0.096339)
visible = false
[node name="Knife" parent="Rig/Skeleton3D" index="3"]
transform = Transform3D(-4.8469e-07, -0.149894, 0.988701, 0.999999, -2.20542e-07, 1.925e-07, 4.69992e-07, 0.988701, 0.149894, -0.491058, 0.64103, 0.10658)
transform = Transform3D(4.21314e-07, -0.149893, 0.988701, 0.999999, -9.35798e-07, -8.50581e-07, 1.34781e-06, 0.988702, 0.149894, -0.491058, 0.64103, 0.10658)
visible = false
[node name="Throwable" parent="Rig/Skeleton3D" index="4"]
transform = Transform3D(-4.6895e-07, -0.149894, 0.988701, 0.999999, -2.05809e-07, 1.78814e-07, 4.57477e-07, 0.988701, 0.149894, -0.518076, 0.64103, 0.28479)
transform = Transform3D(4.37053e-07, -0.149894, 0.988701, 0.999999, -9.21064e-07, -8.64267e-07, 1.3353e-06, 0.988702, 0.149894, -0.518076, 0.64103, 0.28479)
visible = false
[node name="Rogue_Cape" parent="Rig/Skeleton3D" index="5"]
transform = Transform3D(0.996275, -5.14962e-09, 0.0862353, 5.13043e-09, 1, 4.44077e-10, -0.0862353, 1.8939e-15, 0.996275, -4.17227e-09, 1.20227, 1.53446e-15)
transform = Transform3D(0.996275, -5.14962e-09, 0.0862354, 5.13044e-09, 1, 4.44078e-10, -0.0862354, 1.47756e-15, 0.996275, -4.17227e-09, 1.20227, 1.19714e-15)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -5,4 +5,4 @@
[node name="PickaxeScene" type="Node3D"]
[node name="tool-pickaxe2" parent="." instance=ExtResource("1_ohrc6")]
transform = Transform3D(0.731247, 0.681981, -0.01344, 0, 0.0197035, 0.999806, 0.682113, -0.731105, 0.0144081, -0.0977044, 0.0424874, 0.0943838)
transform = Transform3D(0.731247, 0.681981, -0.01344, 0, 0.0197035, 0.999806, 0.682113, -0.731105, 0.0144081, -0.098, 0.0115309, 0.094)

BIN
assets/tools/Wrench.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bfvn4i4ftg4bu"
path="res://.godot/imported/Wrench.png-341b9f4923257057e101740c7eeb164e.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/tools/Wrench.png"
dest_files=["res://.godot/imported/Wrench.png-341b9f4923257057e101740c7eeb164e.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

48
assets/tools/Wrench.tscn Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bhrc500fm5mq"
path="res://.godot/imported/Wrench_64x64.png-c657f6eb85d7e557e66d342bf98a0570.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/tools/Wrench_64x64.png"
dest_files=["res://.godot/imported/Wrench_64x64.png-c657f6eb85d7e557e66d342bf98a0570.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

12
data/items/wrench.tres Normal file
View File

@ -0,0 +1,12 @@
[gd_resource type="Resource" script_class="Item" load_steps=4 format=3 uid="uid://egkatj1ci0ga"]
[ext_resource type="Texture2D" uid="uid://bfvn4i4ftg4bu" path="res://assets/tools/Wrench.png" id="1_b5epx"]
[ext_resource type="PackedScene" uid="uid://cum7lrtovcvk3" path="res://assets/tools/Wrench.tscn" id="2_8uss6"]
[ext_resource type="Script" path="res://model/item.gd" id="3_gt0gt"]
[resource]
resource_name = "Pickaxe"
script = ExtResource("3_gt0gt")
name = "Wrench"
scene = ExtResource("2_8uss6")
icon = ExtResource("1_b5epx")

View File

@ -1,12 +1,18 @@
~ start
Chloe: Mist! Ich habe meinen Hammer verlegt. Irgendwo in der Nähe des Strands.
Chloe: Kannst Du mir helfen?
- Klar!
Chloe: Vielen Dank!
Chloe: Mist! Ohne meinen Hammer kann ich die Brücke nicht fertig bauen!
Chloe: Hast Du meinen Hammer gesehen?
- Ja!
if has_wrench == false:
Chloe: Du scheinst keinen Hammer zu haben. Oder weißt nicht was ein Hammer ist.
else:av
Chloe: Danke!
set bridge_built_by_engineer = true
- Lieber nicht.
Chloe: Schade!
- Wo ist der Strand?
Chloe: Weiter im Osten. Wenn Du ein paar Schritte gehst hörst Du schon die Möwen.viva
- Wo kann er denn sein?
Chloe: Vielleicht habe ich ihn beim Strand verloren.
=> END

5
model/quest_state.gd Normal file
View File

@ -0,0 +1,5 @@
class_name QuestState
extends Node
@export var has_wrench:bool = false
@export var bridge_built_by_engineer:bool = false

View File

@ -1,7 +0,0 @@
extends Area3D
@export var dialogue_resource: DialogueResource
@export var dialogue_start: String = "start"
func action() -> void:
DialogueManager.show_example_dialogue_balloon(dialogue_resource, dialogue_start)

View File

@ -1,6 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://dhpc2xvlfln7o"]
[ext_resource type="Script" path="res://objects/Actionable.gd" id="1_qvxan"]
[ext_resource type="Script" path="res://objects/actionable.gd" id="1_qvxan"]
[node name="Actionable" type="Area3D"]
collision_layer = 16

View File

@ -1,6 +1,6 @@
[gd_scene load_steps=4 format=3 uid="uid://da5r82nvypfk4"]
[ext_resource type="Script" path="res://pickup_item.gd" id="1_ec7o8"]
[ext_resource type="Script" path="res://objects/pickup_item.gd" id="1_1i8k2"]
[ext_resource type="Resource" uid="uid://dmjr6pmb17l2y" path="res://data/items/woodplanks.tres" id="2_dph0g"]
[sub_resource type="CylinderShape3D" id="CylinderShape3D_1ndog"]
@ -9,7 +9,7 @@ radius = 0.15682
[node name="Item" type="Node3D"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.00393829, 0)
script = ExtResource("1_ec7o8")
script = ExtResource("1_1i8k2")
item = ExtResource("2_dph0g")
[node name="Area3D" type="Area3D" parent="."]

9
objects/actionable.gd Normal file
View File

@ -0,0 +1,9 @@
extends Area3D
@export var dialogue_resource: DialogueResource
@export var dialogue_start: String = "start"
func action(game_state: QuestState) -> void:
var balloon = load("res://ui/dialogue/balloon.tscn").instantiate()
get_tree().current_scene.add_child(balloon)
balloon.start(dialogue_resource, dialogue_start, [game_state])

View File

@ -19,6 +19,10 @@ config/icon="res://icon.svg"
DialogueManager="*res://addons/dialogue_manager/dialogue_manager.gd"
[dialogue_manager]
general/balloon_path="res://ui/dialogue/balloon.tscn"
[dotnet]
project/assembly_name="UIAndInteractionTests"

153
ui/dialogue/balloon.gd Normal file
View File

@ -0,0 +1,153 @@
extends CanvasLayer
## The action to use for advancing the dialogue
@export var next_action: StringName = &"ui_accept"
## The action to use to skip typing the dialogue
@export var skip_action: StringName = &"ui_cancel"
@onready var balloon: Control = %Balloon
@onready var character_label: RichTextLabel = %CharacterLabel
@onready var dialogue_label: DialogueLabel = %DialogueLabel
@onready var responses_menu: DialogueResponsesMenu = %ResponsesMenu
## The dialogue resource
var resource: DialogueResource
## Temporary game states
var temporary_game_states: Array = []
## See if we are waiting for the player
var is_waiting_for_input: bool = false
## See if we are running a long mutation and should hide the balloon
var will_hide_balloon: bool = false
## The current line
var dialogue_line: DialogueLine:
set(next_dialogue_line):
is_waiting_for_input = false
balloon.focus_mode = Control.FOCUS_ALL
balloon.grab_focus()
# The dialogue has finished so close the balloon
if not next_dialogue_line:
queue_free()
return
# If the node isn't ready yet then none of the labels will be ready yet either
if not is_node_ready():
await ready
dialogue_line = next_dialogue_line
character_label.visible = not dialogue_line.character.is_empty()
character_label.text = tr(dialogue_line.character, "dialogue")
dialogue_label.hide()
dialogue_label.dialogue_line = dialogue_line
responses_menu.hide()
responses_menu.set_responses(dialogue_line.responses)
# Show our balloon
balloon.show()
will_hide_balloon = false
dialogue_label.show()
if not dialogue_line.text.is_empty():
dialogue_label.type_out()
await dialogue_label.finished_typing
# Wait for input
if dialogue_line.responses.size() > 0:
balloon.focus_mode = Control.FOCUS_NONE
responses_menu.show()
elif dialogue_line.time != "":
var time = dialogue_line.text.length() * 0.02 if dialogue_line.time == "auto" else dialogue_line.time.to_float()
await get_tree().create_timer(time).timeout
next(dialogue_line.next_id)
else:
is_waiting_for_input = true
balloon.focus_mode = Control.FOCUS_ALL
balloon.grab_focus()
get:
return dialogue_line
func _ready() -> void:
balloon.hide()
Engine.get_singleton("DialogueManager").mutated.connect(_on_mutated)
# If the responses menu doesn't have a next action set, use this one
if responses_menu.next_action.is_empty():
responses_menu.next_action = next_action
func _unhandled_input(_event: InputEvent) -> void:
# Only the balloon is allowed to handle input while it's showing
get_viewport().set_input_as_handled()
func _notification(what: int) -> void:
# Detect a change of locale and update the current dialogue line to show the new language
if what == NOTIFICATION_TRANSLATION_CHANGED and is_instance_valid(dialogue_label):
var visible_ratio = dialogue_label.visible_ratio
self.dialogue_line = await resource.get_next_dialogue_line(dialogue_line.id)
if visible_ratio < 1:
dialogue_label.skip_typing()
## Start some dialogue
func start(dialogue_resource: DialogueResource, title: String, extra_game_states: Array = []) -> void:
temporary_game_states = [self] + extra_game_states
is_waiting_for_input = false
resource = dialogue_resource
self.dialogue_line = await resource.get_next_dialogue_line(title, temporary_game_states)
## Go to the next line
func next(next_id: String) -> void:
self.dialogue_line = await resource.get_next_dialogue_line(next_id, temporary_game_states)
#region Signals
func _on_mutated(_mutation: Dictionary) -> void:
is_waiting_for_input = false
will_hide_balloon = true
get_tree().create_timer(0.1).timeout.connect(func():
if will_hide_balloon:
will_hide_balloon = false
balloon.hide()
)
func _on_balloon_gui_input(event: InputEvent) -> void:
# See if we need to skip typing of the dialogue
if dialogue_label.is_typing:
var mouse_was_clicked: bool = event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.is_pressed()
var skip_button_was_pressed: bool = event.is_action_pressed(skip_action)
if mouse_was_clicked or skip_button_was_pressed:
get_viewport().set_input_as_handled()
dialogue_label.skip_typing()
return
if not is_waiting_for_input: return
if dialogue_line.responses.size() > 0: return
# When there are no response options the balloon itself is the clickable thing
get_viewport().set_input_as_handled()
if event is InputEventMouseButton and event.is_pressed() and event.button_index == MOUSE_BUTTON_LEFT:
next(dialogue_line.next_id)
elif event.is_action_pressed(next_action) and get_viewport().gui_get_focus_owner() == balloon:
next(dialogue_line.next_id)
func _on_responses_menu_response_selected(response: DialogueResponse) -> void:
next(response.next_id)
#endregion

91
ui/dialogue/balloon.tscn Normal file
View File

@ -0,0 +1,91 @@
[gd_scene load_steps=5 format=3 uid="uid://73jm5qjy52vq"]
[ext_resource type="Script" path="res://ui/dialogue/balloon.gd" id="1_36de5"]
[ext_resource type="PackedScene" uid="uid://ckvgyvclnwggo" path="res://addons/dialogue_manager/dialogue_label.tscn" id="2_a8ve6"]
[ext_resource type="Theme" uid="uid://dmk7hc81l8gbw" path="res://ui/ui_theme.tres" id="2_uj536"]
[ext_resource type="Script" path="res://addons/dialogue_manager/dialogue_reponses_menu.gd" id="3_72ixx"]
[node name="ExampleBalloon" type="CanvasLayer"]
layer = 100
script = ExtResource("1_36de5")
[node name="Balloon" type="Control" parent="."]
unique_name_in_owner = true
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("2_uj536")
[node name="Panel" type="Panel" parent="Balloon"]
clip_children = 2
layout_mode = 1
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 21.0
offset_top = -183.0
offset_right = -19.0
offset_bottom = -19.0
grow_horizontal = 2
grow_vertical = 0
mouse_filter = 1
[node name="Dialogue" type="MarginContainer" parent="Balloon/Panel"]
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="Balloon/Panel/Dialogue"]
layout_mode = 2
[node name="CharacterLabel" type="RichTextLabel" parent="Balloon/Panel/Dialogue/VBoxContainer"]
unique_name_in_owner = true
modulate = Color(1, 1, 1, 0.501961)
layout_mode = 2
mouse_filter = 1
bbcode_enabled = true
text = "Character"
fit_content = true
scroll_active = false
[node name="DialogueLabel" parent="Balloon/Panel/Dialogue/VBoxContainer" instance=ExtResource("2_a8ve6")]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
text = "Dialogue..."
[node name="Responses" type="MarginContainer" parent="Balloon"]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -147.0
offset_top = -558.0
offset_right = 494.0
offset_bottom = -154.0
grow_horizontal = 2
grow_vertical = 0
[node name="ResponsesMenu" type="VBoxContainer" parent="Balloon/Responses" node_paths=PackedStringArray("response_template")]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 8
theme_override_constants/separation = 2
script = ExtResource("3_72ixx")
response_template = NodePath("ResponseExample")
[node name="ResponseExample" type="Button" parent="Balloon/Responses/ResponsesMenu"]
layout_mode = 2
text = "Response example"
[connection signal="gui_input" from="Balloon" to="." method="_on_balloon_gui_input"]
[connection signal="response_selected" from="Balloon/Responses/ResponsesMenu" to="." method="_on_responses_menu_response_selected"]

View File

@ -4,9 +4,11 @@
[ext_resource type="Texture2D" uid="uid://ojsbkfjeu088" path="res://assets/kenney/survival-kit/Previews/toolPickaxe.png" id="1_mafu0"]
[node name="PanelContainer" type="PanelContainer"]
custom_minimum_size = Vector2(64, 64)
script = ExtResource("1_7v5l8")
[node name="TextureRect" type="TextureRect" parent="."]
unique_name_in_owner = true
layout_mode = 2
texture = ExtResource("1_mafu0")
expand_mode = 3

56
world/level.tscn Normal file
View File

@ -0,0 +1,56 @@
[gd_scene load_steps=11 format=3 uid="uid://dmagdl5pi6jdj"]
[ext_resource type="MeshLibrary" uid="uid://dcpuitbu16j1a" path="res://assets/mesh_library.tres" id="1_q0eym"]
[ext_resource type="PackedScene" uid="uid://da5r82nvypfk4" path="res://objects/PickupItem.tscn" id="2_qurr0"]
[ext_resource type="Resource" uid="uid://bn5j38jbwlj1f" path="res://data/items/stick.tres" id="3_q180r"]
[ext_resource type="PackedScene" uid="uid://dtd7p4wjaumae" path="res://assets/resources/Stick.tscn" id="4_h3618"]
[ext_resource type="Resource" uid="uid://egkatj1ci0ga" path="res://data/items/wrench.tres" id="5_tmrcc"]
[ext_resource type="Resource" uid="uid://coser1y1y5unl" path="res://data/items/door.tres" id="5_twsf3"]
[ext_resource type="PackedScene" uid="uid://ca2l61b2j3y5b" path="res://assets/tools/Pickaxe.tscn" id="6_fq3ct"]
[ext_resource type="PackedScene" uid="uid://ysfnsrvgemi6" path="res://assets/resources/WoodPlanks.tscn" id="7_2hyvg"]
[ext_resource type="Resource" uid="uid://c1ll2snhgv3m1" path="res://data/items/treelog.tres" id="8_pafka"]
[ext_resource type="PackedScene" uid="uid://bbmt7xom1j84b" path="res://assets/resources/TreeLog.tscn" id="9_51v1q"]
[node name="Level" type="Node3D"]
[node name="GridMap" type="GridMap" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.5, 0)
rotation_order = 1
mesh_library = ExtResource("1_q0eym")
cell_size = Vector3(0.5, 0.5, 0.5)
cell_center_x = false
cell_center_y = false
cell_center_z = false
data = {
"cells": PackedInt32Array(0, 0, 14, 3, 0, 14, 6, 0, 14, 0, 65533, 14, 3, 65533, 14, 0, 3, 14, 3, 3, 14, 6, 3, 14, 6, 65533, 14, 9, 65533, 14, 6, 65530, 14, 3, 65530, 14, 0, 65530, 14, 65533, 65530, 14, 65533, 65533, 14, 65533, 0, 14, 65533, 3, 14, 65545, 1, 1441801, 65545, 4, 1441801, 65545, 65530, 1441801, 65543, 65528, 9, 65540, 65528, 9, 131067, 65529, 1441801, 131067, 65532, 1441801, 131067, 65535, 1441801, 131067, 2, 1441801, 131068, 65528, 9, 65544, 5, 9, 65538, 5, 9, 131071, 5, 9, 131068, 5, 9, 131067, 3, 1441801, 12, 65533, 14, 12, 0, 14, 12, 65530, 14, 15, 65530, 14, 15, 65527, 14, 15, 65524, 14, 18, 65524, 14, 21, 65524, 14, 21, 65527, 14, 21, 65530, 14, 24, 65530, 14, 24, 65533, 14, 27, 65533, 14, 30, 65533, 14, 33, 65533, 14, 33, 65530, 14, 36, 65530, 14, 36, 65533, 14, 36, 65527, 14, 39, 65527, 14, 39, 65530, 14, 39, 65524, 14, 42, 65524, 14, 39, 65533, 14, 42, 65533, 14, 42, 65530, 14)
}
metadata/_editor_floor_ = Vector3(0, 1, 0)
[node name="Objects" type="Node3D" parent="."]
[node name="Item" parent="Objects" instance=ExtResource("2_qurr0")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.55623, 0, 0.612282)
item = ExtResource("3_q180r")
[node name="_Node3D_153923" parent="Objects/Item" instance=ExtResource("4_h3618")]
[node name="Item5" parent="Objects" instance=ExtResource("2_qurr0")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.24544, 0, -2.75085)
item = ExtResource("5_tmrcc")
[node name="Item4" parent="Objects" instance=ExtResource("2_qurr0")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.17514, -2.38419e-07, 0.574962)
item = ExtResource("5_twsf3")
[node name="_Node3D_153924" parent="Objects/Item4" instance=ExtResource("6_fq3ct")]
[node name="Item2" parent="Objects" instance=ExtResource("2_qurr0")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.978853, -2.38419e-07, -1.39068)
[node name="_Node3D_153925" parent="Objects/Item2" instance=ExtResource("7_2hyvg")]
[node name="Item3" parent="Objects" instance=ExtResource("2_qurr0")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.28455, 0, -0.204204)
item = ExtResource("8_pafka")
[node name="_Node3D_153926" parent="Objects/Item3" instance=ExtResource("9_51v1q")]