Scriptum/Assets/Scripts/Domain/NpcDialogueManager.cs
2022-10-20 23:30:19 +02:00

60 lines
1.8 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[Serializable]
public class NpcDialogueManager : MonoBehaviour
{
[SerializeField]
public List<DialogueStepModel> DialogueStepsList;
public void Start()
{
/* CODE DIALOGUE DECLARATION EXAMPLE
DialogueController DialogueStep = new DialogueController();
DialogueStep.AddSentence(new DialogueModel("lorem ipsum"));
*//* di.AddSentence(new QuestionDialogueModel("tolore dolore?",
new List<Tuple<string, Action>> {
new Tuple<string, Action>("AcceptButton", CustomPanel),
new Tuple<string, Action>("RejectButton", QuestionPanel)
}));*//*
DialogueStep.SetActionAfterDialogueEnds(() => { });
DialogueStepModel dialogueStepModel = new DialogueStepModel(DialogueStep);
DialogueStepsList = new List<DialogueStepModel> { dialogueStepModel };
*/
BuildDialogue();
}
/// <summary>
/// Function to begin dialogue - will be invoked after user reaction from other script :)
/// </summary>
public void ShowStep()
{
// 1. Find first yet undisplayed for player anbd show
foreach(var DialogueStep in DialogueStepsList)
{
if(!DialogueStep.WasDisplayed && DialogueStep.DialogueController.listOfDialogue.Count != 0)
{
DialogueStep.DialogueController.Show(DialogueStep.DialogueController.listOfDialogue.Dequeue());
break;
}
}
}
/// <summary>
/// Build each step of dialogue
/// </summary>
private void BuildDialogue()
{
foreach(var dialogueStep in DialogueStepsList)
{
dialogueStep.Build();
}
}
}