You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
1.6 KiB
94 lines
1.6 KiB
using UnityEngine; |
|
using System; |
|
using System.Collections; |
|
using System.Collections.Generic; |
|
|
|
namespace Fungus.Script |
|
{ |
|
[CommandCategory("Dialog")] |
|
[HelpText("Writes a line of story text to the dialog. A condition can be specified for when the story text should be shown.")] |
|
public class Say : FungusCommand |
|
{ |
|
public enum ShowCondition |
|
{ |
|
Always, |
|
Once, |
|
BooleanIsTrue, |
|
BooleanIsFalse |
|
} |
|
|
|
public string character; |
|
public string text; |
|
public ShowCondition showCondition; |
|
public BooleanVariable booleanVariable; |
|
|
|
int executionCount; |
|
|
|
public override void OnEnter() |
|
{ |
|
Dialog dialog = Game.GetInstance().dialog; |
|
if (dialog == null) |
|
{ |
|
Continue(); |
|
return; |
|
} |
|
|
|
bool showSayText = true; |
|
|
|
if (showCondition == ShowCondition.Always) |
|
{ |
|
// Always show option |
|
} |
|
else if (showCondition == ShowCondition.Once) |
|
{ |
|
if (executionCount > 0) |
|
{ |
|
showSayText = false; |
|
} |
|
} |
|
else |
|
{ |
|
if (booleanVariable == null) |
|
{ |
|
showSayText = false; |
|
} |
|
else |
|
{ |
|
if (showCondition == ShowCondition.BooleanIsTrue && |
|
booleanVariable.Value != true) |
|
{ |
|
showSayText = false; |
|
} |
|
else if (showCondition == ShowCondition.BooleanIsFalse && |
|
booleanVariable.Value != false) |
|
{ |
|
showSayText = false; |
|
} |
|
} |
|
} |
|
|
|
if (!showSayText) |
|
{ |
|
Continue(); |
|
return; |
|
} |
|
|
|
executionCount++; |
|
|
|
if (character.Length > 0) |
|
{ |
|
dialog.SetCharacter(character); |
|
} |
|
|
|
dialog.Say (text, delegate { |
|
Continue(); |
|
}); |
|
} |
|
|
|
public override string GetSummary() |
|
{ |
|
return "\"" + text + "\""; |
|
} |
|
} |
|
|
|
} |