From 872d650b3da0d63083a0d474ffd9cffa13709342 Mon Sep 17 00:00:00 2001 From: Evgenij Titarenko Date: Sun, 25 Aug 2024 13:31:50 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=8C=20=D0=BE=D1=82=D0=BA=D0=BB=D1=8E=D1=87?= =?UTF-8?q?=D0=B0=D1=82=D1=8C=20=D0=B8=D0=BD=D1=82=D0=B5=D1=80=D0=B0=D0=BA?= =?UTF-8?q?=D1=82=D0=B8=D0=B2=D0=BD=D1=8B=D0=B5=20=D0=BE=D0=B1=D1=8A=D0=B5?= =?UTF-8?q?=D0=BA=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- prefabs/Interactable.tscn | 3 ++- scenes/Day1.tscn | 9 ++++++++- scripts/Day.cs | 7 +++++++ scripts/Interactable.cs | 15 ++++++++++++--- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/prefabs/Interactable.tscn b/prefabs/Interactable.tscn index 35d0929..3de7c11 100644 --- a/prefabs/Interactable.tscn +++ b/prefabs/Interactable.tscn @@ -4,10 +4,11 @@ [ext_resource type="SpriteFrames" uid="uid://bvnfvjn7am8tc" path="res://resources/sprites/key.tres" id="2_0s1fq"] [sub_resource type="CircleShape2D" id="CircleShape2D_w4p6k"] -radius = 60.0 +radius = 0.0 [node name="Interactable" type="Node2D"] script = ExtResource("1_4ni08") +IsEnabled = true [node name="Area2D" type="Area2D" parent="."] diff --git a/scenes/Day1.tscn b/scenes/Day1.tscn index f9d479c..de3e452 100644 --- a/scenes/Day1.tscn +++ b/scenes/Day1.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=19 format=3 uid="uid://c1abgp6quvo3o"] +[gd_scene load_steps=20 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"] @@ -10,6 +10,7 @@ [ext_resource type="SpriteFrames" uid="uid://532buo56y4q2" path="res://resources/sprites/npcs/crewmate.tres" id="7_j5wfn"] [ext_resource type="PackedScene" uid="uid://dfdsnwub212o6" path="res://prefabs/Player.tscn" id="8_csxln"] [ext_resource type="AudioStream" uid="uid://be35iuapayv0u" path="res://resources/music/Day1.wav" id="9_43nb0"] +[ext_resource type="PackedScene" uid="uid://x6pqolxtgwvy" path="res://prefabs/Interactable.tscn" id="12_p32yk"] [ext_resource type="SpriteFrames" uid="uid://wu7pmuvjw5qm" path="res://resources/sprites/npcs/Empty.tres" id="10_medl6"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_h0540"] @@ -255,4 +256,10 @@ stream = SubResource("AudioStreamPlaylist_7838k") autoplay = true bus = &"Music" +[node name="EndDay" parent="." instance=ExtResource("12_p32yk")] +position = Vector2(985, 245) +SpriteOffset = Vector2(0, -30) +AreaRadius = 20.0 +IsEnabled = false + [connection signal="DialogEnded" from="NPCs/Ivan" to="." method="ChangeDay"] diff --git a/scripts/Day.cs b/scripts/Day.cs index dc7dfc5..6f6f4a7 100644 --- a/scripts/Day.cs +++ b/scripts/Day.cs @@ -17,6 +17,7 @@ public partial class Day : Node2D private Player _player; private ColorRect _colorRect; private AudioStreamPlayer _music; + private Interactable _endDay; private double _transitionTimeout = 0; @@ -26,6 +27,7 @@ public partial class Day : Node2D _player = (Player)FindChild("Player"); _colorRect = _player.CRect; _music = (AudioStreamPlayer)FindChild("Music"); + _endDay = (Interactable)FindChild("EndDay"); _colorRect.Color = new Color(0, 0, 0, 1f); _music.VolumeDb = -40; _player.CurrentState = Player.State.Wait; @@ -36,6 +38,11 @@ public partial class Day : Node2D { _state = State.TransitionOut; } + + public void EnableEndDay() + { + + } // Called every frame. 'delta' is the elapsed time since the previous frame. public override void _Process(double delta) diff --git a/scripts/Interactable.cs b/scripts/Interactable.cs index fdf4a61..17665ac 100644 --- a/scripts/Interactable.cs +++ b/scripts/Interactable.cs @@ -13,7 +13,7 @@ public partial class Interactable : Node2D [Export] public Vector2 SpriteOffset; [Export] public float AreaRadius; - + [Export] public bool IsEnabled; private AnimatedSprite2D _sprite; private CollisionShape2D _areaMesh; @@ -46,11 +46,20 @@ public partial class Interactable : Node2D if (_sprite.Position != SpriteOffset) _sprite.Position = SpriteOffset; if (Math.Abs(_collisionCircle.Radius - AreaRadius) > Tolerance) _collisionCircle.Radius = AreaRadius; } + + if (IsEnabled) + { + _sprite.Visible = true; + } + else + { + _sprite.Visible = false; + } } private void _on_area_2d_body_entered(Node2D body) { - if (body is Player player) + if (IsEnabled && body is Player player) { _sprite.Visible = true; EmitSignal(SignalName.PlayerNearBy, player); @@ -59,7 +68,7 @@ public partial class Interactable : Node2D private void _on_area_2d_body_exited(Node2D body) { - if (body is Player player) + if (IsEnabled && body is Player player) { _sprite.Visible = false; EmitSignal(SignalName.PlayerLeft, player);