From c0f1ed9d0e0521b99500a61c995efdc4c2cbf5a4 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Mon, 18 Aug 2014 13:18:33 +0100 Subject: [PATCH] Split Call command into Call and If --- .../{CallEditor.cs => IfEditor.cs} | 67 ++++------ .../Editor/FungusScript/IfEditor.cs.meta | 8 ++ .../Fungus/VisualScripting/{Call.cs => If.cs} | 116 ++++++------------ Assets/Fungus/VisualScripting/If.cs.meta | 8 ++ Assets/Shuttle/ShuttleGame.unity | Bin 82444 -> 83564 bytes 5 files changed, 80 insertions(+), 119 deletions(-) rename Assets/Fungus/Editor/FungusScript/{CallEditor.cs => IfEditor.cs} (57%) create mode 100644 Assets/Fungus/Editor/FungusScript/IfEditor.cs.meta rename Assets/Fungus/VisualScripting/{Call.cs => If.cs} (59%) create mode 100644 Assets/Fungus/VisualScripting/If.cs.meta diff --git a/Assets/Fungus/Editor/FungusScript/CallEditor.cs b/Assets/Fungus/Editor/FungusScript/IfEditor.cs similarity index 57% rename from Assets/Fungus/Editor/FungusScript/CallEditor.cs rename to Assets/Fungus/Editor/FungusScript/IfEditor.cs index 566ddfa6..0dbd02ab 100644 --- a/Assets/Fungus/Editor/FungusScript/CallEditor.cs +++ b/Assets/Fungus/Editor/FungusScript/IfEditor.cs @@ -6,39 +6,18 @@ using System.Collections.Generic; namespace Fungus.Script { - [CustomEditor (typeof(Call))] - public class CallEditor : FungusCommandEditor + [CustomEditor (typeof(If))] + public class IfEditor : FungusCommandEditor { public override void DrawCommandGUI() { serializedObject.Update(); - - Call t = target as Call; - FungusScript sc = t.GetFungusScript(); - if (sc == null) - { - return; - } + If t = target as If; - CallCondition callCondition = (CallCondition)EditorGUILayout.EnumPopup(new GUIContent("Call Condition", "Condition when call will occur"), t.callCondition); - if (callCondition != t.callCondition) + FungusScript fungusScript = t.GetFungusScript(); + if (fungusScript == null) { - Undo.RecordObject(t, "Set Call Condition"); - t.callCondition = callCondition; - } - - if (t.callCondition == CallCondition.CallAlways) - { - Sequence targetSequence = SequenceEditor.SequenceField(new GUIContent("Target Sequence", "Sequence to call"), - new GUIContent(""), - t.GetFungusScript(), - t.targetSequence); - if (targetSequence != t.targetSequence) - { - Undo.RecordObject(t, "Set Target Sequence"); - t.targetSequence = targetSequence; - } return; } @@ -49,7 +28,7 @@ namespace Fungus.Script if (fungusVariable != t.variable) { - Undo.RecordObject(t, "Select variable"); + Undo.RecordObject(t, "Select Variable"); t.variable = fungusVariable; } @@ -70,52 +49,54 @@ namespace Fungus.Script operatorList.Add(new GUIContent(">=")); } - CompareOperator compareOperator = (CompareOperator)EditorGUILayout.Popup(new GUIContent("Operator", + CompareOperator compareOperator = (CompareOperator)EditorGUILayout.Popup(new GUIContent("Compare", "The comparison operator to use when comparing values"), (int)t.compareOperator, operatorList.ToArray()); if (compareOperator != t.compareOperator) { - Undo.RecordObject(t, "Select compare operator"); + Undo.RecordObject(t, "Select Compare Operator"); t.compareOperator = compareOperator; } if (t.variable.GetType() == typeof(BooleanVariable)) { - EditorGUILayout.PropertyField(serializedObject.FindProperty("booleanData")); + EditorGUILayout.PropertyField(serializedObject.FindProperty("booleanValue")); } else if (t.variable.GetType() == typeof(IntegerVariable)) { - EditorGUILayout.PropertyField(serializedObject.FindProperty("integerData")); + EditorGUILayout.PropertyField(serializedObject.FindProperty("integerValue")); } else if (t.variable.GetType() == typeof(FloatVariable)) { - EditorGUILayout.PropertyField(serializedObject.FindProperty("floatData")); + EditorGUILayout.PropertyField(serializedObject.FindProperty("floatValue")); } else if (t.variable.GetType() == typeof(StringVariable)) { - EditorGUILayout.PropertyField(serializedObject.FindProperty("stringData")); + EditorGUILayout.PropertyField(serializedObject.FindProperty("stringValue")); } - Sequence onTrue = SequenceEditor.SequenceField(new GUIContent("On True Sequence", "Sequence to execute if comparision is true"), + EditorGUILayout.Separator(); + + Sequence thenSequence = SequenceEditor.SequenceField(new GUIContent("Then", "Sequence to execute if comparision is true"), new GUIContent(""), t.GetFungusScript(), - t.onTrueSequence); + t.thenSequence); - Sequence onFalse = SequenceEditor.SequenceField(new GUIContent("On False Sequence", "Sequence to execute if comparision is false"), + Sequence elseSequence = SequenceEditor.SequenceField(new GUIContent("Else", "Sequence to execute if comparision is false"), new GUIContent(""), t.GetFungusScript(), - t.onFalseSequence); + t.elseSequence); - if (onTrue != t.onTrueSequence) + if (thenSequence != t.thenSequence) { - Undo.RecordObject(t, "Set On True Sequence"); - t.onTrueSequence = onTrue; + Undo.RecordObject(t, "Set Then Sequence"); + t.thenSequence = thenSequence; } - if (onFalse != t.onFalseSequence) + if (elseSequence != t.elseSequence) { - Undo.RecordObject(t, "Set On False Sequence"); - t.onFalseSequence = onFalse; + Undo.RecordObject(t, "Set Else Sequence"); + t.elseSequence = elseSequence; } serializedObject.ApplyModifiedProperties(); diff --git a/Assets/Fungus/Editor/FungusScript/IfEditor.cs.meta b/Assets/Fungus/Editor/FungusScript/IfEditor.cs.meta new file mode 100644 index 00000000..437cdae2 --- /dev/null +++ b/Assets/Fungus/Editor/FungusScript/IfEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 562735ac0902c4cc886917eed42b89b9 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Fungus/VisualScripting/Call.cs b/Assets/Fungus/VisualScripting/If.cs similarity index 59% rename from Assets/Fungus/VisualScripting/Call.cs rename to Assets/Fungus/VisualScripting/If.cs index fb2866ff..61843d2c 100644 --- a/Assets/Fungus/VisualScripting/Call.cs +++ b/Assets/Fungus/VisualScripting/If.cs @@ -4,12 +4,6 @@ using System.Collections.Generic; namespace Fungus.Script { - public enum CallCondition - { - CallAlways, - CallIf - } - public enum CompareOperator { Equals, // == @@ -20,38 +14,27 @@ namespace Fungus.Script GreaterThanOrEquals // >= } - [HelpText("Start running another sequence. Can use a variable comparision to decide which sequence to run.")] - public class Call : FungusCommand + [HelpText("Execute another sequence IF a condition is true. Sequences can be specified for both true (THEN) and false (ELSE) conditions.")] + public class If : FungusCommand { - public CallCondition callCondition; - - public Sequence targetSequence; // Only used for Always condition - public FungusVariable variable; public CompareOperator compareOperator; - public BooleanData booleanData; + public BooleanData booleanValue; - public IntegerData integerData; + public IntegerData integerValue; - public FloatData floatData; + public FloatData floatValue; - public StringData stringData; + public StringData stringValue; - public Sequence onTrueSequence; + public Sequence thenSequence; - public Sequence onFalseSequence; + public Sequence elseSequence; public override void OnEnter() { - if (callCondition == CallCondition.CallAlways && - targetSequence != null) - { - ExecuteSequence(targetSequence); - return; - } - bool condition = false; if (variable == null) @@ -63,7 +46,7 @@ namespace Fungus.Script if (variable.GetType() == typeof(BooleanVariable)) { bool lhs = (variable as BooleanVariable).Value; - bool rhs = booleanData.Value; + bool rhs = booleanValue.Value; switch (compareOperator) { @@ -79,7 +62,7 @@ namespace Fungus.Script else if (variable.GetType() == typeof(IntegerVariable)) { int lhs = (variable as IntegerVariable).Value; - int rhs = integerData.Value; + int rhs = integerValue.Value; switch (compareOperator) { @@ -106,7 +89,7 @@ namespace Fungus.Script else if (variable.GetType() == typeof(FloatVariable)) { float lhs = (variable as FloatVariable).Value; - float rhs = floatData.Value; + float rhs = floatValue.Value; switch (compareOperator) { @@ -133,7 +116,7 @@ namespace Fungus.Script else if (variable.GetType() == typeof(StringVariable)) { string lhs = (variable as StringVariable).Value; - string rhs = stringData.Value; + string rhs = stringValue.Value; switch (compareOperator) { @@ -149,17 +132,17 @@ namespace Fungus.Script if (condition) { - if (onTrueSequence != null) + if (thenSequence != null) { - ExecuteSequence(onTrueSequence); + ExecuteSequence(thenSequence); return; } } else { - if (onFalseSequence != null) + if (elseSequence != null) { - ExecuteSequence(onFalseSequence); + ExecuteSequence(elseSequence); return; } } @@ -169,63 +152,44 @@ namespace Fungus.Script public override void GetConnectedSequences(ref List connectedSequences) { - if (callCondition == CallCondition.CallAlways && - targetSequence != null) - { - connectedSequences.Add(targetSequence); - return; - } - - if (onTrueSequence != null) + if (thenSequence != null) { - connectedSequences.Add(onTrueSequence); + connectedSequences.Add(thenSequence); } - if (onFalseSequence != null) + if (elseSequence != null) { - connectedSequences.Add(onFalseSequence); + connectedSequences.Add(elseSequence); } } public override string GetSummary() { - if (callCondition == CallCondition.CallAlways) + if (variable == null) { - if (targetSequence == null) - { - return "No target sequence selected"; - } + return "No variable selected"; + } - return targetSequence.name; + string description = "IF " + variable.key + " THEN "; + + if (thenSequence == null) + { + description += ""; } else { - if (variable == null) - { - return "No variable selected"; - } - - string description = "If " + variable.key + " then "; - - if (onTrueSequence == null) - { - description += ""; - } - else - { - description += onTrueSequence.name; - } - description += " else "; - if (onFalseSequence == null) - { - description += ""; - } - else - { - description += onFalseSequence.name; - } - - return description; + description += thenSequence.name; + } + description += " ELSE "; + if (elseSequence == null) + { + description += ""; } + else + { + description += elseSequence.name; + } + + return description; } } diff --git a/Assets/Fungus/VisualScripting/If.cs.meta b/Assets/Fungus/VisualScripting/If.cs.meta new file mode 100644 index 00000000..c0814d71 --- /dev/null +++ b/Assets/Fungus/VisualScripting/If.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 70c5622b8a80845c980954170295f292 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Shuttle/ShuttleGame.unity b/Assets/Shuttle/ShuttleGame.unity index 18e28b3f78635312e5a35a3a3789d29d0ae7ba27..4c01f7c16ba980c12670c70c8aafcd9f8b0db55d 100644 GIT binary patch delta 3433 zcmZ9Odu-F!702%}@gu}Z40+Us0CwWoaqPq{35lU0b_!&nfCvy(VG1aSx^cD?B^z{9 zqBz~c2o+sjev}Iutf^S5FxYD54tG^SskTX;1QpwuH2w>PZK>2vWGzi_Te9!{Jt7-R z*Z2HB_ndpr>;CNHBl^#e>#G^%ZDG_tz!=MiJcyY!)~~8x`TUdY(cIkJGCWTwL-9Z8 zlT-R@^oG-$oH_r=0?BUAlg<~6OYa)J$rsHDgS5%)O_tqDQ*y4(pi2%q{z%EY){}XX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