Add speech management
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DefaultNamespace;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using TMPro;
|
||||
@@ -37,7 +38,8 @@ public class DialogManager : Singleton<DialogManager>
|
||||
{
|
||||
QuestionOptionArea = transform.FindChildRecursive("ADDQOPTIONSHERE");
|
||||
QuestionInfillArea = transform.FindChildRecursive("ADDQINFILSHERE");
|
||||
|
||||
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
@@ -56,6 +58,7 @@ public class DialogManager : Singleton<DialogManager>
|
||||
//public interface to start interaction
|
||||
public void StartDialog(GuardManager guardId)
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
dialogTree = LevelLoader.Instance.SpeechTree;
|
||||
|
||||
currentGuard = guardId;
|
||||
@@ -143,6 +146,12 @@ public class DialogManager : Singleton<DialogManager>
|
||||
|
||||
public void BackButtonPress()
|
||||
{
|
||||
if (questionStack.Count == 0)
|
||||
{
|
||||
reset();
|
||||
return;
|
||||
}
|
||||
|
||||
AskButton.SetActive(false);
|
||||
var (item, parent, infil) = questionStack.Pop();
|
||||
currentItem = parent;
|
||||
@@ -172,12 +181,14 @@ public class DialogManager : Singleton<DialogManager>
|
||||
Debug.LogError(FullQuestion);
|
||||
|
||||
string q = "";
|
||||
string r = "";
|
||||
while (questionStack.Count > 0)
|
||||
{
|
||||
var (item, _, go) = questionStack.Pop();
|
||||
Destroy(go);
|
||||
|
||||
q += item;
|
||||
r = item + " " + r;
|
||||
if (item.StartsWith("guard "))
|
||||
{
|
||||
FullQuestion = FullQuestion.ReplaceLast("GS", "G" + (int.Parse(item[^1].ToString())-1));
|
||||
@@ -194,11 +205,30 @@ public class DialogManager : Singleton<DialogManager>
|
||||
var response = currentGuard.Answer(FullQuestion);
|
||||
|
||||
Debug.Log(response);
|
||||
|
||||
|
||||
r = r.Replace("NOREC_", "");
|
||||
|
||||
string responsePrefix = "";
|
||||
if (FullQuestion.Contains("%"))
|
||||
{
|
||||
responsePrefix = "They would answer: ";
|
||||
}
|
||||
|
||||
SpeechManager.Instance.StartText(new[]
|
||||
{
|
||||
new KeyValuePair<string, string>(r, "PLAYER"),
|
||||
new KeyValuePair<string, string>(responsePrefix + response.ToRandomString(), "GUARD")
|
||||
});
|
||||
|
||||
reset();
|
||||
}
|
||||
|
||||
private void reset()
|
||||
{
|
||||
//reset for next question
|
||||
currentItem = dialogTree;
|
||||
recursiveDepth = 0;
|
||||
PopulateQuestionOptions();
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user