Browse Source

Renamed SequenceController to FungusScript

master
chrisgregan 10 years ago
parent
commit
f94203aaf9
  1. 8
      Assets/Fungus/Editor/CompareCommandEditor.cs
  2. 20
      Assets/Fungus/Editor/FungusEditorWindow.cs
  3. 8
      Assets/Fungus/Editor/FungusScriptEditor.cs
  4. 0
      Assets/Fungus/Editor/FungusScriptEditor.cs.meta
  5. 6
      Assets/Fungus/Editor/SequenceEditor.cs
  6. 4
      Assets/Fungus/Editor/SetVariableCommandEditor.cs
  7. BIN
      Assets/Fungus/Tests/Sequence/SequenceTest.unity
  8. 4
      Assets/Fungus/Tests/Sequence/SequenceTestRoom.cs
  9. 2
      Assets/Fungus/VisualScripting/CompareCommand.cs
  10. 14
      Assets/Fungus/VisualScripting/FungusCommand.cs
  11. 2
      Assets/Fungus/VisualScripting/FungusScript.cs
  12. 0
      Assets/Fungus/VisualScripting/FungusScript.cs.meta
  13. 24
      Assets/Fungus/VisualScripting/Sequence.cs
  14. 4
      Assets/Fungus/VisualScripting/SetVariableCommand.cs

8
Assets/Fungus/Editor/CompareCommandEditor.cs

@ -1,4 +1,4 @@
using UnityEditor;
using UnityEditor;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
@ -13,7 +13,7 @@ namespace Fungus
{
CompareCommand t = target as CompareCommand;
SequenceController sc = t.GetParentSequenceController();
FungusScript sc = t.GetParentFungusScript();
if (sc == null)
{
return;
@ -115,11 +115,11 @@ namespace Fungus
}
Sequence onTrue = SequenceEditor.SequenceField(new GUIContent("On True Sequence", "Sequence to execute if comparision is true"),
t.GetParentSequenceController(),
t.GetParentFungusScript(),
t.onTrueSequence);
Sequence onFalse = SequenceEditor.SequenceField(new GUIContent("On False Sequence", "Sequence to execute if comparision is false"),
t.GetParentSequenceController(),
t.GetParentFungusScript(),
t.onFalseSequence);
if (onTrue != t.onTrueSequence)

20
Assets/Fungus/Editor/FungusEditorWindow.cs

@ -25,19 +25,19 @@ public class FungusEditorWindow : EditorWindow
Repaint();
}
SequenceController GetSequenceController()
FungusScript GetFungusScript()
{
GameObject activeObject = Selection.activeGameObject;
while (activeObject != null)
{
SequenceController sequenceController = activeObject.GetComponent<SequenceController>();
FungusScript fungusScript = activeObject.GetComponent<FungusScript>();
Sequence sequence = activeObject.GetComponent<Sequence>();
if (sequenceController != null)
if (fungusScript != null)
{
// Found sequence controller
return sequenceController;
return fungusScript;
}
else if (sequence != null &&
sequence.transform.parent != null)
@ -56,13 +56,13 @@ public class FungusEditorWindow : EditorWindow
void OnGUI()
{
SequenceController sequenceController = GetSequenceController();
if (sequenceController == null)
FungusScript fungusScript = GetFungusScript();
if (fungusScript == null)
{
return;
}
Sequence[] sequences = sequenceController.GetComponentsInChildren<Sequence>();
Sequence[] sequences = fungusScript.GetComponentsInChildren<Sequence>();
Rect scrollViewRect = new Rect();
@ -110,10 +110,10 @@ public class FungusEditorWindow : EditorWindow
GUI.EndScrollView();
string labelText = sequenceController.name;
string labelText = fungusScript.name;
if (Application.isPlaying)
{
if (sequenceController.activeSequence == null)
if (fungusScript.activeSequence == null)
{
labelText += " (Idle)";
}
@ -133,7 +133,7 @@ public class FungusEditorWindow : EditorWindow
GUILayout.Space(15);
if (GUILayout.Button(labelText))
{
Selection.activeGameObject = sequenceController.gameObject;
Selection.activeGameObject = fungusScript.gameObject;
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();

8
Assets/Fungus/Editor/SequenceControllerEditor.cs → Assets/Fungus/Editor/FungusScriptEditor.cs

@ -1,4 +1,4 @@
using UnityEditor;
using UnityEditor;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
@ -39,8 +39,8 @@ public class VariableDrawer : PropertyDrawer
}
}
[CustomEditor (typeof(SequenceController))]
public class SequenceControllerEditor : Editor
[CustomEditor (typeof(FungusScript))]
public class FungusScriptEditor : Editor
{
SerializedProperty variablesProperty;
@ -53,7 +53,7 @@ public class SequenceControllerEditor : Editor
{
serializedObject.Update();
SequenceController t = target as SequenceController;
FungusScript t = target as FungusScript;
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();

0
Assets/Fungus/Editor/SequenceControllerEditor.cs.meta → Assets/Fungus/Editor/FungusScriptEditor.cs.meta

6
Assets/Fungus/Editor/SequenceEditor.cs

@ -8,9 +8,9 @@ using Fungus;
public class SequenceEditor : Editor
{
static public Sequence SequenceField(GUIContent label, SequenceController sequenceController, Sequence sequence)
static public Sequence SequenceField(GUIContent label, FungusScript fungusScript, Sequence sequence)
{
if (sequenceController == null)
if (fungusScript == null)
{
return null;
}
@ -22,7 +22,7 @@ public class SequenceEditor : Editor
int selectedIndex = 0;
sequenceNames.Add(new GUIContent("<None>"));
Sequence[] sequences = sequenceController.GetComponentsInChildren<Sequence>();
Sequence[] sequences = fungusScript.GetComponentsInChildren<Sequence>();
for (int i = 0; i < sequences.Length; ++i)
{
sequenceNames.Add(new GUIContent(sequences[i].name));

4
Assets/Fungus/Editor/SetVariableCommandEditor.cs

@ -1,4 +1,4 @@
using UnityEditor;
using UnityEditor;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
@ -13,7 +13,7 @@ namespace Fungus
{
SetVariableCommand t = target as SetVariableCommand;
SequenceController sc = t.GetParentSequenceController();
FungusScript sc = t.GetParentFungusScript();
if (sc == null)
{
return;

BIN
Assets/Fungus/Tests/Sequence/SequenceTest.unity

Binary file not shown.

4
Assets/Fungus/Tests/Sequence/SequenceTestRoom.cs

@ -4,11 +4,11 @@ using Fungus;
public class SequenceTestRoom : Room
{
public SequenceController sequenceController;
public FungusScript fungusScript;
void OnEnter()
{
sequenceController.Execute();
fungusScript.Execute();
/*
Sequence s = GetComponent<Sequence>();

2
Assets/Fungus/VisualScripting/CompareCommand.cs

@ -35,7 +35,7 @@ namespace Fungus
public override void OnEnter()
{
Variable v = parentSequenceController.GetVariable(variableKey);
Variable v = parentFungusScript.GetVariable(variableKey);
bool condition = false;

14
Assets/Fungus/VisualScripting/FungusCommand.cs

@ -1,4 +1,4 @@
#if UNITY_EDITOR
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
@ -14,7 +14,7 @@ namespace Fungus
public string errorMessage = "";
[HideInInspector]
public SequenceController parentSequenceController;
public FungusScript parentFungusScript;
[HideInInspector]
public Sequence parentSequence;
@ -22,17 +22,17 @@ namespace Fungus
public virtual void Start()
{
parentSequence = GetComponent<Sequence>();
parentSequenceController = GetParentSequenceController();
parentFungusScript = GetParentFungusScript();
}
public SequenceController GetParentSequenceController()
public FungusScript GetParentFungusScript()
{
SequenceController sc = null;
FungusScript sc = null;
Transform parent = transform.parent;
while (parent != null)
{
sc = parent.gameObject.GetComponent<SequenceController>();
sc = parent.gameObject.GetComponent<FungusScript>();
if (sc != null)
{
break;
@ -67,7 +67,7 @@ namespace Fungus
{
OnExit();
parentSequence.Finish();
parentSequenceController.ExecuteSequence(s);
parentFungusScript.ExecuteSequence(s);
}
public virtual void OnEnter()

2
Assets/Fungus/VisualScripting/SequenceController.cs → Assets/Fungus/VisualScripting/FungusScript.cs

@ -7,7 +7,7 @@ using System.Collections;
using System.Collections.Generic;
using Fungus;
public class SequenceController : MonoBehaviour
public class FungusScript : MonoBehaviour
{
public float stepTime;

0
Assets/Fungus/VisualScripting/SequenceController.cs.meta → Assets/Fungus/VisualScripting/FungusScript.cs.meta

24
Assets/Fungus/VisualScripting/Sequence.cs

@ -17,23 +17,23 @@ namespace Fungus
public Rect nodeRect = new Rect(10, 10, 100, 100);
[System.NonSerialized]
public SequenceController sequenceController;
public FungusScript fungusScript;
[System.NonSerialized]
public FungusCommand activeCommand;
public virtual void Start()
{
sequenceController = GetSequenceController();
fungusScript = GetFungusScript();
}
public SequenceController GetSequenceController()
public FungusScript GetFungusScript()
{
SequenceController sc = null;
FungusScript sc = null;
Transform parent = transform.parent;
while (parent != null)
{
sc = parent.gameObject.GetComponent<SequenceController>();
sc = parent.gameObject.GetComponent<FungusScript>();
if (sc != null)
{
break;
@ -58,13 +58,13 @@ namespace Fungus
public bool IsRunning()
{
if (sequenceController == null ||
sequenceController.activeSequence == null)
if (fungusScript == null ||
fungusScript.activeSequence == null)
{
return false;
}
return (sequenceController.activeSequence == this);
return (fungusScript.activeSequence == this);
}
public void ExecuteNextCommand(FungusCommand currentCommand = null)
@ -93,14 +93,14 @@ namespace Fungus
}
else
{
if (sequenceController.stepTime == 0f)
if (fungusScript.stepTime == 0f)
{
activeCommand = nextCommand;
nextCommand.Execute();
}
else
{
StartCoroutine(ExecuteAfterDelay(nextCommand, sequenceController.stepTime));
StartCoroutine(ExecuteAfterDelay(nextCommand, fungusScript.stepTime));
}
}
@ -116,11 +116,11 @@ namespace Fungus
public void Finish()
{
activeCommand = null;
sequenceController.activeSequence = null;
fungusScript.activeSequence = null;
// No more commands to run in current sequence
#if UNITY_EDITOR
Selection.activeGameObject = sequenceController.gameObject;
Selection.activeGameObject = fungusScript.gameObject;
#endif
}
}

4
Assets/Fungus/VisualScripting/SetVariableCommand.cs

@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
using System.Collections;
using Fungus;
@ -22,7 +22,7 @@ public class SetVariableCommand : FungusCommand
return;
}
Variable v = parentSequenceController.GetVariable(variableKey);
Variable v = parentFungusScript.GetVariable(variableKey);
if (v == null)
{
Debug.LogError("Variable " + variableKey + " not defined.");

Loading…
Cancel
Save