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.
81 lines
1.5 KiB
81 lines
1.5 KiB
11 years ago
|
using UnityEngine;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
|
||
11 years ago
|
namespace Fungus.Script
|
||
11 years ago
|
{
|
||
|
|
||
11 years ago
|
public class Option : FungusCommand
|
||
11 years ago
|
{
|
||
11 years ago
|
public enum ShowCondition
|
||
11 years ago
|
{
|
||
11 years ago
|
Always,
|
||
|
NotVisited,
|
||
|
BooleanIsTrue,
|
||
|
BooleanIsFalse
|
||
11 years ago
|
}
|
||
|
|
||
11 years ago
|
public string optionText;
|
||
|
public Sequence targetSequence;
|
||
|
public ShowCondition showCondition;
|
||
11 years ago
|
public BooleanVariable booleanVariable;
|
||
11 years ago
|
|
||
|
public override void OnEnter()
|
||
|
{
|
||
|
Dialog dialog = Game.GetInstance().dialog;
|
||
11 years ago
|
bool showOption = (dialog != null && targetSequence != null);
|
||
|
|
||
|
if (showCondition == ShowCondition.Always)
|
||
|
{
|
||
|
// Always show option
|
||
|
}
|
||
|
else if (showCondition == ShowCondition.NotVisited)
|
||
|
{
|
||
11 years ago
|
if (targetSequence == null ||
|
||
|
targetSequence.GetExecutionCount () > 0)
|
||
11 years ago
|
{
|
||
|
showOption = false;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
11 years ago
|
if (booleanVariable == null)
|
||
11 years ago
|
{
|
||
|
showOption = false;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (showCondition == ShowCondition.BooleanIsTrue &&
|
||
11 years ago
|
booleanVariable.Value != true)
|
||
11 years ago
|
{
|
||
|
showOption = false;
|
||
|
}
|
||
|
else if (showCondition == ShowCondition.BooleanIsFalse &&
|
||
11 years ago
|
booleanVariable.Value != false)
|
||
11 years ago
|
{
|
||
|
showOption = false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (showOption)
|
||
11 years ago
|
{
|
||
11 years ago
|
dialog.AddOption(optionText, () => {
|
||
11 years ago
|
Stop();
|
||
11 years ago
|
parentFungusScript.ExecuteSequence(targetSequence);
|
||
11 years ago
|
});
|
||
|
}
|
||
|
Continue();
|
||
|
}
|
||
|
|
||
|
public override void GetConnectedSequences(ref List<Sequence> connectedSequences)
|
||
|
{
|
||
11 years ago
|
if (targetSequence != null)
|
||
11 years ago
|
{
|
||
11 years ago
|
connectedSequences.Add(targetSequence);
|
||
11 years ago
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|