began the dialog system
This commit is contained in:
7
dialog/main.json
Normal file
7
dialog/main.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"cupcake":[
|
||||
"this is a test string...",
|
||||
"It looks delicious!",
|
||||
"Eat it when its an finished item!"
|
||||
]
|
||||
}
|
@@ -18,6 +18,7 @@ config/icon="res://icon.svg"
|
||||
[autoload]
|
||||
|
||||
Essential="*res://src/essential.cs"
|
||||
SignalBus="*res://src/signal_bus.cs"
|
||||
|
||||
[display]
|
||||
|
||||
@@ -80,3 +81,8 @@ hotkey_fullscreen={
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194342,"physical_keycode":0,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[layer_names]
|
||||
|
||||
2d_physics/layer_1="World"
|
||||
2d_physics/layer_2="Dialog"
|
||||
|
14
scenes/gui/dialog_object_area.tscn
Normal file
14
scenes/gui/dialog_object_area.tscn
Normal file
@@ -0,0 +1,14 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://d14pjtkh0xmrk"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/scene-scripts/gui/dialog_object_area.cs" id="1_ttc4e"]
|
||||
|
||||
[node name="dialog_area" type="Area2D"]
|
||||
process_mode = 2
|
||||
collision_layer = 0
|
||||
collision_mask = 2
|
||||
script = ExtResource("1_ttc4e")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
|
||||
[connection signal="area_entered" from="." to="." method="onAreaEntered"]
|
||||
[connection signal="area_exited" from="." to="." method="onAreaExited"]
|
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://ujfhvssvbgpg"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://ujfhvssvbgpg"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/scene-scripts/player.cs" id="1_qehox"]
|
||||
[ext_resource type="Texture2D" uid="uid://ciidukjv5k6oa" path="res://assets/textures/debug/banana.png" id="2_1l1co"]
|
||||
@@ -15,6 +15,9 @@ animations = [{
|
||||
radius = 21.0
|
||||
height = 66.0
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_f1ppa"]
|
||||
size = Vector2(108, 119)
|
||||
|
||||
[node name="player" type="CharacterBody2D"]
|
||||
script = ExtResource("1_qehox")
|
||||
|
||||
@@ -26,3 +29,11 @@ shape = SubResource("CapsuleShape2D_38v5o")
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
current = true
|
||||
|
||||
[node name="DialogInteractArea" type="Area2D" parent="."]
|
||||
collision_layer = 2
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="DialogInteractArea"]
|
||||
position = Vector2(0, -0.5)
|
||||
shape = SubResource("RectangleShape2D_f1ppa")
|
||||
|
26
src/scene-scripts/gui/dialog_object_area.cs
Normal file
26
src/scene-scripts/gui/dialog_object_area.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
public partial class dialog_object_area : Area2D
|
||||
{
|
||||
[Export]
|
||||
public string dialogKey = "";
|
||||
public bool areaActive = false;
|
||||
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
if(areaActive && @event.IsActionPressed("ui_accept"))
|
||||
{
|
||||
EmitSignal("DialogDisplayEventHandler", dialogKey);
|
||||
}
|
||||
}
|
||||
public void onAreaEntered()
|
||||
{
|
||||
areaActive = true;
|
||||
}
|
||||
public void onAreaExited()
|
||||
{
|
||||
areaActive = false;
|
||||
}
|
||||
}
|
8
src/signal_bus.cs
Normal file
8
src/signal_bus.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class signal_bus : Node
|
||||
{
|
||||
[Signal]
|
||||
public delegate void DialogDisplayEventHandler(string textKey);
|
||||
}
|
Reference in New Issue
Block a user