NPC interraction and dialog receiver
This commit is contained in:
parent
f17b1f7402
commit
65b0b39da3
|
|
@ -34,7 +34,7 @@ animations = [ {
|
||||||
"speed": 8.0
|
"speed": 8.0
|
||||||
}, {
|
}, {
|
||||||
"frames": [ ExtResource( 8 ), ExtResource( 19 ), ExtResource( 5 ), ExtResource( 12 ), ExtResource( 17 ), ExtResource( 12 ), ExtResource( 17 ), ExtResource( 12 ), ExtResource( 5 ), ExtResource( 19 ), ExtResource( 19 ), ExtResource( 8 ) ],
|
"frames": [ ExtResource( 8 ), ExtResource( 19 ), ExtResource( 5 ), ExtResource( 12 ), ExtResource( 17 ), ExtResource( 12 ), ExtResource( 17 ), ExtResource( 12 ), ExtResource( 5 ), ExtResource( 19 ), ExtResource( 19 ), ExtResource( 8 ) ],
|
||||||
"loop": true,
|
"loop": false,
|
||||||
"name": "draw_sword",
|
"name": "draw_sword",
|
||||||
"speed": 8.0
|
"speed": 8.0
|
||||||
}, {
|
}, {
|
||||||
|
|
|
||||||
24
src/actors/npcs/WarriorGirl/WarriorGirl.gd
Normal file
24
src/actors/npcs/WarriorGirl/WarriorGirl.gd
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
extends Actor
|
||||||
|
|
||||||
|
|
||||||
|
# Declare member variables here. Examples:
|
||||||
|
# var a = 2
|
||||||
|
# var b = "text"
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
#func _process(delta):
|
||||||
|
# pass
|
||||||
|
|
||||||
|
|
||||||
|
func _on_NPC_Dialog_body_entered(body):
|
||||||
|
movement_state_machine.change_to_known_state("draw_sword")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _on_NPC_Dialog_body_exited(body):
|
||||||
|
movement_state_machine.change_to_known_state("default")
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
[gd_scene load_steps=7 format=2]
|
[gd_scene load_steps=9 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://lib/parent_scenes/actor.tscn" type="PackedScene" id=1]
|
[ext_resource path="res://lib/parent_scenes/actor.tscn" type="PackedScene" id=1]
|
||||||
[ext_resource path="res://assets/actors/npcs/WarriorGirl/WarriorGirl.tres" type="SpriteFrames" id=2]
|
[ext_resource path="res://assets/actors/npcs/WarriorGirl/WarriorGirl.tres" type="SpriteFrames" id=2]
|
||||||
[ext_resource path="res://src/actors/npcs/default.tres" type="Resource" id=3]
|
[ext_resource path="res://src/actors/npcs/default.tres" type="Resource" id=3]
|
||||||
[ext_resource path="res://src/Interactables/interactable_npc_dialog.tscn" type="PackedScene" id=4]
|
[ext_resource path="res://src/Interactables/interactable_npc_dialog.tscn" type="PackedScene" id=4]
|
||||||
|
[ext_resource path="res://src/actors/npcs/WarriorGirl/WarriorGirl.gd" type="Script" id=5]
|
||||||
|
[ext_resource path="res://src/actors/npcs/draw_sword.tres" type="Resource" id=6]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
extents = Vector2( 9, 14 )
|
extents = Vector2( 9, 14 )
|
||||||
|
|
@ -15,10 +17,11 @@ height = 58.0
|
||||||
[node name="WarriorGirl" instance=ExtResource( 1 )]
|
[node name="WarriorGirl" instance=ExtResource( 1 )]
|
||||||
scale = Vector2( -1, 1 )
|
scale = Vector2( -1, 1 )
|
||||||
collision_layer = 0
|
collision_layer = 0
|
||||||
|
script = ExtResource( 5 )
|
||||||
actor_type = "NPC"
|
actor_type = "NPC"
|
||||||
|
|
||||||
[node name="Movement_StateMachine" parent="." index="0"]
|
[node name="Movement_StateMachine" parent="." index="0"]
|
||||||
states = [ ExtResource( 3 ) ]
|
states = [ ExtResource( 3 ), ExtResource( 6 ) ]
|
||||||
|
|
||||||
[node name="AnimatedSprite_StateReceiver" parent="." index="1"]
|
[node name="AnimatedSprite_StateReceiver" parent="." index="1"]
|
||||||
frames = ExtResource( 2 )
|
frames = ExtResource( 2 )
|
||||||
|
|
@ -29,6 +32,7 @@ position = Vector2( -5, 6 )
|
||||||
shape = SubResource( 1 )
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
[node name="NPC_Dialog" parent="." index="5" instance=ExtResource( 4 )]
|
[node name="NPC_Dialog" parent="." index="5" instance=ExtResource( 4 )]
|
||||||
|
collision_mask = 2
|
||||||
dialog_text = "Hello, I am a human."
|
dialog_text = "Hello, I am a human."
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="NPC_Dialog" index="0"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="NPC_Dialog" index="0"]
|
||||||
|
|
@ -36,3 +40,6 @@ modulate = Color( 0, 1, 0, 1 )
|
||||||
position = Vector2( -5, 6 )
|
position = Vector2( -5, 6 )
|
||||||
rotation = 1.5708
|
rotation = 1.5708
|
||||||
shape = SubResource( 2 )
|
shape = SubResource( 2 )
|
||||||
|
|
||||||
|
[connection signal="body_entered" from="NPC_Dialog" to="." method="_on_NPC_Dialog_body_entered"]
|
||||||
|
[connection signal="body_exited" from="NPC_Dialog" to="." method="_on_NPC_Dialog_body_exited"]
|
||||||
|
|
|
||||||
29
src/actors/npcs/draw_sword.tres
Normal file
29
src/actors/npcs/draw_sword.tres
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
[gd_resource type="Resource" load_steps=2 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://lib/classes/state_animated_actor.gd" type="Script" id=1]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
debug_state = false
|
||||||
|
timeout_seconds = 0.0
|
||||||
|
name = "draw_sword"
|
||||||
|
speed_start = Vector2( 1.36422e-12, 1.36422e-12 )
|
||||||
|
speed_end = Vector2( 0, 1000 )
|
||||||
|
min_acceleration = Vector2( 0, 0 )
|
||||||
|
acceleration = Vector2( 0, 280 )
|
||||||
|
max_acceleration = Vector2( 0, 0 )
|
||||||
|
jerk_factor = Vector2( 1, 1 )
|
||||||
|
horizontal_speed = 1.36422e-12
|
||||||
|
horizontal_acceleration = 300.0
|
||||||
|
horizontal_speed_offset = 0.0
|
||||||
|
horizontal_speed_offset_acceleration = 0.0
|
||||||
|
vertical_speed = 0.0
|
||||||
|
vertical_acceleration = 0.0
|
||||||
|
vertical_speed_offset = 0.0
|
||||||
|
vertical_speed_offset_acceleration = 0.0
|
||||||
|
horizontal_jerk_factor = 1.0
|
||||||
|
vertical_jerk_factor = 1.0
|
||||||
|
preserve_inertia = true
|
||||||
|
is_grounded = true
|
||||||
|
animation_sequence = [ "draw_sword", "default" ]
|
||||||
|
|
@ -144,6 +144,9 @@ func touch_the_thing(the_thing: Interactable) -> bool:
|
||||||
player_inventory.add_to_inventory(the_thing.item, the_thing.count)
|
player_inventory.add_to_inventory(the_thing.item, the_thing.count)
|
||||||
#player_inventory.select_secondary(the_thing.item)
|
#player_inventory.select_secondary(the_thing.item)
|
||||||
the_thing.trigger_interaction()
|
the_thing.trigger_interaction()
|
||||||
|
if the_thing is Interactable_NPC_Dialog:
|
||||||
|
## Get this to the UI mananger
|
||||||
|
print("NPC wants to say: ",the_thing.dialog_text)
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user