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.
51 lines
896 B
51 lines
896 B
using UnityEngine; |
|
using System.Collections; |
|
using Fungus; |
|
|
|
public class SetVariableCommand : FungusCommand |
|
{ |
|
public string variableKey; |
|
|
|
public BooleanData booleanData; |
|
|
|
public IntegerData integerData; |
|
|
|
public FloatData floatData; |
|
|
|
public StringData stringData; |
|
|
|
public override void OnEnter() |
|
{ |
|
if (variableKey.Length == 0) |
|
{ |
|
Finish(); |
|
return; |
|
} |
|
|
|
Variable v = parentFungusScript.GetVariable(variableKey); |
|
if (v == null) |
|
{ |
|
Debug.LogError("Variable " + variableKey + " not defined."); |
|
} |
|
else |
|
{ |
|
switch (v.type) |
|
{ |
|
case VariableType.Boolean: |
|
v.booleanValue = booleanData.value; |
|
break; |
|
case VariableType.Integer: |
|
v.integerValue = integerData.value; |
|
break; |
|
case VariableType.Float: |
|
v.floatValue = floatData.value; |
|
break; |
|
case VariableType.String: |
|
v.stringValue = stringData.value; |
|
break; |
|
} |
|
} |
|
|
|
Finish(); |
|
} |
|
}
|
|
|