2024-04-05 17:29:05 +02:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class NPC_EventStack : MonoBehaviour
|
|
|
|
{
|
|
|
|
[SerializeField] private List<string> _eventStack = new List<string>() { "What a great day to develope a game!" };
|
|
|
|
[SerializeField] private int _maxStackHeight = 5;
|
|
|
|
|
2024-04-05 18:11:26 +02:00
|
|
|
private Text2Speech _text2speech;
|
|
|
|
|
2024-04-05 17:29:05 +02:00
|
|
|
public void AddNewContext(string context)
|
|
|
|
{
|
|
|
|
_eventStack.Add(context);
|
|
|
|
if (_eventStack.Count > _maxStackHeight)
|
|
|
|
{
|
|
|
|
_eventStack.RemoveAt(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public string GetEntireContext()
|
|
|
|
{
|
|
|
|
string output = "";
|
|
|
|
foreach (string e in _eventStack)
|
|
|
|
{
|
|
|
|
output += e + ", ";
|
|
|
|
}
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
|
|
|
public string GetLatestContext()
|
|
|
|
{
|
|
|
|
if (_eventStack.Count > 0)
|
|
|
|
{
|
|
|
|
return _eventStack[_eventStack.Count - 1];
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2024-04-05 18:11:26 +02:00
|
|
|
|
|
|
|
public void GenerateVoice()
|
|
|
|
{
|
|
|
|
if ( _eventStack.Count == 0 )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_text2speech.Generate(GetEntireContext());
|
|
|
|
}
|
|
|
|
}
|
2024-04-05 17:29:05 +02:00
|
|
|
}
|