|
|
|
|
|
|
/// </summary>
|
|
|
|
public class DialogueManager : MonoBehaviour |
|
|
|
{ |
|
|
|
[SerializeField] private ChoiceBox _choiceBox; // TODO: Demonstration purpose only. Remove or adjust later.
|
|
|
|
// [SerializeField] private ChoiceBox _choiceBox; // TODO: Demonstration purpose only. Remove or adjust later.
|
|
|
|
private bool _reachedEndOfDialogue { get => _counter >= _currentDialogueDataSO.dialogueLines.Count; } |
|
|
|
private bool _reachedEndOfDialogue { get => _counter >= _currentDialogueDataSO.DialogueLines.Count; } |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Displays DialogueData in the UI, one by one.
|
|
|
|
|
|
|
{ |
|
|
|
BeginDialogueData(dialogueDataSO); |
|
|
|
|
|
|
|
DisplayDialogueLine(_currentDialogueDataSO.dialogueLines[_counter]); |
|
|
|
DisplayDialogueLine(_currentDialogueDataSO.DialogueLines[_counter], dialogueDataSO.Actor); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
/// This function is also called by <c>DialogueBehaviour</c> from clips on Timeline during cutscenes.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="dialogueLine"></param>
|
|
|
|
public void DisplayDialogueLine(DialogueLineSO dialogueLine) |
|
|
|
public void DisplayDialogueLine(DialogueLineSO dialogueLine, ActorSO actor) |
|
|
|
Debug.Log("A line of dialogue has been spoken: \"" + dialogueLine.Sentence + "\" by " + dialogueLine.Actor.ActorName); |
|
|
|
Debug.Log("A line of dialogue has been spoken: \"" + dialogueLine.Sentence + "\" by " +actor.ActorName ); |
|
|
|
} |
|
|
|
|
|
|
|
private void OnAdvance() |
|
|
|
|
|
|
if (!_reachedEndOfDialogue) |
|
|
|
{ |
|
|
|
DisplayDialogueLine(_currentDialogueDataSO.dialogueLines[_counter]); |
|
|
|
DisplayDialogueLine(_currentDialogueDataSO.DialogueLines[_counter], _currentDialogueDataSO.Actor); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
|
|
|
_inputReader.advanceDialogueEvent -= OnAdvance; |
|
|
|
|
|
|
|
// TODO: Demonstration purpose only. Remove or adjust later.
|
|
|
|
_choiceBox.Show(_currentDialogueDataSO.Choices, this); |
|
|
|
//_choiceBox.Show(_currentDialogueDataSO.Choices, this);
|
|
|
|
} |
|
|
|
|
|
|
|
public void DialogueEnded() |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// TODO: Demonstration purpose only. Remove or adjust later.
|
|
|
|
/* |
|
|
|
[Serializable] |
|
|
|
public class ChoiceBox |
|
|
|
{ |
|
|
|
|
|
|
_gameObject.SetActive(false); |
|
|
|
} |
|
|
|
} |
|
|
|
*/ |