Прогрессия 2

This commit is contained in:
Евгений Титаренко 2024-08-25 18:08:54 +03:00
parent b793b79d39
commit f37e2b5c4f
10 changed files with 67 additions and 18 deletions

View file

@ -56,6 +56,7 @@ stream_0 = ExtResource("9_43nb0")
[node name="Test" type="Node2D"]
script = ExtResource("1_cko08")
NextScene = "Day2"
IsCaptainDisabled = true
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("1_a6v5r")
@ -270,8 +271,10 @@ AreaRadius = 20.0
[node name="Day1Cutscene" parent="." instance=ExtResource("14_t3ylj")]
position = Vector2(1275, 18)
[connection signal="DialogEnded" from="NPCs/Eugene" to="." method="EnableEngine"]
[connection signal="DialogEnded" from="NPCs/Engine" to="." method="EnableEndDay"]
[connection signal="finished" from="Nightmare" to="." method="ChangeScene"]
[connection signal="OnInteract" from="EndDay" to="." method="ChangeDay"]
[connection signal="PlayerLeft" from="EndDay" to="." method="RemoveEndDay"]
[connection signal="PlayerNearBy" from="EndDay" to="." method="AssignEndDay"]
[connection signal="Finished" from="Day1Cutscene" to="." method="EnableCaptain"]

View file

@ -273,4 +273,5 @@ position = Vector2(985, 245)
SpriteOffset = Vector2(0, -30)
AreaRadius = 20.0
[connection signal="DialogEnded" from="NPCs/Eugene" to="." method="EnableEngine"]
[connection signal="DialogEnded" from="NPCs/Engine" to="." method="EnableEndDay"]

View file

@ -273,4 +273,5 @@ position = Vector2(985, 245)
SpriteOffset = Vector2(0, -30)
AreaRadius = 20.0
[connection signal="DialogEnded" from="NPCs/Computer" to="." method="EnableEngine"]
[connection signal="DialogEnded" from="NPCs/Engine" to="." method="EnableEndDay"]

View file

@ -273,4 +273,5 @@ position = Vector2(985, 245)
SpriteOffset = Vector2(0, -30)
AreaRadius = 20.0
[connection signal="DialogEnded" from="NPCs/Doctor" to="." method="EnableEngine"]
[connection signal="DialogEnded" from="NPCs/Engine" to="." method="ChangeDay"]

View file

@ -55,6 +55,7 @@ stream_0 = ExtResource("10_bwdem")
[node name="Test" type="Node2D"]
script = ExtResource("1_ii8yu")
NextScene = "Menu"
IsEngineDisabled = false
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("1_p4jcj")

View file

@ -4,7 +4,8 @@ using System;
public partial class Day : Node2D
{
[Export] public string NextScene;
[Export] public bool IsEngineDisabled = true;
[Export] public bool IsCaptainDisabled = false;
private enum State
{
Default,
@ -19,6 +20,8 @@ public partial class Day : Node2D
private AudioStreamPlayer _music;
private AudioStreamPlayer _nightmare;
private Interactable _endDay;
private NPC _engine;
private Door _captainDoor;
private double _transitionTimeout = 0;
@ -30,12 +33,26 @@ public partial class Day : Node2D
_music = (AudioStreamPlayer)FindChild("Music");
_nightmare = (AudioStreamPlayer)FindChild("Nightmare");
_endDay = (Interactable)FindChild("EndDay");
_engine = (NPC)FindChild("Engine");
_captainDoor = (Door)FindChild("Door_CAPTAIN");
_colorRect.Color = new Color(0, 0, 0, 1f);
_music.VolumeDb = -40;
_player.CurrentState = Player.State.Wait;
_endDay.Disable();
if (IsEngineDisabled) _engine.Disable();
if (IsCaptainDisabled) _captainDoor.Disable();
}
public void EnableEngine()
{
_engine.Enable();
}
public void EnableCaptain()
{
_captainDoor.Enable();
}
public void AssignEndDay(Player player)
{
player.InteractableObjects.Add(_endDay);

View file

@ -3,6 +3,9 @@ using System;
public partial class Day1Cutscene : Node2D
{
[Signal]
public delegate void FinishedEventHandler();
private Player _player;
private AnimatedSprite2D _sprite;
@ -55,6 +58,7 @@ public partial class Day1Cutscene : Node2D
public void Final()
{
_player.CurrentState = Player.State.Normal;
EmitSignal(SignalName.Finished);
QueueFree();
}

View file

@ -5,11 +5,21 @@ public partial class Door : Node2D
{
[Export] public Door Exit;
private Interactable _interactable;
public void Enable()
{
_interactable.Enable();
}
public void Disable()
{
_interactable.Disable();
}
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
_interactable = (Interactable)FindChild("Interactable");
}
// Called every frame. 'delta' is the elapsed time since the previous frame.

View file

@ -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()

View file

@ -2,7 +2,7 @@ using Godot;
using System;
using Godot.Collections;
// [Tool]
[Tool]
public partial class NPC : Node2D
{
[Signal]
@ -20,7 +20,7 @@ public partial class NPC : Node2D
}
private AnimatedSprite2D _sprite;
private Interactable _interactable;
private int _currentDialogLine;
//Диалог закончен, если больше нет строк диалога.
@ -38,10 +38,21 @@ public partial class NPC : Node2D
return IsDialogEnded ? DefaultDialogLine : DialogLines[_currentDialogLine++];
}
}
public void Disable()
{
_interactable.Disable();
}
public void Enable()
{
_interactable.Enable();
}
public override void _Ready()
{
_sprite = (AnimatedSprite2D)FindChild("AnimatedSprite2D");
_interactable = (Interactable)FindChild("Interactable");
if (Frames is not null) _sprite.SpriteFrames = Frames;
_sprite.Play("default");
_currentDialogLine = 0;