|
|
@ -134,6 +134,12 @@ namespace Fungus |
|
|
|
[Tooltip("Unique identifier for this flowchart in localized string keys. If no id is specified then the name of the Flowchart object will be used.")] |
|
|
|
[Tooltip("Unique identifier for this flowchart in localized string keys. If no id is specified then the name of the Flowchart object will be used.")] |
|
|
|
public string localizationId = ""; |
|
|
|
public string localizationId = ""; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Display line numbers in the command list in the Block inspector. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
[Tooltip("Display line numbers in the command list in the Block inspector.")] |
|
|
|
|
|
|
|
public bool showLineNumbers = false; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* List of commands to hide in the Add Command menu. Use this to restrict the set of commands available when editing a Flowchart. |
|
|
|
* List of commands to hide in the Add Command menu. Use this to restrict the set of commands available when editing a Flowchart. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -641,9 +647,32 @@ namespace Fungus |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Debug.LogWarning("Variable " + key + " not found."); |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Register a new variable with the Flowchart at runtime. |
|
|
|
|
|
|
|
* The variable should be added as a component on the Flowchart game object. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void SetVariable<T>(string key, T newvariable) where T : Variable |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
foreach (Variable v in variables) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (v != null && v.key == key) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
T variable = v as T; |
|
|
|
|
|
|
|
if (variable != null) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
variable = newvariable; |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Debug.LogWarning("Variable " + key + " not found."); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Gets a list of all variables with public scope in this Flowchart. |
|
|
|
* Gets a list of all variables with public scope in this Flowchart. |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -667,20 +696,17 @@ namespace Fungus |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public virtual bool GetBooleanVariable(string key) |
|
|
|
public virtual bool GetBooleanVariable(string key) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (Variable v in variables) |
|
|
|
BooleanVariable variable = GetVariable<BooleanVariable>(key); |
|
|
|
{ |
|
|
|
|
|
|
|
if (v != null && v.key == key) |
|
|
|
if(variable != null) |
|
|
|
{ |
|
|
|
|
|
|
|
BooleanVariable variable = v as BooleanVariable; |
|
|
|
|
|
|
|
if (variable != null) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
return variable.value; |
|
|
|
return GetVariable<BooleanVariable>(key).value; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
Debug.LogWarning("Boolean variable " + key + " not found."); |
|
|
|
{ |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Sets the value of a boolean variable. |
|
|
|
* Sets the value of a boolean variable. |
|
|
@ -688,20 +714,12 @@ namespace Fungus |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public virtual void SetBooleanVariable(string key, bool value) |
|
|
|
public virtual void SetBooleanVariable(string key, bool value) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (Variable v in variables) |
|
|
|
BooleanVariable variable = GetVariable<BooleanVariable>(key); |
|
|
|
{ |
|
|
|
if(variable != null) |
|
|
|
if (v != null && v.key == key) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
BooleanVariable variable = v as BooleanVariable; |
|
|
|
|
|
|
|
if (variable != null) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
variable.value = value; |
|
|
|
variable.value = value; |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Debug.LogWarning("Boolean variable " + key + " not found."); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Gets the value of an integer variable. |
|
|
|
* Gets the value of an integer variable. |
|
|
@ -709,20 +727,17 @@ namespace Fungus |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public virtual int GetIntegerVariable(string key) |
|
|
|
public virtual int GetIntegerVariable(string key) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (Variable v in variables) |
|
|
|
IntegerVariable variable = GetVariable<IntegerVariable>(key); |
|
|
|
{ |
|
|
|
|
|
|
|
if (v != null && v.key == key) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
IntegerVariable variable = v as IntegerVariable; |
|
|
|
|
|
|
|
if (variable != null) |
|
|
|
if (variable != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return variable.value; |
|
|
|
return GetVariable<IntegerVariable>(key).value; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
Debug.LogWarning("Integer variable " + key + " not found."); |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Sets the value of an integer variable. |
|
|
|
* Sets the value of an integer variable. |
|
|
@ -730,20 +745,12 @@ namespace Fungus |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public virtual void SetIntegerVariable(string key, int value) |
|
|
|
public virtual void SetIntegerVariable(string key, int value) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (Variable v in variables) |
|
|
|
IntegerVariable variable = GetVariable<IntegerVariable>(key); |
|
|
|
{ |
|
|
|
|
|
|
|
if (v != null && v.key == key) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
IntegerVariable variable = v as IntegerVariable; |
|
|
|
|
|
|
|
if (variable != null) |
|
|
|
if (variable != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
variable.value = value; |
|
|
|
variable.value = value; |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Debug.LogWarning("Integer variable " + key + " not found."); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Gets the value of a float variable. |
|
|
|
* Gets the value of a float variable. |
|
|
@ -751,20 +758,17 @@ namespace Fungus |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public virtual float GetFloatVariable(string key) |
|
|
|
public virtual float GetFloatVariable(string key) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (Variable v in variables) |
|
|
|
FloatVariable variable = GetVariable<FloatVariable>(key); |
|
|
|
{ |
|
|
|
|
|
|
|
if (v != null && v.key == key) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
FloatVariable variable = v as FloatVariable; |
|
|
|
|
|
|
|
if (variable != null) |
|
|
|
if (variable != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return variable.value; |
|
|
|
return GetVariable<FloatVariable>(key).value; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
Debug.LogWarning("Float variable " + key + " not found."); |
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
return 0f; |
|
|
|
return 0f; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Sets the value of a float variable. |
|
|
|
* Sets the value of a float variable. |
|
|
@ -772,20 +776,12 @@ namespace Fungus |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public virtual void SetFloatVariable(string key, float value) |
|
|
|
public virtual void SetFloatVariable(string key, float value) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (Variable v in variables) |
|
|
|
FloatVariable variable = GetVariable<FloatVariable>(key); |
|
|
|
{ |
|
|
|
|
|
|
|
if (v != null && v.key == key) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
FloatVariable variable = v as FloatVariable; |
|
|
|
|
|
|
|
if (variable != null) |
|
|
|
if (variable != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
variable.value = value; |
|
|
|
variable.value = value; |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
Debug.LogWarning("Float variable " + key + " not found."); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Gets the value of a string variable. |
|
|
|
* Gets the value of a string variable. |
|
|
@ -793,20 +789,17 @@ namespace Fungus |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public virtual string GetStringVariable(string key) |
|
|
|
public virtual string GetStringVariable(string key) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (Variable v in variables) |
|
|
|
StringVariable variable = GetVariable<StringVariable>(key); |
|
|
|
{ |
|
|
|
|
|
|
|
if (v != null && v.key == key) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
StringVariable variable = v as StringVariable; |
|
|
|
|
|
|
|
if (variable != null) |
|
|
|
if (variable != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return variable.value; |
|
|
|
return GetVariable<StringVariable>(key).value; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
Debug.LogWarning("String variable " + key + " not found."); |
|
|
|
{ |
|
|
|
return ""; |
|
|
|
return ""; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Sets the value of a string variable. |
|
|
|
* Sets the value of a string variable. |
|
|
@ -814,19 +807,11 @@ namespace Fungus |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public virtual void SetStringVariable(string key, string value) |
|
|
|
public virtual void SetStringVariable(string key, string value) |
|
|
|
{ |
|
|
|
{ |
|
|
|
foreach (Variable v in variables) |
|
|
|
StringVariable variable = GetVariable<StringVariable>(key); |
|
|
|
{ |
|
|
|
|
|
|
|
if (v != null && v.key == key) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
StringVariable variable = v as StringVariable; |
|
|
|
|
|
|
|
if (variable != null) |
|
|
|
if (variable != null) |
|
|
|
{ |
|
|
|
{ |
|
|
|
variable.value = value; |
|
|
|
variable.value = value; |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
Debug.LogWarning("String variable " + key + " not found."); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|