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.
82 lines
1.8 KiB
82 lines
1.8 KiB
10 years ago
|
using UnityEngine;
|
||
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
|
||
10 years ago
|
namespace Fungus
|
||
10 years ago
|
{
|
||
10 years ago
|
[CommandInfo("Dialog",
|
||
|
"Add Option",
|
||
10 years ago
|
"Adds an option for the player to select. All previously added options are displayed by the next Choose command. " +
|
||
|
"You can specify another sequence to call and/or a variable to set when the options is selected.")]
|
||
10 years ago
|
public class AddOption : SetVariable
|
||
10 years ago
|
{
|
||
10 years ago
|
[Tooltip("Option text to display when presenting the option to the player")]
|
||
10 years ago
|
public string optionText;
|
||
10 years ago
|
|
||
|
[Tooltip("Sequence to execute when the player selects this option")]
|
||
10 years ago
|
public Sequence targetSequence;
|
||
|
|
||
10 years ago
|
[Tooltip("Hide this option once it has been selected so that it won't appear again even if executed again")]
|
||
10 years ago
|
public bool hideOnSelected;
|
||
10 years ago
|
|
||
10 years ago
|
protected bool wasSelected;
|
||
10 years ago
|
|
||
10 years ago
|
public override void OnEnter()
|
||
|
{
|
||
10 years ago
|
if (hideOnSelected && wasSelected)
|
||
10 years ago
|
{
|
||
|
Continue();
|
||
|
return;
|
||
|
}
|
||
|
|
||
10 years ago
|
Choose.Option option = new Choose.Option();
|
||
10 years ago
|
option.optionText = optionText;
|
||
|
option.targetSequence = targetSequence;
|
||
10 years ago
|
|
||
|
option.action = () => {
|
||
|
wasSelected = true;
|
||
|
DoSetOperation(); // Set variable (if one is specified)
|
||
|
};
|
||
10 years ago
|
|
||
10 years ago
|
Choose.options.Add(option);
|
||
10 years ago
|
|
||
|
Continue();
|
||
|
}
|
||
|
|
||
|
public override string GetSummary()
|
||
|
{
|
||
|
string summaryText = optionText;
|
||
|
|
||
|
if (targetSequence == null)
|
||
|
{
|
||
|
summaryText += " ( <Continue> )";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
10 years ago
|
summaryText += " (" + targetSequence.sequenceName + ")";
|
||
10 years ago
|
}
|
||
|
|
||
|
return summaryText;
|
||
|
}
|
||
|
|
||
|
public override void GetConnectedSequences(ref List<Sequence> connectedSequences)
|
||
|
{
|
||
|
if (targetSequence != null)
|
||
|
{
|
||
10 years ago
|
connectedSequences.Add(targetSequence);
|
||
10 years ago
|
}
|
||
|
}
|
||
10 years ago
|
|
||
|
public override Color GetButtonColor()
|
||
|
{
|
||
|
return new Color32(184, 210, 235, 255);
|
||
|
}
|
||
10 years ago
|
|
||
|
public override void OnReset()
|
||
|
{
|
||
|
wasSelected = false;
|
||
|
}
|
||
10 years ago
|
}
|
||
|
|
||
|
}
|