From 1f78a48a3baa3b161324643a7400132203e7dbc1 Mon Sep 17 00:00:00 2001 From: chrisgregan Date: Wed, 6 Aug 2014 14:26:45 +0100 Subject: [PATCH] Merged Compare and Jump commands --- .../Editor/FungusScript/CompareEditor.cs | 138 ---------------- .../Editor/FungusScript/CompareEditor.cs.meta | 8 - .../Editor/FungusScript/FungusEditorWindow.cs | 2 +- .../Fungus/Editor/FungusScript/JumpEditor.cs | 30 ---- .../Editor/FungusScript/JumpEditor.cs.meta | 2 +- Assets/Fungus/VisualScripting/Compare.cs | 149 ------------------ Assets/Fungus/VisualScripting/Compare.cs.meta | 8 - .../Fungus/VisualScripting/FungusCommand.cs | 5 + Assets/Fungus/VisualScripting/Jump.cs | 44 ------ Assets/Fungus/VisualScripting/Jump.cs.meta | 2 +- Assets/Shuttle/ShuttleGame.unity | Bin 79300 -> 77764 bytes 11 files changed, 8 insertions(+), 380 deletions(-) delete mode 100644 Assets/Fungus/Editor/FungusScript/CompareEditor.cs delete mode 100644 Assets/Fungus/Editor/FungusScript/CompareEditor.cs.meta delete mode 100644 Assets/Fungus/Editor/FungusScript/JumpEditor.cs delete mode 100644 Assets/Fungus/VisualScripting/Compare.cs delete mode 100644 Assets/Fungus/VisualScripting/Compare.cs.meta delete mode 100644 Assets/Fungus/VisualScripting/Jump.cs diff --git a/Assets/Fungus/Editor/FungusScript/CompareEditor.cs b/Assets/Fungus/Editor/FungusScript/CompareEditor.cs deleted file mode 100644 index f0e2fd55..00000000 --- a/Assets/Fungus/Editor/FungusScript/CompareEditor.cs +++ /dev/null @@ -1,138 +0,0 @@ -using UnityEditor; -using UnityEngine; -using System.Collections; -using System.Collections.Generic; - -namespace Fungus.Script -{ - - [CustomEditor (typeof(Compare))] - public class CompareEditor : FungusCommandEditor - { - public override void DrawCommandInspectorGUI() - { - Compare t = target as Compare; - - FungusScript sc = t.GetFungusScript(); - if (sc == null) - { - return; - } - - List keys = new List(); - keys.Add(""); - int index = 0; - for (int i = 0; i < sc.variables.Count; ++i) - { - Variable v = sc.variables[i]; - keys.Add(v.key); - if (v.key == t.variableKey && - index == 0) - { - index = i + 1; - } - } - - int newIndex = EditorGUILayout.Popup("Variable", index, keys.ToArray()); - - bool keyChanged = (t.variableKey != keys[newIndex]); - - if (keyChanged) - { - Undo.RecordObject(t, "Select variable"); - t.variableKey = keys[newIndex]; - } - - if (t.variableKey == "") - { - return; - } - - VariableType variableType = sc.variables[newIndex - 1].type; - - List operatorList = new List(); - operatorList.Add(new GUIContent("==")); - operatorList.Add(new GUIContent("!=")); - if (variableType == VariableType.Integer || - variableType == VariableType.Float) - { - operatorList.Add(new GUIContent("<")); - operatorList.Add(new GUIContent(">")); - operatorList.Add(new GUIContent("<=")); - operatorList.Add(new GUIContent(">=")); - } - - CompareOperator compareOperator = (CompareOperator)EditorGUILayout.Popup(new GUIContent("Operator", - "The comparison operator to use when comparing values"), - (int)t.compareOperator, - operatorList.ToArray()); - if (compareOperator != t.compareOperator) - { - Undo.RecordObject(t, "Select compare operator"); - t.compareOperator = compareOperator; - } - - bool booleanValue = t.booleanData.value; - int integerValue = t.integerData.value; - float floatValue = t.floatData.value; - string stringValue = t.stringData.value; - - switch (variableType) - { - case VariableType.Boolean: - booleanValue = EditorGUILayout.Toggle(new GUIContent("Boolean Value", "The boolean value to set the variable with"), booleanValue); - break; - case VariableType.Integer: - integerValue = EditorGUILayout.IntField(new GUIContent("Integer Value", "The integer value to set the variable with"), integerValue); - break; - case VariableType.Float: - floatValue = EditorGUILayout.FloatField(new GUIContent("Float Value", "The float value to set the variable with"), floatValue); - break; - case VariableType.String: - stringValue = EditorGUILayout.TextField(new GUIContent("String Value", "The string value to set the variable with"), stringValue); - break; - } - - if (booleanValue != t.booleanData.value) - { - Undo.RecordObject(t, "Set boolean value"); - t.booleanData.value = booleanValue; - } - else if (integerValue != t.integerData.value) - { - Undo.RecordObject(t, "Set integer value"); - t.integerData.value = integerValue; - } - else if (floatValue != t.floatData.value) - { - Undo.RecordObject(t, "Set float value"); - t.floatData.value = floatValue; - } - else if (stringValue != t.stringData.value) - { - Undo.RecordObject(t, "Set string value"); - t.stringData.value = stringValue; - } - - Sequence onTrue = SequenceEditor.SequenceField(new GUIContent("On True Sequence", "Sequence to execute if comparision is true"), - t.GetFungusScript(), - t.onTrueSequence); - - Sequence onFalse = SequenceEditor.SequenceField(new GUIContent("On False Sequence", "Sequence to execute if comparision is false"), - t.GetFungusScript(), - t.onFalseSequence); - - if (onTrue != t.onTrueSequence) - { - Undo.RecordObject(t, "Set On True Sequence"); - t.onTrueSequence = onTrue; - } - if (onFalse != t.onFalseSequence) - { - Undo.RecordObject(t, "Set On False Sequence"); - t.onFalseSequence = onFalse; - } - } - } - -} diff --git a/Assets/Fungus/Editor/FungusScript/CompareEditor.cs.meta b/Assets/Fungus/Editor/FungusScript/CompareEditor.cs.meta deleted file mode 100644 index 1fd8ee35..00000000 --- a/Assets/Fungus/Editor/FungusScript/CompareEditor.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: d0cbb7e4ccb4a41db8ced7c87070df1d -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs b/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs index 67b25899..ed82b68c 100755 --- a/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs +++ b/Assets/Fungus/Editor/FungusScript/FungusEditorWindow.cs @@ -195,7 +195,7 @@ namespace Fungus.Script FungusCommand[] commands = sequence.gameObject.GetComponents(); foreach (FungusCommand command in commands) { - string commandName = command.GetType().Name; + string commandName = command.GetCommandName(); if (command.errorMessage.Length > 0) { diff --git a/Assets/Fungus/Editor/FungusScript/JumpEditor.cs b/Assets/Fungus/Editor/FungusScript/JumpEditor.cs deleted file mode 100644 index 36cd0a43..00000000 --- a/Assets/Fungus/Editor/FungusScript/JumpEditor.cs +++ /dev/null @@ -1,30 +0,0 @@ -using UnityEditor; -using UnityEditorInternal; -using UnityEngine; -using System.Collections; -using System.Collections.Generic; - -namespace Fungus.Script -{ - - [CustomEditor (typeof(Jump))] - public class JumpEditor : FungusCommandEditor - { - public override void DrawCommandInspectorGUI() - { - Jump t = target as Jump; - - EditorGUI.BeginChangeCheck(); - - Sequence newSequence = SequenceEditor.SequenceField(new GUIContent("Sequence", "Sequence to jump to"), - t.GetFungusScript(), - t.targetSequence); - if (EditorGUI.EndChangeCheck()) - { - Undo.RecordObject(t, "Set Jump command"); - t.targetSequence = newSequence; - } - } - } - -} \ No newline at end of file diff --git a/Assets/Fungus/Editor/FungusScript/JumpEditor.cs.meta b/Assets/Fungus/Editor/FungusScript/JumpEditor.cs.meta index f7cba747..1fd8ee35 100644 --- a/Assets/Fungus/Editor/FungusScript/JumpEditor.cs.meta +++ b/Assets/Fungus/Editor/FungusScript/JumpEditor.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 970dc31f991bd4b0ba8e3475419f3272 +guid: d0cbb7e4ccb4a41db8ced7c87070df1d MonoImporter: serializedVersion: 2 defaultReferences: [] diff --git a/Assets/Fungus/VisualScripting/Compare.cs b/Assets/Fungus/VisualScripting/Compare.cs deleted file mode 100644 index d321aafe..00000000 --- a/Assets/Fungus/VisualScripting/Compare.cs +++ /dev/null @@ -1,149 +0,0 @@ -using UnityEngine; -using System.Collections; -using System.Collections.Generic; - -namespace Fungus.Script -{ - - public enum CompareOperator - { - Equals, // == - NotEquals, // != - LessThan, // < - GreaterThan, // > - LessThanOrEquals, // <= - GreaterThanOrEquals // >= - } - - public class Compare : FungusCommand - { - public string variableKey; - - public CompareOperator compareOperator; - - public BooleanData booleanData; - - public IntegerData integerData; - - public FloatData floatData; - - public StringData stringData; - - public Sequence onTrueSequence; - - public Sequence onFalseSequence; - - public override void OnEnter() - { - Variable v = parentFungusScript.GetVariable(variableKey); - - bool condition = false; - - switch (v.type) - { - case VariableType.Boolean: - switch (compareOperator) - { - case CompareOperator.Equals: - condition = (v.booleanValue == booleanData.value); - break; - case CompareOperator.NotEquals: - default: - condition = (v.booleanValue != booleanData.value); - break; - } - break; - case VariableType.Integer: - switch (compareOperator) - { - case CompareOperator.Equals: - condition = (v.integerValue == integerData.value); - break; - case CompareOperator.NotEquals: - condition = (v.integerValue != integerData.value); - break; - case CompareOperator.LessThan: - condition = (v.integerValue < integerData.value); - break; - case CompareOperator.GreaterThan: - condition = (v.integerValue > integerData.value); - break; - case CompareOperator.LessThanOrEquals: - condition = (v.integerValue <= integerData.value); - break; - case CompareOperator.GreaterThanOrEquals: - condition = (v.integerValue >= integerData.value); - break; - } - break; - case VariableType.Float: - switch (compareOperator) - { - case CompareOperator.Equals: - condition = (v.floatValue == floatData.value); - break; - case CompareOperator.NotEquals: - condition = (v.floatValue != floatData.value); - break; - case CompareOperator.LessThan: - condition = (v.floatValue < floatData.value); - break; - case CompareOperator.GreaterThan: - condition = (v.floatValue > floatData.value); - break; - case CompareOperator.LessThanOrEquals: - condition = (v.floatValue <= floatData.value); - break; - case CompareOperator.GreaterThanOrEquals: - condition = (v.floatValue >= floatData.value); - break; - } - break; - case VariableType.String: - switch (compareOperator) - { - case CompareOperator.Equals: - condition = (v.stringValue == stringData.value); - break; - case CompareOperator.NotEquals: - default: - condition = (v.stringValue != stringData.value); - break; - } - break; - } - - if (condition) - { - if (onTrueSequence != null) - { - ExecuteSequence(onTrueSequence); - return; - } - } - else - { - if (onFalseSequence != null) - { - ExecuteSequence(onFalseSequence); - return; - } - } - - Continue(); - } - - public override void GetConnectedSequences(ref List connectedSequences) - { - if (onTrueSequence != null) - { - connectedSequences.Add(onTrueSequence); - } - if (onFalseSequence != null) - { - connectedSequences.Add(onFalseSequence); - } - } - } - -} \ No newline at end of file diff --git a/Assets/Fungus/VisualScripting/Compare.cs.meta b/Assets/Fungus/VisualScripting/Compare.cs.meta deleted file mode 100644 index 21288ec4..00000000 --- a/Assets/Fungus/VisualScripting/Compare.cs.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 050fb9e6e72f442b3b883da8a965bdeb -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: diff --git a/Assets/Fungus/VisualScripting/FungusCommand.cs b/Assets/Fungus/VisualScripting/FungusCommand.cs index 55a84118..77fe88f2 100644 --- a/Assets/Fungus/VisualScripting/FungusCommand.cs +++ b/Assets/Fungus/VisualScripting/FungusCommand.cs @@ -84,6 +84,11 @@ namespace Fungus.Script public virtual void GetConnectedSequences(ref List connectedSequences) {} + + public virtual string GetCommandName() + { + return GetType().Name; + } } } \ No newline at end of file diff --git a/Assets/Fungus/VisualScripting/Jump.cs b/Assets/Fungus/VisualScripting/Jump.cs deleted file mode 100644 index 32842720..00000000 --- a/Assets/Fungus/VisualScripting/Jump.cs +++ /dev/null @@ -1,44 +0,0 @@ -using UnityEngine; -using System; -using System.Collections; -using System.Collections.Generic; - -namespace Fungus.Script -{ - - public class Jump : FungusCommand - { - public Sequence targetSequence; - - public override void OnEnter() - { - if (targetSequence == null) - { - return; - } - - ExecuteSequence(targetSequence); - } - - public void OnDrawGizmos() - { - if (targetSequence == null) - { - errorMessage = "Please select a Target Sequence object"; - } - else - { - errorMessage = ""; - } - } - - public override void GetConnectedSequences(ref List connectedSequences) - { - if (targetSequence != null) - { - connectedSequences.Add(targetSequence); - } - } - } - -} \ No newline at end of file diff --git a/Assets/Fungus/VisualScripting/Jump.cs.meta b/Assets/Fungus/VisualScripting/Jump.cs.meta index a381bed9..21288ec4 100644 --- a/Assets/Fungus/VisualScripting/Jump.cs.meta +++ b/Assets/Fungus/VisualScripting/Jump.cs.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: c6a48e2d0a0f542d69398d3c180375da +guid: 050fb9e6e72f442b3b883da8a965bdeb MonoImporter: serializedVersion: 2 defaultReferences: [] diff --git a/Assets/Shuttle/ShuttleGame.unity b/Assets/Shuttle/ShuttleGame.unity index 1260f6c14c393b2dfe46eff2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