Scriptum/Assets/Scripts/REFACTORING/Application/Dialogue/Model/DialogueStepModel.cs

62 lines
1.7 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
// change to "mission step" model in future
[Serializable]
public class DialogueStepModel
{
[SerializeField]
public string Header;
[SerializeField] // this flag tell whatewer dialoge ware already display to user
public bool WasDisplayed = false;
[SerializeField] // list to map to queue in DialogueController
public List<DialogueModel> ListOfSentences = new List<DialogueModel>();
[SerializeField]
public UnityEvent EndOfDialogueStepAction = new UnityEvent();
// for displaying set of sentences in one display
public DialogueController DialogueController { get; protected set; }
public DialogueStepModel() { }
public DialogueStepModel(DialogueController _dialogueController)
{
DialogueController = _dialogueController;
}
/// <summary>
/// Just convert list to queue structure :D
/// </summary>
public virtual void Build()
{
// 1. Clear previous setups
// 2. Map first structur into second
DialogueController = new DialogueController();
foreach (DialogueModel DialogueModel in ListOfSentences)
{
// Pass data to builded panel (name, sentence, buttons)
DialogueModel.Header = Header; // set header
DialogueController.AddSentence(DialogueModel);
}
// 3. Bind finishing action
// 3.1 Add marked step as displayed action
EndOfDialogueStepAction.AddListener(() => WasDisplayed = true);
// 3.2 Bind actions
DialogueController.SetActionAfterDialogueEnds(EndOfDialogueStepAction);
}
}