2022-10-16 19:40:44 +02:00
|
|
|
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)
|
|
|
|
{
|
2022-10-20 23:30:19 +02:00
|
|
|
if(!DialogueStep.WasDisplayed && DialogueStep.DialogueController.listOfDialogue.Count != 0)
|
2022-10-16 19:40:44 +02:00
|
|
|
{
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|