diff --git a/assets/actors/npcs/WarriorGirl/WarriorGirl.tres b/assets/actors/npcs/WarriorGirl/WarriorGirl.tres index 7921749..cde4ace 100644 --- a/assets/actors/npcs/WarriorGirl/WarriorGirl.tres +++ b/assets/actors/npcs/WarriorGirl/WarriorGirl.tres @@ -34,7 +34,7 @@ animations = [ { "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 ) ], -"loop": true, +"loop": false, "name": "draw_sword", "speed": 8.0 }, { diff --git a/src/actors/npcs/WarriorGirl/WarriorGirl.gd b/src/actors/npcs/WarriorGirl/WarriorGirl.gd new file mode 100644 index 0000000..0a5c292 --- /dev/null +++ b/src/actors/npcs/WarriorGirl/WarriorGirl.gd @@ -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") diff --git a/src/actors/npcs/WarriorGirl/WarriorGirl.tscn b/src/actors/npcs/WarriorGirl/WarriorGirl.tscn index f527567..bbb2eb4 100644 --- a/src/actors/npcs/WarriorGirl/WarriorGirl.tscn +++ b/src/actors/npcs/WarriorGirl/WarriorGirl.tscn @@ -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://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/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] extents = Vector2( 9, 14 ) @@ -15,10 +17,11 @@ height = 58.0 [node name="WarriorGirl" instance=ExtResource( 1 )] scale = Vector2( -1, 1 ) collision_layer = 0 +script = ExtResource( 5 ) actor_type = "NPC" [node name="Movement_StateMachine" parent="." index="0"] -states = [ ExtResource( 3 ) ] +states = [ ExtResource( 3 ), ExtResource( 6 ) ] [node name="AnimatedSprite_StateReceiver" parent="." index="1"] frames = ExtResource( 2 ) @@ -29,6 +32,7 @@ position = Vector2( -5, 6 ) shape = SubResource( 1 ) [node name="NPC_Dialog" parent="." index="5" instance=ExtResource( 4 )] +collision_mask = 2 dialog_text = "Hello, I am a human." [node name="CollisionShape2D" type="CollisionShape2D" parent="NPC_Dialog" index="0"] @@ -36,3 +40,6 @@ modulate = Color( 0, 1, 0, 1 ) position = Vector2( -5, 6 ) rotation = 1.5708 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"] diff --git a/src/actors/npcs/draw_sword.tres b/src/actors/npcs/draw_sword.tres new file mode 100644 index 0000000..2a01492 --- /dev/null +++ b/src/actors/npcs/draw_sword.tres @@ -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" ] diff --git a/src/actors/players/playerE/PlayerE.gd b/src/actors/players/playerE/PlayerE.gd index ee26081..0a0aa01 100644 --- a/src/actors/players/playerE/PlayerE.gd +++ b/src/actors/players/playerE/PlayerE.gd @@ -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.select_secondary(the_thing.item) 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