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.
93 lines
1.6 KiB
93 lines
1.6 KiB
11 years ago
|
using UnityEngine;
|
||
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
|
||
11 years ago
|
namespace Fungus.Script
|
||
11 years ago
|
{
|
||
11 years ago
|
[HelpText("Writes a line of story text to the dialog. A condition can be specified for when the story text should be shown.")]
|
||
11 years ago
|
public class Say : FungusCommand
|
||
11 years ago
|
{
|
||
11 years ago
|
public enum ShowCondition
|
||
|
{
|
||
|
Always,
|
||
|
Once,
|
||
|
BooleanIsTrue,
|
||
|
BooleanIsFalse
|
||
|
}
|
||
|
|
||
11 years ago
|
public string character;
|
||
11 years ago
|
public string text;
|
||
11 years ago
|
public ShowCondition showCondition;
|
||
11 years ago
|
public BooleanVariable booleanVariable;
|
||
11 years ago
|
|
||
|
int executionCount;
|
||
11 years ago
|
|
||
11 years ago
|
public override void OnEnter()
|
||
11 years ago
|
{
|
||
|
Dialog dialog = Game.GetInstance().dialog;
|
||
11 years ago
|
if (dialog == null)
|
||
11 years ago
|
{
|
||
11 years ago
|
Continue();
|
||
|
return;
|
||
11 years ago
|
}
|
||
11 years ago
|
|
||
|
bool showSayText = true;
|
||
|
|
||
|
if (showCondition == ShowCondition.Always)
|
||
|
{
|
||
|
// Always show option
|
||
|
}
|
||
|
else if (showCondition == ShowCondition.Once)
|
||
|
{
|
||
|
if (executionCount > 0)
|
||
|
{
|
||
|
showSayText = false;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
11 years ago
|
if (booleanVariable == null)
|
||
11 years ago
|
{
|
||
|
showSayText = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (showCondition == ShowCondition.BooleanIsTrue &&
|
||
11 years ago
|
booleanVariable.Value != true)
|
||
11 years ago
|
{
|
||
|
showSayText = false;
|
||
|
}
|
||
|
else if (showCondition == ShowCondition.BooleanIsFalse &&
|
||
11 years ago
|
booleanVariable.Value != false)
|
||
11 years ago
|
{
|
||
|
showSayText = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (!showSayText)
|
||
|
{
|
||
|
Continue();
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
executionCount++;
|
||
11 years ago
|
|
||
11 years ago
|
if (character.Length > 0)
|
||
|
{
|
||
|
dialog.SetCharacter(character);
|
||
|
}
|
||
|
|
||
11 years ago
|
dialog.Say (text, delegate {
|
||
11 years ago
|
Continue();
|
||
11 years ago
|
});
|
||
|
}
|
||
11 years ago
|
|
||
11 years ago
|
public override string GetSummary()
|
||
11 years ago
|
{
|
||
|
return "\"" + text + "\"";
|
||
|
}
|
||
11 years ago
|
}
|
||
|
|
||
|
}
|