2022-10-16 19:40:44 +02:00
|
|
|
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
|
|
|
|
{
|
2022-12-06 03:10:36 +01:00
|
|
|
[SerializeField]
|
|
|
|
public string Header;
|
|
|
|
|
2022-10-16 19:40:44 +02:00
|
|
|
[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; }
|
|
|
|
|
|
|
|
|
2022-12-20 03:30:37 +01:00
|
|
|
public DialogueStepModel()
|
|
|
|
{
|
|
|
|
// Add marked step as displayed action as first!
|
|
|
|
EndOfDialogueStepAction.AddListener(() => { MarkAsDisplayed(); });
|
|
|
|
}
|
2022-10-16 19:40:44 +02:00
|
|
|
|
|
|
|
public DialogueStepModel(DialogueController _dialogueController)
|
|
|
|
{
|
2022-12-20 03:30:37 +01:00
|
|
|
// Add marked step as displayed action as first!
|
|
|
|
EndOfDialogueStepAction.AddListener(() => { MarkAsDisplayed(); });
|
|
|
|
|
2022-10-16 19:40:44 +02:00
|
|
|
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)
|
2022-12-06 03:10:36 +01:00
|
|
|
DialogueModel.Header = Header; // set header
|
2022-12-27 15:16:59 +01:00
|
|
|
//Debug.Log($"Add sentence - {DialogueModel.Sentence}");
|
2022-10-16 19:40:44 +02:00
|
|
|
DialogueController.AddSentence(DialogueModel);
|
|
|
|
}
|
|
|
|
|
2022-12-20 03:30:37 +01:00
|
|
|
// 3 Bind ending actions
|
|
|
|
DialogueController.SetActionAfterDialogueEnds(EndOfDialogueStepAction);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SetActionAfterDialogueStep(UnityEvent _endOfDialogueStepAction)
|
|
|
|
{
|
|
|
|
EndOfDialogueStepAction = _endOfDialogueStepAction;
|
|
|
|
}
|
2022-12-04 18:42:34 +01:00
|
|
|
|
2022-12-20 03:30:37 +01:00
|
|
|
public void SetActionAfterDialogueStep(Action _finishDialogueAction)
|
|
|
|
{
|
|
|
|
EndOfDialogueStepAction.AddListener(new UnityAction(_finishDialogueAction));
|
|
|
|
}
|
2022-12-04 18:42:34 +01:00
|
|
|
|
2022-12-20 03:30:37 +01:00
|
|
|
public void MarkAsDisplayed()
|
|
|
|
{
|
|
|
|
WasDisplayed = true;
|
2022-10-16 19:40:44 +02:00
|
|
|
}
|
|
|
|
}
|