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

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

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