Browse Source

Refactored Variable to use IVariable interface

master
Christopher 8 years ago
parent
commit
03fa707851
  1. 25
      Assets/Fungus/Flowchart/Scripts/IVariable.cs
  2. 12
      Assets/Fungus/Flowchart/Scripts/IVariable.cs.meta
  3. 10
      Assets/Fungus/Flowchart/Scripts/Variable.cs

25
Assets/Fungus/Flowchart/Scripts/IVariable.cs

@ -0,0 +1,25 @@
using UnityEngine;
namespace Fungus
{
/// <summary>
/// A Fungus variable that can be used with Commands.
/// </summary>
public interface IVariable
{
/// <summary>
/// Visibility scope for the variable.
/// </summary>
VariableScope Scope { get; }
/// <summary>
/// String identifier for the variable.
/// </summary>
string Key { get; set; }
/// <summary>
/// Callback to reset the variable if the Flowchart is reset.
/// </summary>
void OnReset();
}
}

12
Assets/Fungus/Flowchart/Scripts/IVariable.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 75ff90e0b811142d39cc9031dbf4b992
timeCreated: 1473856441
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

10
Assets/Fungus/Flowchart/Scripts/Variable.cs

@ -57,15 +57,21 @@ namespace Fungus
/// Abstract base class for variables.
/// </summary>
[RequireComponent(typeof(Flowchart))]
public abstract class Variable : MonoBehaviour
public abstract class Variable : MonoBehaviour, IVariable
{
[SerializeField] protected VariableScope scope;
public virtual VariableScope Scope { get { return scope; } }
[SerializeField] protected string key = "";
#region IVariable implementation
public virtual VariableScope Scope { get { return scope; } }
public virtual string Key { get { return key; } set { key = value; } }
public abstract void OnReset();
#endregion
}
/// <summary>

Loading…
Cancel
Save