Browse Source

Conversation command passes info to conversation manager

-supports a default time wait on each conversation item
master
desktop-maesty/steve 7 years ago
parent
commit
a88dad4969
  1. 17
      Assets/Fungus/Scripts/Commands/Conversation.cs
  2. 6
      Assets/Fungus/Scripts/Utils/ConversationManager.cs

17
Assets/Fungus/Scripts/Commands/Conversation.cs

@ -7,11 +7,11 @@ using System.Collections;
namespace Fungus
{
/// <summary>
/// Do multiple say and portrait commands in a single block of text. Format is: [character] [portrait] [stage position] [: Story text].
/// Do multiple say and portrait commands in a single block of text. Format is: [character] [portrait] [stage position] [hide] [<<< | >>>] [clear | noclear] [wait | nowait] [fade | nofade] [: Story text].
/// </summary>
[CommandInfo("Narrative",
"Conversation",
"Do multiple say and portrait commands in a single block of text. Format is: [character] [portrait] [stage position] [: Story text]")]
"Conversation",
"Do multiple say and portrait commands in a single block of text. Format is: [character] [portrait] [stage position] [hide] [<<< | >>>] [clear | noclear] [wait | nowait] [fade | nofade] [: Story text]")]
[AddComponentMenu("")]
[ExecuteInEditMode]
public class Conversation : Command
@ -20,6 +20,12 @@ namespace Fungus
protected ConversationManager conversationManager = new ConversationManager();
[SerializeField] protected BooleanData clearPrevious = new BooleanData(true);
[SerializeField] protected BooleanData waitForInput = new BooleanData(true);
[Tooltip("a wait for seconds added to each item of the conversation.")]
[SerializeField] protected FloatData waitForSeconds = new FloatData(0);
[SerializeField] protected BooleanData fadeWhenDone = new BooleanData(true);
protected virtual void Start()
{
conversationManager.PopulateCharacterCache();
@ -30,6 +36,11 @@ namespace Fungus
var flowchart = GetFlowchart();
string subbedText = flowchart.SubstituteVariables(conversationText.Value);
conversationManager.ClearPrev = clearPrevious;
conversationManager.WaitForInput = waitForInput;
conversationManager.FadeDone = fadeWhenDone;
conversationManager.WaitForSeconds = waitForSeconds;
yield return StartCoroutine(conversationManager.DoConversation(subbedText));
Continue();

6
Assets/Fungus/Scripts/Utils/ConversationManager.cs

@ -34,6 +34,7 @@ namespace Fungus
public bool ClearPrev { get; set; }
public bool WaitForInput { get; set; }
public bool FadeDone { get; set; }
public FloatData WaitForSeconds { get; internal set; }
public ConversationManager()
{
@ -167,6 +168,11 @@ namespace Fungus
// Populate the story text to be written
item.Text = text;
if(WaitForSeconds > 0)
{
item.Text += "{w=" + WaitForSeconds.ToString() +"}";
}
if (sayParams == null || sayParams.Length == 0)
{
// Text only, no params - early out.

Loading…
Cancel
Save