Add ability to hit NPCs and see different dialogue, add interrupt feature for dialogue controller singleton

This commit is contained in:
2024-09-09 17:20:54 -07:00
parent 699b4b95cf
commit fc33b07dc7
12 changed files with 489 additions and 420 deletions

View File

@@ -12,24 +12,37 @@ public partial class Npc : Node3D
[Node] public Area3D DialogueZone { get; set; } = default!;
[Node] public Area3D Hitbox { get; set; } = default!;
[Export]
public Godot.Collections.Array<Resource> DialogueOptions { get; set; } = default!;
public Resource Dialogue { get; set; } = default!;
private bool _isInDialogueZone = false;
private Node _dialogueBalloon;
private bool _isIntroductionComplete = false;
public void OnReady()
{
SetPhysicsProcess(true);
DialogueZone.BodyEntered += DialogueZone_BodyEntered;
DialogueZone.BodyExited += DialogueZone_BodyExited;
Hitbox.AreaEntered += Hitbox_AreaEntered;
}
private void Hitbox_AreaEntered(Area3D area)
{
DialogueController.ShowDialogue(Dialogue, "hit");
}
private void Hitbox_BodyEntered(Node body)
{
DialogueController.ShowDialogue(Dialogue, "hit");
}
private void DialogueZone_BodyExited(Node3D body)
{
_isInDialogueZone = false;
if (_dialogueBalloon != null)
_dialogueBalloon.QueueFree();
DialogueController.Interrupt();
}
private void DialogueZone_BodyEntered(Node3D body)
@@ -40,6 +53,14 @@ public partial class Npc : Node3D
public override void _UnhandledInput(InputEvent @event)
{
if (Input.IsActionJustPressed(GameInputs.Throw) && _isInDialogueZone)
_dialogueBalloon = DialogueManager.ShowDialogueBalloonScene(DialogueController.DialogueBalloon, DialogueOptions.First(), "introduction");
{
if (_isIntroductionComplete)
DialogueController.ShowDialogue(Dialogue, "general");
else
{
DialogueController.ShowDialogue(Dialogue, "introduction");
_isIntroductionComplete = true;
}
}
}
}

View File

@@ -1,15 +1,23 @@
[gd_scene load_steps=5 format=3 uid="uid://d4l4qutp8x40c"]
[gd_scene load_steps=7 format=3 uid="uid://d4l4qutp8x40c"]
[ext_resource type="Texture2D" uid="uid://t7fbfplu2js7" path="res://src/npc/rat/ROYAL_RAT_PRINCEP.png" id="1_0r0wh"]
[ext_resource type="Script" path="res://src/npc/Npc.cs" id="1_cpdf2"]
[ext_resource type="Resource" uid="uid://cf7ycgdiihyh" path="res://src/npc/rat/ratdialogue.dialogue" id="2_uo38w"]
[sub_resource type="CylinderShape3D" id="CylinderShape3D_wfhgc"]
radius = 2.5
radius = 3.0
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_kg3qv"]
radius = 0.837722
height = 2.8375
[sub_resource type="CylinderShape3D" id="CylinderShape3D_nwuwj"]
height = 2.24425
radius = 1.00578
[node name="NPC" type="Node3D"]
script = ExtResource("1_cpdf2")
DialogueOptions = Array[Resource]([ExtResource("2_uo38w")])
Dialogue = ExtResource("2_uo38w")
[node name="Sprite" type="Sprite3D" parent="."]
unique_name_in_owner = true
@@ -28,3 +36,19 @@ collision_mask = 2
[node name="CollisionShape3D" type="CollisionShape3D" parent="DialogueZone"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00131226, 0, -0.00723076)
shape = SubResource("CylinderShape3D_wfhgc")
[node name="Collision" type="RigidBody3D" parent="."]
collision_mask = 0
gravity_scale = 0.0
[node name="CollisionShape3D" type="CollisionShape3D" parent="Collision"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.169075, 0, 0)
shape = SubResource("CapsuleShape3D_kg3qv")
[node name="Hitbox" type="Area3D" parent="."]
unique_name_in_owner = true
collision_layer = 16
collision_mask = 16
[node name="CollisionShape3D" type="CollisionShape3D" parent="Hitbox"]
shape = SubResource("CylinderShape3D_nwuwj")

View File

@@ -7,4 +7,42 @@ Royal Rat Princep, Tekohcyo: Though it be in mind only, I am traitor to mine cou
Royal Rat Princep, Tekohcyo: Alas, the tower has rejected me, so here I reside.
Unable to return home, but unable to climb it.
=> END
=> END
~ general
% => B1
% => B2
% => B3
% => B4
% => B5
=> END
~ B1
Royal Rat Princep, Tekohcyo: It became too much to bear, imagining what secrets they spoke within the walls.
The Goddess could change their hearts…
At least, it is what I dreamed of.
=> END
~ B2
Royal Rat Princep, Tekohcyo: I knew the Tower would save me. When it showed itself to me, I felt a hope I hadnt felt since I was a child.
Though it must have been a false hope in those days. What despairs did I possibly have to define that hope by?
I was surrounded by love and play. The ideal environment for all living creatures.
=> END
~ B3
Royal Rat Princep, Tekohcyo: Though I am fearful of what my resolve could lead me to, I have yet to step foot in the audience chamber at the top.
The thousand hands of the tower have always placed me gently where I fell, where I wished, and where I appear before you...
=> END
~ B4
Royal Rat Princep, Tekohcyo: Is it my own heart that needs to change, or the subjects around me?
=> END
~ B5
Royal Rat Princep, Tekohcyo: The walls of the Tower may deceive you.
=> END
~ hit
Royal Rat Princep, Tekohcyo: I suppose in the end, any end is, relievingly, an end.
=> END