Прогрессия 2
This commit is contained in:
parent
b793b79d39
commit
f37e2b5c4f
10 changed files with 67 additions and 18 deletions
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue