Катсцена первого дня финальная версия
This commit is contained in:
parent
32f09f08f3
commit
d92d6f629b
8 changed files with 110 additions and 42 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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<Dialog>();
|
||||
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<Dialog>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue