Катсцена первого дня финальная версия

This commit is contained in:
Евгений Титаренко 2024-08-25 17:35:36 +03:00
parent 32f09f08f3
commit d92d6f629b
8 changed files with 110 additions and 42 deletions

View file

@ -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;
}
}