diff --git a/prefabs/Day1Cutscene.tscn b/prefabs/Day1Cutscene.tscn index c406c64..597be39 100644 --- a/prefabs/Day1Cutscene.tscn +++ b/prefabs/Day1Cutscene.tscn @@ -1,12 +1,20 @@ -[gd_scene load_steps=6 format=3 uid="uid://ca2cali2s1y6x"] +[gd_scene load_steps=9 format=3 uid="uid://ca2cali2s1y6x"] [ext_resource type="SpriteFrames" uid="uid://bwssm27bm14s7" path="res://resources/sprites/npcs/captain.tres" id="1_pra77"] [ext_resource type="Script" path="res://scripts/Day1Cutscene.cs" id="1_ryay5"] [ext_resource type="PackedScene" uid="uid://c5ndo6b0unkst" path="res://prefabs/NPC.tscn" id="3_c46dh"] [ext_resource type="AudioStream" uid="uid://dtbu8f2sp1lql" path="res://resources/sounds/spook8.wav" id="4_dfp4a"] +[ext_resource type="AudioStream" uid="uid://cb0344er3onkq" path="res://resources/sounds/door/doorOpen_1.ogg" id="5_2n8ga"] +[ext_resource type="AudioStream" uid="uid://87caolv1uksk" path="res://resources/sounds/door/doorClose_3.ogg" id="6_6tavv"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_yoe65"] -size = Vector2(53, 20) +size = Vector2(23, 20) + +[sub_resource type="AudioStreamPlaylist" id="AudioStreamPlaylist_ruuga"] +loop = false +stream_count = 2 +stream_0 = ExtResource("5_2n8ga") +stream_1 = ExtResource("6_6tavv") [node name="Day1Cutscene" type="Node2D"] script = ExtResource("1_ryay5") @@ -17,7 +25,7 @@ sprite_frames = ExtResource("1_pra77") [node name="Area2D" type="Area2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] -position = Vector2(-16.5, 0) +position = Vector2(-1.5, 0) shape = SubResource("RectangleShape2D_yoe65") [node name="NPC1" parent="." instance=ExtResource("3_c46dh")] @@ -34,4 +42,13 @@ DialogLines = ["...", "Quite intresting", "Process this signal on main computer" stream = ExtResource("4_dfp4a") bus = &"Spook" +[node name="DoorSounds" type="AudioStreamPlayer" parent="."] +stream = SubResource("AudioStreamPlaylist_ruuga") +volume_db = -10.0 +bus = &"Sound" + [connection signal="body_entered" from="Area2D" to="." method="Stage1"] +[connection signal="DialogEnded" from="NPC1" to="." method="Stage2"] +[connection signal="DialogEnded" from="NPC2" to="." method="Stage4"] +[connection signal="finished" from="Spook" to="." method="Stage3"] +[connection signal="finished" from="DoorSounds" to="." method="Final"] diff --git a/prefabs/Door.tscn b/prefabs/Door.tscn index 74d269d..6df7b64 100644 --- a/prefabs/Door.tscn +++ b/prefabs/Door.tscn @@ -8,7 +8,7 @@ script = ExtResource("1_nwv7e") [node name="Interactable" parent="." instance=ExtResource("1_yb42q")] SpriteOffset = Vector2(0, -40) -AreaRadius = 20.0 +AreaRadius = 5.0 [connection signal="PlayerLeft" from="Interactable" to="." method="_on_interactable_player_left"] [connection signal="PlayerNearBy" from="Interactable" to="." method="_on_interactable_player_near_by"] diff --git a/prefabs/Interactable.tscn b/prefabs/Interactable.tscn index 3de7c11..8182843 100644 --- a/prefabs/Interactable.tscn +++ b/prefabs/Interactable.tscn @@ -3,19 +3,19 @@ [ext_resource type="Script" path="res://scripts/Interactable.cs" id="1_4ni08"] [ext_resource type="SpriteFrames" uid="uid://bvnfvjn7am8tc" path="res://resources/sprites/key.tres" id="2_0s1fq"] -[sub_resource type="CircleShape2D" id="CircleShape2D_w4p6k"] +[sub_resource type="CircleShape2D" id="CircleShape2D_t3l22"] radius = 0.0 [node name="Interactable" type="Node2D"] script = ExtResource("1_4ni08") -IsEnabled = true [node name="Area2D" type="Area2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] -shape = SubResource("CircleShape2D_w4p6k") +shape = SubResource("CircleShape2D_t3l22") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +visible = false scale = Vector2(0.5, 0.5) sprite_frames = ExtResource("2_0s1fq") autoplay = "default" diff --git a/scenes/Day1.tscn b/scenes/Day1.tscn index 6e781df..0bc8d49 100644 --- a/scenes/Day1.tscn +++ b/scenes/Day1.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=26 format=3 uid="uid://c1abgp6quvo3o"] +[gd_scene load_steps=27 format=3 uid="uid://c1abgp6quvo3o"] [ext_resource type="Texture2D" uid="uid://b5baxx5o21qy1" path="res://resources/sprites/Sub/Sub.png" id="1_a6v5r"] [ext_resource type="Script" path="res://scripts/Day.cs" id="1_cko08"] @@ -13,6 +13,7 @@ [ext_resource type="SpriteFrames" uid="uid://wu7pmuvjw5qm" path="res://resources/sprites/npcs/Empty.tres" id="10_medl6"] [ext_resource type="AudioStream" uid="uid://cw6y35jglsn1" path="res://resources/sounds/nightmares/D1nm.wav" id="12_jjnbw"] [ext_resource type="PackedScene" uid="uid://x6pqolxtgwvy" path="res://prefabs/Interactable.tscn" id="12_p32yk"] +[ext_resource type="PackedScene" uid="uid://ca2cali2s1y6x" path="res://prefabs/Day1Cutscene.tscn" id="14_t3ylj"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_h0540"] size = Vector2(640, 24) @@ -167,13 +168,8 @@ Exit = NodePath("../Door_SONAR2") position = Vector2(1179, 14) Exit = NodePath("../Door_SONAR") -[node name="Door_QUOTERS" parent="Doors" node_paths=PackedStringArray("Exit") instance=ExtResource("2_qedp5")] +[node name="Door_QUOTERS" parent="Doors" instance=ExtResource("2_qedp5")] position = Vector2(1436, 134) -Exit = NodePath("../Door_QUOTERS2") - -[node name="Door_QUOTERS2" parent="Doors" node_paths=PackedStringArray("Exit") instance=ExtResource("2_qedp5")] -position = Vector2(1442, 255) -Exit = NodePath("../Door_QUOTERS") [node name="Door_ENGINE" parent="Doors" node_paths=PackedStringArray("Exit") instance=ExtResource("2_qedp5")] position = Vector2(91, 134) @@ -191,6 +187,10 @@ Exit = NodePath("../Door_CAPTAIN2") position = Vector2(1019, -258) Exit = NodePath("../Door_CAPTAIN") +[node name="Door_QUOTERS2" parent="Doors" node_paths=PackedStringArray("Exit") instance=ExtResource("2_qedp5")] +position = Vector2(1442, 255) +Exit = NodePath("../Door_QUOTERS") + [node name="NPCs" type="Node2D" parent="."] [node name="Cook" parent="NPCs" instance=ExtResource("3_t4e54")] @@ -266,6 +266,9 @@ position = Vector2(985, 245) SpriteOffset = Vector2(0, -30) AreaRadius = 20.0 +[node name="Day1Cutscene" parent="." instance=ExtResource("14_t3ylj")] +position = Vector2(1275, 18) + [connection signal="DialogEnded" from="NPCs/Ivan" to="." method="EnableEndDay"] [connection signal="finished" from="Nightmare" to="." method="ChangeScene"] [connection signal="OnInteract" from="EndDay" to="." method="ChangeDay"] diff --git a/scripts/Day1Cutscene.cs b/scripts/Day1Cutscene.cs index 3aca061..f822087 100644 --- a/scripts/Day1Cutscene.cs +++ b/scripts/Day1Cutscene.cs @@ -5,24 +5,59 @@ public partial class Day1Cutscene : Node2D { private Player _player; + private AnimatedSprite2D _sprite; + private NPC _npc1; private NPC _npc2; private AudioStreamPlayer _spook; + private AudioStreamPlayer _doorSounds; + + private bool _stage4 = false; + + private double _captainLeaveTime = 0; + + private Vector2 _spriteInitialPosition; // Called when the node enters the scene tree for the first time. public override void _Ready() { + _sprite = (AnimatedSprite2D)FindChild("AnimatedSprite2D"); _npc1 = (NPC)FindChild("NPC1"); _npc2 = (NPC)FindChild("NPC2"); _spook = (AudioStreamPlayer)FindChild("Spook"); + _doorSounds = (AudioStreamPlayer)FindChild("DoorSounds"); + _spriteInitialPosition = _sprite.GlobalPosition; } // Called every frame. 'delta' is the elapsed time since the previous frame. public override void _Process(double delta) { + if (_stage4) + { + if (_captainLeaveTime <= 3) + { + if (_sprite.Animation == "default") _sprite.Play("walk"); + _captainLeaveTime += delta; + _sprite.GlobalPosition = + _spriteInitialPosition.Lerp(new Vector2(1179, _sprite.GlobalPosition.Y), (float)(_captainLeaveTime / 3)); + } + else + { + _stage4 = false; + _sprite.Visible = false; + _doorSounds.Play(); + } + + } } + public void Final() + { + _player.CurrentState = Player.State.Normal; + QueueFree(); + } + public void Stage1(Node2D body) { if (body is Player player) @@ -30,6 +65,7 @@ public partial class Day1Cutscene : Node2D _player = player; player.InteractableObjects.Add(_npc1); player.CurrentState = Player.State.ChatWithNPC; + player.AddMessage(_npc1); } } @@ -37,14 +73,23 @@ public partial class Day1Cutscene : Node2D { _player.CurrentState = Player.State.Wait; _player.InteractableObjects.Remove(_npc1); - AudioServer.SetBusVolumeDb(0, -20); + AudioServer.SetBusVolumeDb(1, -20); _spook.Play(); _player.InteractableObjects.Add(_npc2); } public void Stage3() { - AudioServer.SetBusVolumeDb(0, 0); + _sprite.FlipH = true; + AudioServer.SetBusVolumeDb(1, 0); _player.CurrentState = Player.State.ChatWithNPC; + _player.AddMessage(_npc2); + } + + public void Stage4() + { + _player.InteractableObjects.Remove(_npc2); + _stage4 = true; + _player.CurrentState = Player.State.Wait; } } diff --git a/scripts/Interactable.cs b/scripts/Interactable.cs index a095616..15526db 100644 --- a/scripts/Interactable.cs +++ b/scripts/Interactable.cs @@ -1,7 +1,7 @@ using Godot; using System; -[Tool] +// [Tool] public partial class Interactable : Node2D { private const double Tolerance = 1e-6; @@ -34,24 +34,24 @@ public partial class Interactable : Node2D _sprite.Position = SpriteOffset; _collisionCircle = (CircleShape2D)_areaMesh.Shape; _collisionCircle.Radius = AreaRadius; - if (Engine.IsEditorHint()) - { - _sprite.Visible = true; - } - else - { - _sprite.Visible = false; - } + // if (Engine.IsEditorHint()) + // { + // _sprite.Visible = true; + // } + // else + // { + // _sprite.Visible = false; + // } } // Called every frame. 'delta' is the elapsed time since the previous frame. public override void _Process(double delta) { - if (Engine.IsEditorHint()) - { - if (_sprite.Position != SpriteOffset) _sprite.Position = SpriteOffset; - if (Math.Abs(_collisionCircle.Radius - AreaRadius) > Tolerance) _collisionCircle.Radius = AreaRadius; - } + // if (Engine.IsEditorHint()) + // { + // if (_sprite.Position != SpriteOffset) _sprite.Position = SpriteOffset; + // if (Math.Abs(_collisionCircle.Radius - AreaRadius) > Tolerance) _collisionCircle.Radius = AreaRadius; + // } } public void Interact() diff --git a/scripts/NPC.cs b/scripts/NPC.cs index 0b48e5f..514642d 100644 --- a/scripts/NPC.cs +++ b/scripts/NPC.cs @@ -2,7 +2,7 @@ using Godot; using System; using Godot.Collections; -[Tool] +// [Tool] public partial class NPC : Node2D { [Signal] diff --git a/scripts/Player.cs b/scripts/Player.cs index 74f8a59..1040305 100644 --- a/scripts/Player.cs +++ b/scripts/Player.cs @@ -35,6 +35,7 @@ public partial class Player : CharacterBody2D Visible = false; break; case State.ReadChat: + if (CurrentState == State.Wait) return; _nextLabel.Visible = false; _exitLabel.Visible = true; _chatLogContainer.CurrentState = ChatLogContainer.ChatState.Default; @@ -212,21 +213,23 @@ public partial class Player : CharacterBody2D } } + + public void AddMessage(NPC npc) + { + var msg = _dialogBox.Instantiate(); + msg.Text = npc.Message; + msg.Author = npc.NPCName; + _chatLogContainer.AddChild(msg); + _chatLogContainer.CurrentState = ChatLogContainer.ChatState.Default; + if (npc.IsDialogEnded) CurrentState = State.ReadChat; + } + public override void _Input(InputEvent @event) { if (@event.IsActionPressed("Interact")) { if (InteractableObject is NPC npc) { - void AddMessage() - { - var msg = _dialogBox.Instantiate(); - msg.Text = npc.Message; - msg.Author = npc.NPCName; - _chatLogContainer.AddChild(msg); - _chatLogContainer.CurrentState = ChatLogContainer.ChatState.Default; - if (npc.IsDialogEnded) CurrentState = State.ReadChat; - } switch (CurrentState) { @@ -243,10 +246,10 @@ public partial class Player : CharacterBody2D _sprite.FlipH = false; } CurrentState = State.ChatWithNPC; - AddMessage(); + AddMessage(npc); break; case State.ChatWithNPC: - AddMessage(); + AddMessage(npc); break; } }