Browse Source

Set and Jump use BooleanData, IntegerData, etc.

master
chrisgregan 10 years ago
parent
commit
d6ceaa21c9
  1. 68
      Assets/Fungus/Editor/FungusScript/JumpEditor.cs
  2. 59
      Assets/Fungus/Editor/FungusScript/SetEditor.cs
  3. 6
      Assets/Fungus/VisualScripting/BooleanVariable.cs
  4. 6
      Assets/Fungus/VisualScripting/FloatVariable.cs
  5. 6
      Assets/Fungus/VisualScripting/IntegerVariable.cs
  6. 18
      Assets/Fungus/VisualScripting/Jump.cs
  7. 18
      Assets/Fungus/VisualScripting/Set.cs
  8. 6
      Assets/Fungus/VisualScripting/StringVariable.cs
  9. BIN
      Assets/Shuttle/ShuttleGame.unity

68
Assets/Fungus/Editor/FungusScript/JumpEditor.cs

@ -11,6 +11,8 @@ namespace Fungus.Script
{
public override void DrawCommandInspectorGUI()
{
serializedObject.Update();
Jump t = target as Jump;
FungusScript sc = t.GetFungusScript();
@ -75,61 +77,21 @@ namespace Fungus.Script
t.compareOperator = compareOperator;
}
FungusVariable compareVariable = FungusVariableEditor.VariableField(new GUIContent("Compare Variable", "Variable to compare with"),
t.GetFungusScript(),
t.compareVariable,
v => v.GetType() == fungusVariable.GetType());
if (compareVariable != t.compareVariable)
if (t.variable.GetType() == typeof(BooleanVariable))
{
Undo.RecordObject(t, "Select Compare Variable");
t.compareVariable = compareVariable;
EditorGUILayout.PropertyField(serializedObject.FindProperty("booleanData"));
}
if (compareVariable == null)
else if (t.variable.GetType() == typeof(IntegerVariable))
{
bool booleanValue = t.booleanValue;
int integerValue = t.integerValue;
float floatValue = t.floatValue;
string stringValue = t.stringValue;
if (t.variable.GetType() == typeof(BooleanVariable))
{
booleanValue = EditorGUILayout.Toggle(new GUIContent("Boolean Value", "The boolean value to set the variable with"), booleanValue);
}
else if (t.variable.GetType() == typeof(IntegerVariable))
{
integerValue = EditorGUILayout.IntField(new GUIContent("Integer Value", "The integer value to set the variable with"), integerValue);
}
else if (t.variable.GetType() == typeof(FloatVariable))
{
floatValue = EditorGUILayout.FloatField(new GUIContent("Float Value", "The float value to set the variable with"), floatValue);
}
else if (t.variable.GetType() == typeof(StringVariable))
{
stringValue = EditorGUILayout.TextField(new GUIContent("String Value", "The string value to set the variable with"), stringValue);
}
if (booleanValue != t.booleanValue)
{
Undo.RecordObject(t, "Set boolean value");
t.booleanValue = booleanValue;
}
else if (integerValue != t.integerValue)
{
Undo.RecordObject(t, "Set integer value");
t.integerValue = integerValue;
}
else if (floatValue != t.floatValue)
{
Undo.RecordObject(t, "Set float value");
t.floatValue = floatValue;
}
else if (stringValue != t.stringValue)
{
Undo.RecordObject(t, "Set string value");
t.stringValue = stringValue;
}
EditorGUILayout.PropertyField(serializedObject.FindProperty("integerData"));
}
else if (t.variable.GetType() == typeof(FloatVariable))
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("floatData"));
}
else if (t.variable.GetType() == typeof(StringVariable))
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("stringData"));
}
Sequence onTrue = SequenceEditor.SequenceField(new GUIContent("On True Sequence", "Sequence to execute if comparision is true"),
@ -150,6 +112,8 @@ namespace Fungus.Script
Undo.RecordObject(t, "Set On False Sequence");
t.onFalseSequence = onFalse;
}
serializedObject.ApplyModifiedProperties();
}
}

59
Assets/Fungus/Editor/FungusScript/SetEditor.cs

@ -11,6 +11,8 @@ namespace Fungus.Script
{
public override void DrawCommandInspectorGUI()
{
serializedObject.Update();
Set t = target as Set;
FungusScript fungusScript = t.GetFungusScript();
@ -120,53 +122,24 @@ namespace Fungus.Script
t.setOperator = setOperator;
}
FungusVariable setVariable = FungusVariableEditor.VariableField(new GUIContent("Other Variable", "The variable to read the assigned value from."),
t.GetFungusScript(),
t.setVariable,
v => v.GetType() == variable.GetType ());
if (setVariable != t.setVariable)
if (variable.GetType() == typeof(BooleanVariable))
{
Undo.RecordObject(t, "Select Set Variable");
t.setVariable = setVariable;
EditorGUILayout.PropertyField(serializedObject.FindProperty("booleanData"));
}
if (setVariable == null)
else if (variable.GetType() == typeof(IntegerVariable))
{
EditorGUI.BeginChangeCheck();
bool booleanValue = t.booleanValue;
int integerValue = t.integerValue;
float floatValue = t.floatValue;
string stringValue = t.stringValue;
if (variable.GetType() == typeof(BooleanVariable))
{
booleanValue = EditorGUILayout.Toggle (new GUIContent("Boolean Value", "A constant boolean value to set the variable with"), booleanValue);
}
else if (variable.GetType() == typeof(IntegerVariable))
{
integerValue = EditorGUILayout.IntField(new GUIContent("Integer Value", "A constant integer value to set the variable with"), integerValue);
}
else if (variable.GetType() == typeof(FloatVariable))
{
floatValue = EditorGUILayout.FloatField(new GUIContent("Float Value", "A constant float value to set the variable with"), floatValue);
}
else if (variable.GetType() == typeof(StringVariable))
{
stringValue = EditorGUILayout.TextField(new GUIContent("String Value", "A constant string value to set the variable with"), stringValue);
}
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(t, "Set Variable Data");
t.booleanValue = booleanValue;
t.integerValue = integerValue;
t.floatValue = floatValue;
t.stringValue = stringValue;
}
EditorGUILayout.PropertyField(serializedObject.FindProperty("integerData"));
}
else if (variable.GetType() == typeof(FloatVariable))
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("floatData"));
}
else if (variable.GetType() == typeof(StringVariable))
{
EditorGUILayout.PropertyField(serializedObject.FindProperty("stringData"));
}
serializedObject.ApplyModifiedProperties();
}
}

6
Assets/Fungus/VisualScripting/BooleanVariable.cs

@ -21,6 +21,12 @@ namespace Fungus.Script
{
public BooleanVariable booleanReference;
public bool booleanValue;
public bool Value
{
get { return (booleanReference == null) ? booleanValue : booleanReference.Value; }
set { if (booleanReference == null) { booleanValue = value; } else { booleanReference.Value = value; } }
}
}
}

6
Assets/Fungus/VisualScripting/FloatVariable.cs

@ -20,6 +20,12 @@ namespace Fungus.Script
{
public FloatVariable floatReference;
public float floatValue;
public float Value
{
get { return (floatReference == null) ? floatValue : floatReference.Value; }
set { if (floatReference == null) { floatValue = value; } else { floatReference.Value = value; } }
}
}
}

6
Assets/Fungus/VisualScripting/IntegerVariable.cs

@ -20,6 +20,12 @@ namespace Fungus.Script
{
public IntegerVariable integerReference;
public int integerValue;
public int Value
{
get { return (integerReference == null) ? integerValue : integerReference.Value; }
set { if (integerReference == null) { integerValue = value; } else { integerReference.Value = value; } }
}
}
}

18
Assets/Fungus/VisualScripting/Jump.cs

@ -30,15 +30,13 @@ namespace Fungus.Script
public CompareOperator compareOperator;
public FungusVariable compareVariable;
public BooleanData booleanData;
public bool booleanValue;
public IntegerData integerData;
public int integerValue;
public FloatData floatData;
public float floatValue;
public string stringValue;
public StringData stringData;
public Sequence onTrueSequence;
@ -64,7 +62,7 @@ namespace Fungus.Script
if (variable.GetType() == typeof(BooleanVariable))
{
bool lhs = (variable as BooleanVariable).Value;
bool rhs = (compareVariable as BooleanVariable) == null ? booleanValue : (compareVariable as BooleanVariable).Value;
bool rhs = booleanData.Value;
switch (compareOperator)
{
@ -80,7 +78,7 @@ namespace Fungus.Script
else if (variable.GetType() == typeof(IntegerVariable))
{
int lhs = (variable as IntegerVariable).Value;
int rhs = (compareVariable as IntegerVariable) == null ? integerValue : (compareVariable as IntegerVariable).Value;
int rhs = integerData.Value;
switch (compareOperator)
{
@ -107,7 +105,7 @@ namespace Fungus.Script
else if (variable.GetType() == typeof(FloatVariable))
{
float lhs = (variable as FloatVariable).Value;
float rhs = (compareVariable as FloatVariable) == null ? floatValue : (compareVariable as FloatVariable).Value;
float rhs = floatData.Value;
switch (compareOperator)
{
@ -134,7 +132,7 @@ namespace Fungus.Script
else if (variable.GetType() == typeof(StringVariable))
{
string lhs = (variable as StringVariable).Value;
string rhs = (compareVariable as StringVariable) == null ? stringValue : (compareVariable as StringVariable).Value;
string rhs = stringData.Value;
switch (compareOperator)
{

18
Assets/Fungus/VisualScripting/Set.cs

@ -20,15 +20,13 @@ namespace Fungus.Script
public SetOperator setOperator;
public FungusVariable setVariable;
public BooleanData booleanData;
public bool booleanValue;
public IntegerData integerData;
public int integerValue;
public FloatData floatData;
public float floatValue;
public string stringValue;
public StringData stringData;
public override void OnEnter()
{
@ -41,7 +39,7 @@ namespace Fungus.Script
if (variable.GetType() == typeof(BooleanVariable))
{
BooleanVariable lhs = (variable as BooleanVariable);
bool rhs = (setVariable as BooleanVariable) == null ? booleanValue : (setVariable as BooleanVariable).Value;
bool rhs = booleanData.Value;
switch (setOperator)
{
@ -57,7 +55,7 @@ namespace Fungus.Script
else if (variable.GetType() == typeof(IntegerVariable))
{
IntegerVariable lhs = (variable as IntegerVariable);
int rhs = (setVariable as IntegerVariable) == null ? integerValue : (setVariable as IntegerVariable).Value;
int rhs = integerData.Value;
switch (setOperator)
{
@ -82,7 +80,7 @@ namespace Fungus.Script
else if (variable.GetType() == typeof(FloatVariable))
{
FloatVariable lhs = (variable as FloatVariable);
float rhs = (setVariable as FloatVariable) == null ? floatValue : (setVariable as FloatVariable).Value;
float rhs = floatData.Value;
switch (setOperator)
{
@ -107,7 +105,7 @@ namespace Fungus.Script
else if (variable.GetType() == typeof(StringVariable))
{
StringVariable lhs = (variable as StringVariable);
string rhs = (setVariable as StringVariable) == null ? stringValue : (setVariable as StringVariable).Value;
string rhs = stringData.Value;
switch (setOperator)
{

6
Assets/Fungus/VisualScripting/StringVariable.cs

@ -20,6 +20,12 @@ namespace Fungus.Script
{
public StringVariable stringReference;
public string stringValue;
public string Value
{
get { return (stringReference == null) ? stringValue : stringReference.Value; }
set { if (stringReference == null) { stringValue = value; } else { stringReference.Value = value; } }
}
}
}

BIN
Assets/Shuttle/ShuttleGame.unity

Binary file not shown.
Loading…
Cancel
Save