Browse Source

Set and Jump use BooleanData, IntegerData, etc.

master
chrisgregan 11 years ago
parent
commit
d6ceaa21c9
  1. 52
      Assets/Fungus/Editor/FungusScript/JumpEditor.cs
  2. 41
      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

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

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

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

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

6
Assets/Fungus/VisualScripting/BooleanVariable.cs

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

18
Assets/Fungus/VisualScripting/Set.cs

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

6
Assets/Fungus/VisualScripting/StringVariable.cs

@ -20,6 +20,12 @@ namespace Fungus.Script
{ {
public StringVariable stringReference; public StringVariable stringReference;
public string stringValue; 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