Browse Source

Refactored many classes to use protected serialisable fields, with public property accessors where required.

master
Christopher 9 years ago
parent
commit
83c12c7e76
  1. 8
      Assets/Fungus/Animation/Scripts/Commands/PlayAnimState.cs
  2. 4
      Assets/Fungus/Animation/Scripts/Commands/ResetAnimTrigger.cs
  3. 6
      Assets/Fungus/Animation/Scripts/Commands/SetAnimBool.cs
  4. 6
      Assets/Fungus/Animation/Scripts/Commands/SetAnimFloat.cs
  5. 6
      Assets/Fungus/Animation/Scripts/Commands/SetAnimInteger.cs
  6. 4
      Assets/Fungus/Animation/Scripts/Commands/SetAnimTrigger.cs
  7. 4
      Assets/Fungus/Audio/Editor/ControlAudioEditor.cs
  8. 14
      Assets/Fungus/Audio/Scripts/Commands/ControlAudio.cs
  9. 8
      Assets/Fungus/Audio/Scripts/Commands/PlayMusic.cs
  10. 6
      Assets/Fungus/Audio/Scripts/Commands/PlaySound.cs
  11. 6
      Assets/Fungus/Audio/Scripts/Commands/PlayUsfxrSound.cs
  12. 6
      Assets/Fungus/Audio/Scripts/Commands/SetAudioPitch.cs
  13. 6
      Assets/Fungus/Audio/Scripts/Commands/SetAudioVolume.cs
  14. 6
      Assets/Fungus/Camera/Editor/ViewEditor.cs
  15. 26
      Assets/Fungus/Camera/Scripts/CameraController.cs
  16. 20
      Assets/Fungus/Camera/Scripts/Commands/FadeScreen.cs
  17. 26
      Assets/Fungus/Camera/Scripts/Commands/FadeToView.cs
  18. 2
      Assets/Fungus/Camera/Scripts/Commands/Fullscreen.cs
  19. 16
      Assets/Fungus/Camera/Scripts/Commands/MoveToView.cs
  20. 6
      Assets/Fungus/Camera/Scripts/Commands/ShakeCamera.cs
  21. 10
      Assets/Fungus/Camera/Scripts/Commands/StartSwipe.cs
  22. 4
      Assets/Fungus/Flowchart/Editor/AssetModProcessor.cs
  23. 138
      Assets/Fungus/Flowchart/Editor/BlockEditor.cs
  24. 18
      Assets/Fungus/Flowchart/Editor/BlockInspector.cs
  25. 9
      Assets/Fungus/Flowchart/Editor/CommandEditor.cs
  26. 50
      Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs
  27. 28
      Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs
  28. 6
      Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs
  29. 207
      Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs
  30. 36
      Assets/Fungus/Flowchart/Editor/InvokeMethodEditor.cs
  31. 4
      Assets/Fungus/Flowchart/Editor/LabelEditor.cs
  32. 2
      Assets/Fungus/Flowchart/Editor/SetVariableEditor.cs
  33. 8
      Assets/Fungus/Flowchart/Editor/VariableEditor.cs
  34. 18
      Assets/Fungus/Flowchart/Editor/VariableListAdaptor.cs
  35. 89
      Assets/Fungus/Flowchart/Scripts/Block.cs
  36. 39
      Assets/Fungus/Flowchart/Scripts/Command.cs
  37. 16
      Assets/Fungus/Flowchart/Scripts/Commands/Break.cs
  38. 18
      Assets/Fungus/Flowchart/Scripts/Commands/Call.cs
  39. 6
      Assets/Fungus/Flowchart/Scripts/Commands/CallMethod.cs
  40. 4
      Assets/Fungus/Flowchart/Scripts/Commands/Comment.cs
  41. 2
      Assets/Fungus/Flowchart/Scripts/Commands/Condition.cs
  42. 4
      Assets/Fungus/Flowchart/Scripts/Commands/DebugLog.cs
  43. 2
      Assets/Fungus/Flowchart/Scripts/Commands/DeleteSaveKey.cs
  44. 2
      Assets/Fungus/Flowchart/Scripts/Commands/Destroy.cs
  45. 12
      Assets/Fungus/Flowchart/Scripts/Commands/Else.cs
  46. 12
      Assets/Fungus/Flowchart/Scripts/Commands/ElseIf.cs
  47. 9
      Assets/Fungus/Flowchart/Scripts/Commands/End.cs
  48. 26
      Assets/Fungus/Flowchart/Scripts/Commands/If.cs
  49. 30
      Assets/Fungus/Flowchart/Scripts/Commands/InvokeEvent.cs
  50. 26
      Assets/Fungus/Flowchart/Scripts/Commands/InvokeMethod.cs
  51. 10
      Assets/Fungus/Flowchart/Scripts/Commands/Jump.cs
  52. 4
      Assets/Fungus/Flowchart/Scripts/Commands/Label.cs
  53. 4
      Assets/Fungus/Flowchart/Scripts/Commands/LoadScene.cs
  54. 4
      Assets/Fungus/Flowchart/Scripts/Commands/LoadVariable.cs
  55. 2
      Assets/Fungus/Flowchart/Scripts/Commands/OpenURL.cs
  56. 8
      Assets/Fungus/Flowchart/Scripts/Commands/RandomFloat.cs
  57. 8
      Assets/Fungus/Flowchart/Scripts/Commands/RandomInteger.cs
  58. 6
      Assets/Fungus/Flowchart/Scripts/Commands/ReadTextFile.cs
  59. 4
      Assets/Fungus/Flowchart/Scripts/Commands/Reset.cs
  60. 4
      Assets/Fungus/Flowchart/Scripts/Commands/SaveVariable.cs
  61. 4
      Assets/Fungus/Flowchart/Scripts/Commands/SendMessage.cs
  62. 4
      Assets/Fungus/Flowchart/Scripts/Commands/SetActive.cs
  63. 2
      Assets/Fungus/Flowchart/Scripts/Commands/SetSaveProfile.cs
  64. 16
      Assets/Fungus/Flowchart/Scripts/Commands/SetVariable.cs
  65. 8
      Assets/Fungus/Flowchart/Scripts/Commands/SpawnObject.cs
  66. 4
      Assets/Fungus/Flowchart/Scripts/Commands/StopBlock.cs
  67. 4
      Assets/Fungus/Flowchart/Scripts/Commands/StopFlowchart.cs
  68. 2
      Assets/Fungus/Flowchart/Scripts/Commands/Wait.cs
  69. 10
      Assets/Fungus/Flowchart/Scripts/Commands/While.cs
  70. 10
      Assets/Fungus/Flowchart/Scripts/EventHandler.cs
  71. 4
      Assets/Fungus/Flowchart/Scripts/EventHandlers/KeyPressed.cs
  72. 2
      Assets/Fungus/Flowchart/Scripts/EventHandlers/MessageReceived.cs
  73. 146
      Assets/Fungus/Flowchart/Scripts/Flowchart.cs
  74. 4
      Assets/Fungus/Flowchart/Scripts/FungusState.cs
  75. 4
      Assets/Fungus/Flowchart/Scripts/Node.cs
  76. 8
      Assets/Fungus/Flowchart/Scripts/Variable.cs
  77. 2
      Assets/Fungus/Flowchart/Scripts/VariableTypes/AnimatorVariable.cs
  78. 2
      Assets/Fungus/Flowchart/Scripts/VariableTypes/AudioSourceVariable.cs
  79. 2
      Assets/Fungus/Flowchart/Scripts/VariableTypes/BooleanVariable.cs
  80. 2
      Assets/Fungus/Flowchart/Scripts/VariableTypes/ColorVariable.cs
  81. 2
      Assets/Fungus/Flowchart/Scripts/VariableTypes/FloatVariable.cs
  82. 2
      Assets/Fungus/Flowchart/Scripts/VariableTypes/GameObjectVariable.cs
  83. 2
      Assets/Fungus/Flowchart/Scripts/VariableTypes/IntegerVariable.cs
  84. 2
      Assets/Fungus/Flowchart/Scripts/VariableTypes/MaterialVariable.cs
  85. 2
      Assets/Fungus/Flowchart/Scripts/VariableTypes/ObjectVariable.cs
  86. 2
      Assets/Fungus/Flowchart/Scripts/VariableTypes/SpriteVariable.cs
  87. 4
      Assets/Fungus/Flowchart/Scripts/VariableTypes/StringVariable.cs
  88. 2
      Assets/Fungus/Flowchart/Scripts/VariableTypes/TextureVariable.cs
  89. 2
      Assets/Fungus/Flowchart/Scripts/VariableTypes/TransformVariable.cs
  90. 2
      Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector2Variable.cs
  91. 2
      Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector3Variable.cs
  92. 8
      Assets/Fungus/Lua/Scripts/Commands/ExecuteLua.cs
  93. 2
      Assets/Fungus/Narrative/Scripts/Commands/Menu.cs
  94. 2
      Assets/Fungus/Narrative/Scripts/Commands/MenuTimer.cs
  95. 2
      Assets/Fungus/Narrative/Scripts/Localization.cs
  96. 2
      Assets/Fungus/Narrative/Scripts/MenuDialog.cs
  97. 8
      Assets/Fungus/Sprite/Scripts/Clickable2D.cs
  98. 8
      Assets/Fungus/Sprite/Scripts/Commands/FadeSprite.cs
  99. 6
      Assets/Fungus/Sprite/Scripts/Commands/SetClickable2D.cs
  100. 6
      Assets/Fungus/Sprite/Scripts/Commands/SetCollider.cs
  101. Some files were not shown because too many files have changed in this diff Show More

8
Assets/Fungus/Animation/Scripts/Commands/PlayAnimState.cs

@ -16,16 +16,16 @@ namespace Fungus
public class PlayAnimState : Command
{
[Tooltip("Reference to an Animator component in a game object")]
public AnimatorData animator = new AnimatorData();
[SerializeField] protected AnimatorData animator = new AnimatorData();
[Tooltip("Name of the state you want to play")]
public StringData stateName = new StringData();
[SerializeField] protected StringData stateName = new StringData();
[Tooltip("Layer to play animation on")]
public IntegerData layer = new IntegerData(-1);
[SerializeField] protected IntegerData layer = new IntegerData(-1);
[Tooltip("Start time of animation")]
public FloatData time = new FloatData(0f);
[SerializeField] protected FloatData time = new FloatData(0f);
public override void OnEnter()
{

4
Assets/Fungus/Animation/Scripts/Commands/ResetAnimTrigger.cs

@ -18,10 +18,10 @@ namespace Fungus
public class ResetAnimTrigger : Command
{
[Tooltip("Reference to an Animator component in a game object")]
public AnimatorData _animator;
[SerializeField] protected AnimatorData _animator;
[Tooltip("Name of the trigger Animator parameter that will be reset")]
public StringData _parameterName;
[SerializeField] protected StringData _parameterName;
public override void OnEnter()
{

6
Assets/Fungus/Animation/Scripts/Commands/SetAnimBool.cs

@ -18,13 +18,13 @@ namespace Fungus
public class SetAnimBool : Command
{
[Tooltip("Reference to an Animator component in a game object")]
public AnimatorData _animator;
[SerializeField] protected AnimatorData _animator;
[Tooltip("Name of the boolean Animator parameter that will have its value changed")]
public StringData _parameterName;
[SerializeField] protected StringData _parameterName;
[Tooltip("The boolean value to set the parameter to")]
public BooleanData value;
[SerializeField] protected BooleanData value;
public override void OnEnter()
{

6
Assets/Fungus/Animation/Scripts/Commands/SetAnimFloat.cs

@ -18,13 +18,13 @@ namespace Fungus
public class SetAnimFloat : Command
{
[Tooltip("Reference to an Animator component in a game object")]
public AnimatorData _animator;
[SerializeField] protected AnimatorData _animator;
[Tooltip("Name of the float Animator parameter that will have its value changed")]
public StringData _parameterName;
[SerializeField] protected StringData _parameterName;
[Tooltip("The float value to set the parameter to")]
public FloatData value;
[SerializeField] protected FloatData value;
public override void OnEnter()
{

6
Assets/Fungus/Animation/Scripts/Commands/SetAnimInteger.cs

@ -18,13 +18,13 @@ namespace Fungus
public class SetAnimInteger : Command
{
[Tooltip("Reference to an Animator component in a game object")]
public AnimatorData _animator;
[SerializeField] protected AnimatorData _animator;
[Tooltip("Name of the integer Animator parameter that will have its value changed")]
public StringData _parameterName;
[SerializeField] protected StringData _parameterName;
[Tooltip("The integer value to set the parameter to")]
public IntegerData value;
[SerializeField] protected IntegerData value;
public override void OnEnter()
{

4
Assets/Fungus/Animation/Scripts/Commands/SetAnimTrigger.cs

@ -18,10 +18,10 @@ namespace Fungus
public class SetAnimTrigger : Command
{
[Tooltip("Reference to an Animator component in a game object")]
public AnimatorData _animator;
[SerializeField] protected AnimatorData _animator;
[Tooltip("Name of the trigger Animator parameter that will have its value changed")]
public StringData _parameterName;
[SerializeField] protected StringData _parameterName;
public override void OnEnter()
{

4
Assets/Fungus/Audio/Editor/ControlAudioEditor.cs

@ -49,11 +49,11 @@ namespace Fungus
EditorGUILayout.PropertyField(controlProp);
EditorGUILayout.PropertyField(audioSourceProp);
string fadeLabel = "Fade Out Duration";
if (t.control != ControlAudio.controlType.StopLoop && t.control != ControlAudio.controlType.PauseLoop)
if (t.Control != ControlAudio.controlType.StopLoop && t.Control != ControlAudio.controlType.PauseLoop)
{
fadeLabel = "Fade In Duration";
string volumeLabel = "End Volume";
if (t.control == ControlAudio.controlType.ChangeVolume)
if (t.Control == ControlAudio.controlType.ChangeVolume)
{
fadeLabel = "Fade Duration";
volumeLabel = "New Volume";

14
Assets/Fungus/Audio/Scripts/Commands/ControlAudio.cs

@ -25,24 +25,26 @@ namespace Fungus
}
[Tooltip("What to do to audio")]
public controlType control;
[SerializeField] protected controlType control;
public controlType Control { get { return control; } }
[Tooltip("Audio clip to play")]
public AudioSourceData _audioSource;
[SerializeField] protected AudioSourceData _audioSource;
[Range(0,1)]
[Tooltip("Start audio at this volume")]
public float startVolume = 1;
[SerializeField] protected float startVolume = 1;
[Range(0,1)]
[Tooltip("End audio at this volume")]
public float endVolume = 1;
[SerializeField] protected float endVolume = 1;
[Tooltip("Time to fade between current volume level and target volume level.")]
public float fadeDuration;
[SerializeField] protected float fadeDuration;
[Tooltip("Wait until this command has finished before executing the next command.")]
public bool waitUntilFinished = false;
[SerializeField] protected bool waitUntilFinished = false;
public override void OnEnter()
{

8
Assets/Fungus/Audio/Scripts/Commands/PlayMusic.cs

@ -15,16 +15,16 @@ namespace Fungus
public class PlayMusic : Command
{
[Tooltip("Music sound clip to play")]
public AudioClip musicClip;
[SerializeField] protected AudioClip musicClip;
[Tooltip("Time to begin playing in seconds. If the audio file is compressed, the time index may be inaccurate.")]
public float atTime;
[SerializeField] protected float atTime;
[Tooltip("The music will start playing again at end.")]
public bool loop = true;
[SerializeField] protected bool loop = true;
[Tooltip("Length of time to fade out previous playing music.")]
public float fadeDuration = 1f;
[SerializeField] protected float fadeDuration = 1f;
public override void OnEnter()
{

6
Assets/Fungus/Audio/Scripts/Commands/PlaySound.cs

@ -15,14 +15,14 @@ namespace Fungus
public class PlaySound : Command
{
[Tooltip("Sound effect clip to play")]
public AudioClip soundClip;
[SerializeField] protected AudioClip soundClip;
[Range(0,1)]
[Tooltip("Volume level of the sound effect")]
public float volume = 1;
[SerializeField] protected float volume = 1;
[Tooltip("Wait until the sound has finished playing before continuing execution.")]
public bool waitUntilFinished;
[SerializeField] protected bool waitUntilFinished;
public override void OnEnter()
{

6
Assets/Fungus/Audio/Scripts/Commands/PlayUsfxrSound.cs

@ -18,13 +18,13 @@
protected SfxrSynth _synth = new SfxrSynth();
[Tooltip("Transform to use for positional audio")]
public Transform ParentTransform = null;
[SerializeField] protected Transform ParentTransform = null;
[Tooltip("Settings string which describes the audio")]
public StringDataMulti _SettingsString = new StringDataMulti("");
[SerializeField] protected StringDataMulti _SettingsString = new StringDataMulti("");
[Tooltip("Time to wait before executing the next command")]
public float waitDuration = 0;
[SerializeField] protected float waitDuration = 0;
//Call this if the settings have changed
protected void UpdateCache() {

6
Assets/Fungus/Audio/Scripts/Commands/SetAudioPitch.cs

@ -16,14 +16,14 @@ namespace Fungus
{
[Range(0,1)]
[Tooltip("Global pitch level for audio played using the Play Music and Play Sound commands")]
public float pitch = 1;
[SerializeField] protected float pitch = 1;
[Range(0,30)]
[Tooltip("Time to fade between current pitch level and target pitch level.")]
public float fadeDuration;
[SerializeField] protected float fadeDuration;
[Tooltip("Wait until the pitch change has finished before executing next command")]
public bool waitUntilFinished = true;
[SerializeField] protected bool waitUntilFinished = true;
public override void OnEnter()
{

6
Assets/Fungus/Audio/Scripts/Commands/SetAudioVolume.cs

@ -16,14 +16,14 @@ namespace Fungus
{
[Range(0,1)]
[Tooltip("Global volume level for audio played using Play Music and Play Sound")]
public float volume = 1f;
[SerializeField] protected float volume = 1f;
[Range(0,30)]
[Tooltip("Time to fade between current volume level and target volume level.")]
public float fadeDuration = 1f;
[SerializeField] protected float fadeDuration = 1f;
[Tooltip("Wait until the volume fade has completed before continuing.")]
public bool waitUntilFinished = true;
[SerializeField] protected bool waitUntilFinished = true;
public override void OnEnter()
{

6
Assets/Fungus/Camera/Editor/ViewEditor.cs

@ -176,11 +176,11 @@ namespace Fungus
Flowchart flowchart = FlowchartWindow.GetFlowchart();
if (flowchart != null)
{
foreach (Command command in flowchart.selectedCommands)
foreach (Command command in flowchart.SelectedCommands)
{
MoveToView moveToViewCommand = command as MoveToView;
if (moveToViewCommand != null &&
moveToViewCommand.targetView == view)
moveToViewCommand.TargetView == view)
{
highlight = true;
}
@ -188,7 +188,7 @@ namespace Fungus
{
FadeToView fadeToViewCommand = command as FadeToView;
if (fadeToViewCommand != null &&
fadeToViewCommand.targetView == view)
fadeToViewCommand.TargetView == view)
{
highlight = true;
}

26
Assets/Fungus/Camera/Scripts/CameraController.cs

@ -20,41 +20,39 @@ namespace Fungus
/**
* Full screen texture used for screen fade effect.
*/
public Texture2D screenFadeTexture;
[SerializeField] protected Texture2D screenFadeTexture;
public Texture2D ScreenFadeTexture { set { screenFadeTexture = value; } }
/**
* Icon to display when swipe pan mode is active.
*/
public Texture2D swipePanIcon;
[SerializeField] protected Texture2D swipePanIcon;
/**
* Position of continue and swipe icons in normalized screen space coords.
* (0,0) = top left, (1,1) = bottom right
*/
public Vector2 swipeIconPosition = new Vector2(1,0);
[SerializeField] protected Vector2 swipeIconPosition = new Vector2(1,0);
/**
* Set the camera z coordinate to a fixed value every frame.
*/
public bool setCameraZ = true;
[SerializeField] protected bool setCameraZ = true;
/**
* Fixed Z coordinate of main camera.
*/
public float cameraZ = -10f;
[SerializeField] protected float cameraZ = -10f;
[SerializeField] protected Camera swipeCamera;
[HideInInspector]
public bool waiting;
protected float fadeAlpha = 0f;
// Swipe panning control
[HideInInspector]
public bool swipePanActive;
public Camera swipeCamera;
protected bool swipePanActive;
[HideInInspector]
public float swipeSpeedMultiplier = 1f;
protected float swipeSpeedMultiplier = 1f;
protected View swipePanViewA;
protected View swipePanViewB;
protected Vector3 previousMousePos;

20
Assets/Fungus/Camera/Scripts/Commands/FadeScreen.cs

@ -17,42 +17,36 @@ namespace Fungus
public class FadeScreen : Command
{
[Tooltip("Time for fade effect to complete")]
public float duration = 1f;
[SerializeField] protected float duration = 1f;
[Tooltip("Current target alpha transparency value. The fade gradually adjusts the alpha to approach this target value.")]
public float targetAlpha = 1f;
[SerializeField] protected float targetAlpha = 1f;
[Tooltip("Wait until the fade has finished before executing next command")]
public bool waitUntilFinished = true;
[SerializeField] protected bool waitUntilFinished = true;
[Tooltip("Color to render fullscreen fade texture with when screen is obscured.")]
public Color fadeColor = Color.black;
[SerializeField] protected Color fadeColor = Color.black;
[Tooltip("Optional texture to use when rendering the fullscreen fade effect.")]
public Texture2D fadeTexture;
[SerializeField] protected Texture2D fadeTexture;
public override void OnEnter()
{
CameraController cameraController = CameraController.GetInstance();
if (waitUntilFinished)
{
cameraController.waiting = true;
}
if (fadeTexture)
{
cameraController.screenFadeTexture = fadeTexture;
cameraController.ScreenFadeTexture = fadeTexture;
}
else
{
cameraController.screenFadeTexture = CameraController.CreateColorTexture(fadeColor, 32, 32);
cameraController.ScreenFadeTexture = CameraController.CreateColorTexture(fadeColor, 32, 32);
}
cameraController.Fade(targetAlpha, duration, delegate {
if (waitUntilFinished)
{
cameraController.waiting = false;
Continue();
}
});

26
Assets/Fungus/Camera/Scripts/Commands/FadeToView.cs

@ -16,25 +16,27 @@ namespace Fungus
public class FadeToView : Command
{
[Tooltip("Time for fade effect to complete")]
public float duration = 1f;
[SerializeField] protected float duration = 1f;
[Tooltip("Fade from fully visible to opaque at start of fade")]
public bool fadeOut = true;
[SerializeField] protected bool fadeOut = true;
[Tooltip("View to transition to when Fade is complete")]
public View targetView;
[SerializeField] protected View targetView;
public View TargetView { get { return targetView; } }
[Tooltip("Wait until the fade has finished before executing next command")]
public bool waitUntilFinished = true;
[SerializeField] protected bool waitUntilFinished = true;
[Tooltip("Color to render fullscreen fade texture with when screen is obscured.")]
public Color fadeColor = Color.black;
[SerializeField] protected Color fadeColor = Color.black;
[Tooltip("Optional texture to use when rendering the fullscreen fade effect.")]
public Texture2D fadeTexture;
[SerializeField] protected Texture2D fadeTexture;
[Tooltip("Camera to use for the fade. Will use main camera if set to none.")]
public Camera targetCamera;
[SerializeField] protected Camera targetCamera;
protected virtual void AcquireCamera()
{
@ -67,24 +69,18 @@ namespace Fungus
CameraController cameraController = CameraController.GetInstance();
if (waitUntilFinished)
{
cameraController.waiting = true;
}
if (fadeTexture)
{
cameraController.screenFadeTexture = fadeTexture;
cameraController.ScreenFadeTexture = fadeTexture;
}
else
{
cameraController.screenFadeTexture = CameraController.CreateColorTexture(fadeColor, 32, 32);
cameraController.ScreenFadeTexture = CameraController.CreateColorTexture(fadeColor, 32, 32);
}
cameraController.FadeToView(targetCamera, targetView, duration, fadeOut, delegate {
if (waitUntilFinished)
{
cameraController.waiting = false;
Continue();
}
});

2
Assets/Fungus/Camera/Scripts/Commands/Fullscreen.cs

@ -22,7 +22,7 @@ namespace Fungus
Windowed
}
public FullscreenMode fullscreenMode;
[SerializeField] protected FullscreenMode fullscreenMode;
public override void OnEnter()
{

16
Assets/Fungus/Camera/Scripts/Commands/MoveToView.cs

@ -16,16 +16,18 @@ namespace Fungus
public class MoveToView : Command
{
[Tooltip("Time for move effect to complete")]
public float duration = 1;
[SerializeField] protected float duration = 1;
[Tooltip("View to transition to when move is complete")]
public Fungus.View targetView;
[SerializeField] protected View targetView;
public View TargetView { get { return targetView; } }
[Tooltip("Wait until the fade has finished before executing next command")]
public bool waitUntilFinished = true;
[SerializeField] protected bool waitUntilFinished = true;
[Tooltip("Camera to use for the pan. Will use main camera if set to none.")]
public Camera targetCamera;
[SerializeField] protected Camera targetCamera;
protected virtual void AcquireCamera()
{
@ -58,11 +60,6 @@ namespace Fungus
CameraController cameraController = CameraController.GetInstance();
if (waitUntilFinished)
{
cameraController.waiting = true;
}
Vector3 targetPosition = targetView.transform.position;
Quaternion targetRotation = targetView.transform.rotation;
float targetSize = targetView.viewSize;
@ -70,7 +67,6 @@ namespace Fungus
cameraController.PanToPosition(targetCamera, targetPosition, targetRotation, targetSize, duration, delegate {
if (waitUntilFinished)
{
cameraController.waiting = false;
Continue();
}
});

6
Assets/Fungus/Camera/Scripts/Commands/ShakeCamera.cs

@ -16,13 +16,13 @@ namespace Fungus
public class ShakeCamera : Command
{
[Tooltip("Time for camera shake effect to complete")]
public float duration = 0.5f;
[SerializeField] protected float duration = 0.5f;
[Tooltip("Magnitude of shake effect in x & y axes")]
public Vector2 amount = new Vector2(1, 1);
[SerializeField] protected Vector2 amount = new Vector2(1, 1);
[Tooltip("Wait until the shake effect has finished before executing next command")]
public bool waitUntilFinished;
[SerializeField] protected bool waitUntilFinished;
public override void OnEnter()
{

10
Assets/Fungus/Camera/Scripts/Commands/StartSwipe.cs

@ -16,19 +16,19 @@ namespace Fungus
public class StartSwipe : Command
{
[Tooltip("Defines one extreme of the scrollable area that the player can pan around")]
public View viewA;
[SerializeField] protected View viewA;
[Tooltip("Defines one extreme of the scrollable area that the player can pan around")]
public View viewB;
[SerializeField] protected View viewB;
[Tooltip("Time to move the camera to a valid starting position between the two views")]
public float duration = 0.5f;
[SerializeField] protected float duration = 0.5f;
[Tooltip("Multiplier factor for speed of swipe pan")]
public float speedMultiplier = 1f;
[SerializeField] protected float speedMultiplier = 1f;
[Tooltip("Camera to use for the pan. Will use main camera if set to none.")]
public Camera targetCamera;
[SerializeField] protected Camera targetCamera;
public virtual void Start()
{

4
Assets/Fungus/Flowchart/Editor/AssetModProcessor.cs

@ -38,9 +38,9 @@ namespace Fungus
Flowchart[] flowcharts = UnityEngine.Object.FindObjectsOfType<Flowchart>();
foreach (Flowchart f in flowcharts)
{
if (!f.saveSelection)
if (!f.SaveSelection)
{
f.selectedBlock = null;
f.SelectedBlock = null;
f.ClearSelectedCommands();
}
}

138
Assets/Fungus/Flowchart/Editor/BlockEditor.cs

@ -64,7 +64,7 @@ namespace Fungus
// Ensure block name is unique for this Flowchart
Block block = target as Block;
string uniqueName = flowchart.GetUniqueBlockKey(blockNameProperty.stringValue, block);
if (uniqueName != block.blockName)
if (uniqueName != block.BlockName)
{
blockNameProperty.stringValue = uniqueName;
}
@ -96,7 +96,7 @@ namespace Fungus
SerializedProperty commandListProperty = serializedObject.FindProperty("commandList");
if (block == flowchart.selectedBlock)
if (block == flowchart.SelectedBlock)
{
SerializedProperty descriptionProp = serializedObject.FindProperty("description");
EditorGUILayout.PropertyField(descriptionProp);
@ -106,22 +106,22 @@ namespace Fungus
block.UpdateIndentLevels();
// Make sure each command has a reference to its parent block
foreach (Command command in block.commandList)
foreach (Command command in block.CommandList)
{
if (command == null) // Will be deleted from the list later on
{
continue;
}
command.parentBlock = block;
command.ParentBlock = block;
}
ReorderableListGUI.Title("Commands");
CommandListAdaptor adaptor = new CommandListAdaptor(commandListProperty, 0);
adaptor.nodeRect = block.nodeRect;
adaptor.nodeRect = block._NodeRect;
ReorderableListFlags flags = ReorderableListFlags.HideAddButton | ReorderableListFlags.HideRemoveButtons | ReorderableListFlags.DisableContextMenu;
if (block.commandList.Count == 0)
if (block.CommandList.Count == 0)
{
EditorGUILayout.HelpBox("Press the + button below to add a command to the list.", MessageType.Info);
}
@ -146,7 +146,7 @@ namespace Fungus
// Copy keyboard shortcut
if (e.type == EventType.ValidateCommand && e.commandName == "Copy")
{
if (flowchart.selectedCommands.Count > 0)
if (flowchart.SelectedCommands.Count > 0)
{
e.Use();
}
@ -161,7 +161,7 @@ namespace Fungus
// Cut keyboard shortcut
if (e.type == EventType.ValidateCommand && e.commandName == "Cut")
{
if (flowchart.selectedCommands.Count > 0)
if (flowchart.SelectedCommands.Count > 0)
{
e.Use();
}
@ -192,7 +192,7 @@ namespace Fungus
// Duplicate keyboard shortcut
if (e.type == EventType.ValidateCommand && e.commandName == "Duplicate")
{
if (flowchart.selectedCommands.Count > 0)
if (flowchart.SelectedCommands.Count > 0)
{
e.Use();
}
@ -208,7 +208,7 @@ namespace Fungus
// Delete keyboard shortcut
if (e.type == EventType.ValidateCommand && e.commandName == "Delete")
{
if (flowchart.selectedCommands.Count > 0)
if (flowchart.SelectedCommands.Count > 0)
{
e.Use();
}
@ -311,9 +311,9 @@ namespace Fungus
Block block = target as Block;
System.Type currentType = null;
if (block.eventHandler != null)
if (block._EventHandler != null)
{
currentType = block.eventHandler.GetType();
currentType = block._EventHandler.GetType();
}
string currentHandlerName = "<None>";
@ -372,9 +372,9 @@ namespace Fungus
}
EditorGUILayout.EndHorizontal();
if (block.eventHandler != null)
if (block._EventHandler != null)
{
EventHandlerEditor eventHandlerEditor = Editor.CreateEditor(block.eventHandler) as EventHandlerEditor;
EventHandlerEditor eventHandlerEditor = Editor.CreateEditor(block._EventHandler) as EventHandlerEditor;
if (eventHandlerEditor != null)
{
eventHandlerEditor.DrawInspectorGUI();
@ -395,16 +395,16 @@ namespace Fungus
Undo.RecordObject(block, "Set Event Handler");
if (block.eventHandler != null)
if (block._EventHandler != null)
{
Undo.DestroyObjectImmediate(block.eventHandler);
Undo.DestroyObjectImmediate(block._EventHandler);
}
if (selectedType != null)
{
EventHandler newHandler = Undo.AddComponent(block.gameObject, selectedType) as EventHandler;
newHandler.parentBlock = block;
block.eventHandler = newHandler;
newHandler.ParentBlock = block;
block._EventHandler = newHandler;
}
// Because this is an async call, we need to force prefab instances to record changes
@ -428,7 +428,7 @@ namespace Fungus
Block[] blocks = flowchart.GetComponents<Block>();
for (int i = 0; i < blocks.Length; ++i)
{
blockNames.Add(new GUIContent(blocks[i].blockName));
blockNames.Add(new GUIContent(blocks[i].BlockName));
if (block == blocks[i])
{
@ -641,16 +641,16 @@ namespace Fungus
// Use index of last selected command in list, or end of list if nothing selected.
int index = -1;
foreach (Command command in flowchart.selectedCommands)
foreach (Command command in flowchart.SelectedCommands)
{
if (command.commandIndex + 1 > index)
if (command.CommandIndex + 1 > index)
{
index = command.commandIndex + 1;
index = command.CommandIndex + 1;
}
}
if (index == -1)
{
index = block.commandList.Count;
index = block.CommandList.Count;
}
GenericMenu commandMenu = new GenericMenu();
@ -738,20 +738,20 @@ namespace Fungus
Command newCommand = Undo.AddComponent(block.gameObject, commandOperation.commandType) as Command;
block.GetFlowchart().AddSelectedCommand(newCommand);
newCommand.parentBlock = block;
newCommand.itemId = flowchart.NextItemId();
newCommand.ParentBlock = block;
newCommand.ItemId = flowchart.NextItemId();
// Let command know it has just been added to the block
newCommand.OnCommandAdded(block);
Undo.RecordObject(block, "Set command type");
if (commandOperation.index < block.commandList.Count - 1)
if (commandOperation.index < block.CommandList.Count - 1)
{
block.commandList.Insert(commandOperation.index, newCommand);
block.CommandList.Insert(commandOperation.index, newCommand);
}
else
{
block.commandList.Add(newCommand);
block.CommandList.Add(newCommand);
}
// Because this is an async call, we need to force prefab instances to record changes
@ -774,12 +774,12 @@ namespace Fungus
bool showPaste = false;
bool showPlay = false;
if (flowchart.selectedCommands.Count > 0)
if (flowchart.SelectedCommands.Count > 0)
{
showCut = true;
showCopy = true;
showDelete = true;
if (flowchart.selectedCommands.Count == 1 && Application.isPlaying)
if (flowchart.SelectedCommands.Count == 1 && Application.isPlaying)
{
showPlay = true;
}
@ -852,14 +852,14 @@ namespace Fungus
Flowchart flowchart = block.GetFlowchart();
if (flowchart == null ||
flowchart.selectedBlock == null)
flowchart.SelectedBlock == null)
{
return;
}
flowchart.ClearSelectedCommands();
Undo.RecordObject(flowchart, "Select All");
foreach (Command command in flowchart.selectedBlock.commandList)
foreach (Command command in flowchart.SelectedBlock.CommandList)
{
flowchart.AddSelectedCommand(command);
}
@ -873,7 +873,7 @@ namespace Fungus
Flowchart flowchart = block.GetFlowchart();
if (flowchart == null ||
flowchart.selectedBlock == null)
flowchart.SelectedBlock == null)
{
return;
}
@ -896,7 +896,7 @@ namespace Fungus
Flowchart flowchart = block.GetFlowchart();
if (flowchart == null ||
flowchart.selectedBlock == null)
flowchart.SelectedBlock == null)
{
return;
}
@ -905,9 +905,9 @@ namespace Fungus
commandCopyBuffer.Clear();
// Scan through all commands in execution order to see if each needs to be copied
foreach (Command command in flowchart.selectedBlock.commandList)
foreach (Command command in flowchart.SelectedBlock.CommandList)
{
if (flowchart.selectedCommands.Contains(command))
if (flowchart.SelectedCommands.Contains(command))
{
System.Type type = command.GetType();
Command newCommand = Undo.AddComponent(commandCopyBuffer.gameObject, type) as Command;
@ -926,7 +926,7 @@ namespace Fungus
Flowchart flowchart = block.GetFlowchart();
if (flowchart == null ||
flowchart.selectedBlock == null)
flowchart.SelectedBlock == null)
{
return;
}
@ -934,14 +934,14 @@ namespace Fungus
CommandCopyBuffer commandCopyBuffer = CommandCopyBuffer.GetInstance();
// Find where to paste commands in block (either at end or after last selected command)
int pasteIndex = flowchart.selectedBlock.commandList.Count;
if (flowchart.selectedCommands.Count > 0)
int pasteIndex = flowchart.SelectedBlock.CommandList.Count;
if (flowchart.SelectedCommands.Count > 0)
{
for (int i = 0; i < flowchart.selectedBlock.commandList.Count; ++i)
for (int i = 0; i < flowchart.SelectedBlock.CommandList.Count; ++i)
{
Command command = flowchart.selectedBlock.commandList[i];
Command command = flowchart.SelectedBlock.CommandList[i];
foreach (Command selectedCommand in flowchart.selectedCommands)
foreach (Command selectedCommand in flowchart.SelectedCommands)
{
if (command == selectedCommand)
{
@ -963,8 +963,8 @@ namespace Fungus
Command pastedCommand = commands.Last<Command>();
if (pastedCommand != null)
{
pastedCommand.itemId = flowchart.NextItemId();
flowchart.selectedBlock.commandList.Insert(pasteIndex++, pastedCommand);
pastedCommand.ItemId = flowchart.NextItemId();
flowchart.SelectedBlock.CommandList.Insert(pasteIndex++, pastedCommand);
}
}
@ -985,15 +985,15 @@ namespace Fungus
Flowchart flowchart = block.GetFlowchart();
if (flowchart == null ||
flowchart.selectedBlock == null)
flowchart.SelectedBlock == null)
{
return;
}
int lastSelectedIndex = 0;
for (int i = flowchart.selectedBlock.commandList.Count - 1; i >= 0; --i)
for (int i = flowchart.SelectedBlock.CommandList.Count - 1; i >= 0; --i)
{
Command command = flowchart.selectedBlock.commandList[i];
foreach (Command selectedCommand in flowchart.selectedCommands)
Command command = flowchart.SelectedBlock.CommandList[i];
foreach (Command selectedCommand in flowchart.SelectedCommands)
{
if (command == selectedCommand)
{
@ -1002,8 +1002,8 @@ namespace Fungus
// Order of destruction is important here for undo to work
Undo.DestroyObjectImmediate(command);
Undo.RecordObject(flowchart.selectedBlock, "Delete");
flowchart.selectedBlock.commandList.RemoveAt(i);
Undo.RecordObject(flowchart.SelectedBlock, "Delete");
flowchart.SelectedBlock.CommandList.RemoveAt(i);
lastSelectedIndex = i;
@ -1015,9 +1015,9 @@ namespace Fungus
Undo.RecordObject(flowchart, "Delete");
flowchart.ClearSelectedCommands();
if (lastSelectedIndex < flowchart.selectedBlock.commandList.Count)
if (lastSelectedIndex < flowchart.SelectedBlock.CommandList.Count)
{
Command nextCommand = flowchart.selectedBlock.commandList[lastSelectedIndex];
Command nextCommand = flowchart.SelectedBlock.CommandList[lastSelectedIndex];
block.GetFlowchart().AddSelectedCommand(nextCommand);
}
@ -1028,19 +1028,19 @@ namespace Fungus
{
Block targetBlock = target as Block;
Flowchart flowchart = targetBlock.GetFlowchart();
Command command = flowchart.selectedCommands[0];
Command command = flowchart.SelectedCommands[0];
if (targetBlock.IsExecuting())
{
// The Block is already executing.
// Tell the Block to stop, wait a little while so the executing command has a
// chance to stop, and then start execution again from the new command.
targetBlock.Stop();
flowchart.StartCoroutine(RunBlock(flowchart, targetBlock, command.commandIndex, 0.2f));
flowchart.StartCoroutine(RunBlock(flowchart, targetBlock, command.CommandIndex, 0.2f));
}
else
{
// Block isn't executing yet so can start it now.
flowchart.ExecuteBlock(targetBlock, command.commandIndex);
flowchart.ExecuteBlock(targetBlock, command.CommandIndex);
}
}
@ -1048,11 +1048,11 @@ namespace Fungus
{
Block targetBlock = target as Block;
Flowchart flowchart = targetBlock.GetFlowchart();
Command command = flowchart.selectedCommands[0];
Command command = flowchart.SelectedCommands[0];
// Stop all active blocks then run the selected block.
flowchart.StopAllBlocks();
flowchart.StartCoroutine(RunBlock(flowchart, targetBlock, command.commandIndex, 0.2f));
flowchart.StartCoroutine(RunBlock(flowchart, targetBlock, command.CommandIndex, 0.2f));
}
protected IEnumerator RunBlock(Flowchart flowchart, Block targetBlock, int commandIndex, float delay)
@ -1066,15 +1066,15 @@ namespace Fungus
Block block = target as Block;
Flowchart flowchart = block.GetFlowchart();
int firstSelectedIndex = flowchart.selectedBlock.commandList.Count;
int firstSelectedIndex = flowchart.SelectedBlock.CommandList.Count;
bool firstSelectedCommandFound = false;
if (flowchart.selectedCommands.Count > 0)
if (flowchart.SelectedCommands.Count > 0)
{
for (int i = 0; i < flowchart.selectedBlock.commandList.Count; i++)
for (int i = 0; i < flowchart.SelectedBlock.CommandList.Count; i++)
{
Command commandInBlock = flowchart.selectedBlock.commandList[i];
Command commandInBlock = flowchart.SelectedBlock.CommandList[i];
foreach (Command selectedCommand in flowchart.selectedCommands)
foreach (Command selectedCommand in flowchart.SelectedCommands)
{
if (commandInBlock == selectedCommand)
{
@ -1095,7 +1095,7 @@ namespace Fungus
if (firstSelectedIndex > 0)
{
flowchart.ClearSelectedCommands();
flowchart.AddSelectedCommand(flowchart.selectedBlock.commandList[firstSelectedIndex-1]);
flowchart.AddSelectedCommand(flowchart.SelectedBlock.CommandList[firstSelectedIndex-1]);
}
Repaint();
@ -1107,13 +1107,13 @@ namespace Fungus
Flowchart flowchart = block.GetFlowchart();
int lastSelectedIndex = -1;
if (flowchart.selectedCommands.Count > 0)
if (flowchart.SelectedCommands.Count > 0)
{
for (int i = 0; i < flowchart.selectedBlock.commandList.Count; i++)
for (int i = 0; i < flowchart.SelectedBlock.CommandList.Count; i++)
{
Command commandInBlock = flowchart.selectedBlock.commandList[i];
Command commandInBlock = flowchart.SelectedBlock.CommandList[i];
foreach (Command selectedCommand in flowchart.selectedCommands)
foreach (Command selectedCommand in flowchart.SelectedCommands)
{
if (commandInBlock == selectedCommand)
{
@ -1122,10 +1122,10 @@ namespace Fungus
}
}
}
if (lastSelectedIndex < flowchart.selectedBlock.commandList.Count-1)
if (lastSelectedIndex < flowchart.SelectedBlock.CommandList.Count-1)
{
flowchart.ClearSelectedCommands();
flowchart.AddSelectedCommand(flowchart.selectedBlock.commandList[lastSelectedIndex+1]);
flowchart.AddSelectedCommand(flowchart.SelectedBlock.CommandList[lastSelectedIndex+1]);
}
Repaint();

18
Assets/Fungus/Flowchart/Editor/BlockInspector.cs

@ -101,19 +101,19 @@ namespace Fungus
Rect blockRect = new Rect(5, topPanelHeight, width - 5, height + 10);
GUILayout.BeginArea(blockRect);
blockScrollPos = GUILayout.BeginScrollView(blockScrollPos, GUILayout.Height(flowchart.blockViewHeight));
blockScrollPos = GUILayout.BeginScrollView(blockScrollPos, GUILayout.Height(flowchart.BlockViewHeight));
activeBlockEditor.DrawBlockGUI(flowchart);
GUILayout.EndScrollView();
Command inspectCommand = null;
if (flowchart.selectedCommands.Count == 1)
if (flowchart.SelectedCommands.Count == 1)
{
inspectCommand = flowchart.selectedCommands[0];
inspectCommand = flowchart.SelectedCommands[0];
}
if (Application.isPlaying &&
inspectCommand != null &&
inspectCommand.parentBlock != block)
inspectCommand.ParentBlock != block)
{
GUILayout.EndArea();
Repaint();
@ -189,7 +189,7 @@ namespace Fungus
// Draw the resize bar after everything else has finished drawing
// This is mainly to avoid incorrect indenting.
Rect resizeRect = new Rect(0, topPanelHeight + flowchart.blockViewHeight + 1, Screen.width, 4f);
Rect resizeRect = new Rect(0, topPanelHeight + flowchart.BlockViewHeight + 1, Screen.width, 4f);
GUI.color = new Color(0.64f, 0.64f, 0.64f);
GUI.DrawTexture(resizeRect, EditorGUIUtility.whiteTexture);
resizeRect.height = 1;
@ -204,7 +204,7 @@ namespace Fungus
private void ResizeScrollView(Flowchart flowchart)
{
Rect cursorChangeRect = new Rect(0, flowchart.blockViewHeight + 1, Screen.width, 4f);
Rect cursorChangeRect = new Rect(0, flowchart.BlockViewHeight + 1, Screen.width, 4f);
EditorGUIUtility.AddCursorRect(cursorChangeRect, MouseCursor.ResizeVertical);
@ -216,7 +216,7 @@ namespace Fungus
if (resize)
{
Undo.RecordObject(flowchart, "Resize view");
flowchart.blockViewHeight = Event.current.mousePosition.y;
flowchart.BlockViewHeight = Event.current.mousePosition.y;
}
ClampBlockViewHeight(flowchart);
@ -251,10 +251,10 @@ namespace Fungus
if (clamp)
{
// Make sure block view is always clamped to visible area
float height = flowchart.blockViewHeight;
float height = flowchart.BlockViewHeight;
height = Mathf.Max(200, height);
height = Mathf.Min(Screen.height - 200,height);
flowchart.blockViewHeight = height;
flowchart.BlockViewHeight = height;
}
if (Event.current.type == EventType.Repaint)

9
Assets/Fungus/Flowchart/Editor/CommandEditor.cs

@ -1,3 +1,4 @@
/**
* This code is part of the Fungus library (http://fungusgames.com) maintained by Chris Gregan (http://twitter.com/gofungus).
* It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
@ -57,7 +58,7 @@ namespace Fungus
if (t.enabled)
{
if (flowchart.colorCommands)
if (flowchart.ColorCommands)
{
GUI.backgroundColor = t.GetButtonColor();
}
@ -77,7 +78,7 @@ namespace Fungus
GUILayout.FlexibleSpace();
GUILayout.Label(new GUIContent("(" + t.itemId + ")"));
GUILayout.Label(new GUIContent("(" + t.ItemId + ")"));
GUILayout.Space(10);
@ -100,11 +101,11 @@ namespace Fungus
EditorGUILayout.Separator();
if (t.errorMessage.Length > 0)
if (t.ErrorMessage.Length > 0)
{
GUIStyle style = new GUIStyle(GUI.skin.label);
style.normal.textColor = new Color(1,0,0);
EditorGUILayout.LabelField(new GUIContent("Error: " + t.errorMessage), style);
EditorGUILayout.LabelField(new GUIContent("Error: " + t.ErrorMessage), style);
}
GUILayout.EndVertical();

50
Assets/Fungus/Flowchart/Editor/CommandListAdaptor.cs

@ -88,14 +88,14 @@ namespace Fungus
return null;
}
Block block = flowchart.selectedBlock;
Block block = flowchart.SelectedBlock;
if (block == null)
{
return null;
}
Command newCommand = Undo.AddComponent<Comment>(block.gameObject) as Command;
newCommand.itemId = flowchart.NextItemId();
newCommand.ItemId = flowchart.NextItemId();
flowchart.ClearSelectedCommands();
flowchart.AddSelectedCommand(newCommand);
@ -111,7 +111,7 @@ namespace Fungus
System.Type type = command.GetType();
Command newCommand = Undo.AddComponent(parentBlock.gameObject, type) as Command;
newCommand.itemId = newCommand.GetFlowchart().NextItemId();
newCommand.ItemId = newCommand.GetFlowchart().NextItemId();
System.Reflection.FieldInfo[] fields = type.GetFields();
foreach (System.Reflection.FieldInfo field in fields)
{
@ -205,7 +205,7 @@ namespace Fungus
}
bool commandIsSelected = false;
foreach (Command selectedCommand in flowchart.selectedCommands)
foreach (Command selectedCommand in flowchart.SelectedCommands)
{
if (selectedCommand == command)
{
@ -229,7 +229,7 @@ namespace Fungus
commandLabelStyle.padding.top -= 1;
float indentSize = 20;
for (int i = 0; i < command.indentLevel; ++i)
for (int i = 0; i < command.IndentLevel; ++i)
{
Rect indentRect = position;
indentRect.x += i * indentSize - 21;
@ -241,12 +241,12 @@ namespace Fungus
}
float commandNameWidth = Mathf.Max(commandLabelStyle.CalcSize(new GUIContent(commandName)).x, 90f);
float indentWidth = command.indentLevel * indentSize;
float indentWidth = command.IndentLevel * indentSize;
Rect commandLabelRect = position;
commandLabelRect.x += indentWidth - 21;
commandLabelRect.y -= 2;
commandLabelRect.width -= (indentSize * command.indentLevel - 22);
commandLabelRect.width -= (indentSize * command.IndentLevel - 22);
commandLabelRect.height += 5;
// There's a weird incompatibility between the Reorderable list control used for the command list and
@ -263,14 +263,14 @@ namespace Fungus
Event.current.button == 0 &&
clickRect.Contains(Event.current.mousePosition))
{
if (flowchart.selectedCommands.Contains(command) && Event.current.button == 0)
if (flowchart.SelectedCommands.Contains(command) && Event.current.button == 0)
{
// Left click on already selected command
// Command key and shift key is not pressed
if (!EditorGUI.actionKey && !Event.current.shift)
{
BlockEditor.actionList.Add ( delegate {
flowchart.selectedCommands.Remove(command);
flowchart.SelectedCommands.Remove(command);
flowchart.ClearSelectedCommands();
});
}
@ -279,7 +279,7 @@ namespace Fungus
if (EditorGUI.actionKey)
{
BlockEditor.actionList.Add ( delegate {
flowchart.selectedCommands.Remove(command);
flowchart.SelectedCommands.Remove(command);
});
Event.current.Use();
}
@ -304,14 +304,14 @@ namespace Fungus
// Find first and last selected commands
int firstSelectedIndex = -1;
int lastSelectedIndex = -1;
if (flowchart.selectedCommands.Count > 0)
if (flowchart.SelectedCommands.Count > 0)
{
if ( flowchart.selectedBlock != null)
if ( flowchart.SelectedBlock != null)
{
for (int i = 0; i < flowchart.selectedBlock.commandList.Count; i++)
for (int i = 0; i < flowchart.SelectedBlock.CommandList.Count; i++)
{
Command commandInBlock = flowchart.selectedBlock.commandList[i];
foreach (Command selectedCommand in flowchart.selectedCommands)
Command commandInBlock = flowchart.SelectedBlock.CommandList[i];
foreach (Command selectedCommand in flowchart.SelectedCommands)
{
if (commandInBlock == selectedCommand)
{
@ -320,10 +320,10 @@ namespace Fungus
}
}
}
for (int i = flowchart.selectedBlock.commandList.Count - 1; i >=0; i--)
for (int i = flowchart.SelectedBlock.CommandList.Count - 1; i >=0; i--)
{
Command commandInBlock = flowchart.selectedBlock.commandList[i];
foreach (Command selectedCommand in flowchart.selectedCommands)
Command commandInBlock = flowchart.SelectedBlock.CommandList[i];
foreach (Command selectedCommand in flowchart.SelectedCommands)
{
if (commandInBlock == selectedCommand)
{
@ -337,7 +337,7 @@ namespace Fungus
if (shift)
{
int currentIndex = command.commandIndex;
int currentIndex = command.CommandIndex;
if (firstSelectedIndex == -1 ||
lastSelectedIndex == -1)
{
@ -359,7 +359,7 @@ namespace Fungus
for (int i = Math.Min(firstSelectedIndex, lastSelectedIndex); i < Math.Max(firstSelectedIndex, lastSelectedIndex); ++i)
{
Command selectedCommand = flowchart.selectedBlock.commandList[i];
Command selectedCommand = flowchart.SelectedBlock.CommandList[i];
BlockEditor.actionList.Add ( delegate {
flowchart.AddSelectedCommand(selectedCommand);
});
@ -372,7 +372,7 @@ namespace Fungus
}
Color commandLabelColor = Color.white;
if (flowchart.colorCommands)
if (flowchart.ColorCommands)
{
commandLabelColor = command.GetButtonColor();
}
@ -399,9 +399,9 @@ namespace Fungus
else
{
string commandNameLabel;
if (flowchart.showLineNumbers)
if (flowchart.ShowLineNumbers)
{
commandNameLabel = command.commandIndex.ToString() + ": " + commandName;
commandNameLabel = command.CommandIndex.ToString() + ": " + commandName;
}
else
{
@ -411,7 +411,7 @@ namespace Fungus
GUI.Label(commandLabelRect, commandNameLabel, commandLabelStyle);
}
if (command.executingIconTimer > Time.realtimeSinceStartup)
if (command.ExecutingIconTimer > Time.realtimeSinceStartup)
{
Rect iconRect = new Rect(commandLabelRect);
iconRect.x += iconRect.width - commandLabelRect.width - 20;
@ -420,7 +420,7 @@ namespace Fungus
Color storeColor = GUI.color;
float alpha = (command.executingIconTimer - Time.realtimeSinceStartup) / Block.executingIconFadeTime;
float alpha = (command.ExecutingIconTimer - Time.realtimeSinceStartup) / Block.executingIconFadeTime;
alpha = Mathf.Clamp01(alpha);
GUI.color = new Color(1f, 1f, 1f, alpha);

28
Assets/Fungus/Flowchart/Editor/FlowchartEditor.cs

@ -91,8 +91,8 @@ namespace Fungus
if (GUILayout.Button(new GUIContent("Center View", "Centers the window view at the center of all blocks in the Flowchart")))
{
// Reset the zoom so we don't have adjust the center position depending on zoom
flowchart.scrollPos = flowchart.centerPosition;
flowchart.zoom = FlowchartWindow.maxZoomValue;
flowchart.ScrollPos = flowchart.CenterPosition;
flowchart.Zoom = FlowchartWindow.maxZoomValue;
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
@ -106,16 +106,16 @@ namespace Fungus
Flowchart t = target as Flowchart;
if (t.variables.Count == 0)
if (t.Variables.Count == 0)
{
t.variablesExpanded = true;
t.VariablesExpanded = true;
}
if (!t.variablesExpanded)
if (!t.VariablesExpanded)
{
if (GUILayout.Button ("Variables (" + t.variables.Count + ")", GUILayout.Height(24)))
if (GUILayout.Button ("Variables (" + t.Variables.Count + ")", GUILayout.Height(24)))
{
t.variablesExpanded = true;
t.VariablesExpanded = true;
}
// Draw disclosure triangle
@ -128,15 +128,15 @@ namespace Fungus
{
Rect listRect = new Rect();
if (t.variables.Count > 0)
if (t.Variables.Count > 0)
{
// Remove any null variables from the list
// Can sometimes happen when upgrading to a new version of Fungus (if .meta GUID changes for a variable class)
for (int i = t.variables.Count - 1; i >= 0; i--)
for (int i = t.Variables.Count - 1; i >= 0; i--)
{
if (t.variables[i] == null)
if (t.Variables[i] == null)
{
t.variables.RemoveAt(i);
t.Variables.RemoveAt(i);
}
}
@ -170,7 +170,7 @@ namespace Fungus
if (GUI.Button (buttonRect, "Variables"))
{
t.variablesExpanded = false;
t.VariablesExpanded = false;
}
// Draw disclosure triangle
@ -249,8 +249,8 @@ namespace Fungus
Undo.RecordObject(flowchart, "Add Variable");
Variable newVariable = flowchart.gameObject.AddComponent(variableType) as Variable;
newVariable.key = flowchart.GetUniqueVariableKey("");
flowchart.variables.Add(newVariable);
newVariable.Key = flowchart.GetUniqueVariableKey("");
flowchart.Variables.Add(newVariable);
// Because this is an async call, we need to force prefab instances to record changes
PrefabUtility.RecordPrefabInstancePropertyModifications(flowchart);

6
Assets/Fungus/Flowchart/Editor/FlowchartMenuItems.cs

@ -23,15 +23,15 @@ namespace Fungus
Flowchart flowchart = go.GetComponent<Flowchart>();
if (flowchart != null)
{
flowchart.version = Flowchart.CURRENT_VERSION;
flowchart.Version = Flowchart.CURRENT_VERSION;
}
// Only the first created Flowchart in the scene should have a default GameStarted block
if (GameObject.FindObjectsOfType<Flowchart>().Length > 1)
{
Block block = go.GetComponent<Block>();
block.eventHandler = null;
GameObject.DestroyImmediate(block.eventHandler);
block._EventHandler = null;
GameObject.DestroyImmediate(block._EventHandler);
}
}

207
Assets/Fungus/Flowchart/Editor/FlowchartWindow.cs

@ -71,13 +71,13 @@ namespace Fungus
}
if (Selection.activeGameObject == null &&
flowchart.selectedBlock != null)
flowchart.SelectedBlock != null)
{
if (blockInspector == null)
{
ShowBlockInspector(flowchart);
}
blockInspector.block = flowchart.selectedBlock;
blockInspector.block = flowchart.SelectedBlock;
}
forceRepaintCount--;
@ -103,11 +103,11 @@ namespace Fungus
Flowchart fs = Selection.activeGameObject.GetComponent<Flowchart>();
if (fs != null)
{
fungusState.selectedFlowchart = fs;
fungusState.SelectedFlowchart = fs;
}
}
return fungusState.selectedFlowchart;
return fungusState.SelectedFlowchart;
}
protected virtual void OnGUI()
@ -122,9 +122,9 @@ namespace Fungus
// Delete any scheduled objects
foreach (Block deleteBlock in deleteList)
{
bool isSelected = (flowchart.selectedBlock == deleteBlock);
bool isSelected = (flowchart.SelectedBlock == deleteBlock);
foreach (Command command in deleteBlock.commandList)
foreach (Command command in deleteBlock.CommandList)
{
Undo.DestroyObjectImmediate(command);
}
@ -160,22 +160,22 @@ namespace Fungus
if (GUILayout.Button(new GUIContent(addTexture, "Add a new block")))
{
Vector2 newNodePosition = new Vector2(50 - flowchart.scrollPos.x,
50 - flowchart.scrollPos.y);
Vector2 newNodePosition = new Vector2(50 - flowchart.ScrollPos.x,
50 - flowchart.ScrollPos.y);
CreateBlock(flowchart, newNodePosition);
}
GUILayout.Space(8);
flowchart.zoom = GUILayout.HorizontalSlider(flowchart.zoom, minZoomValue, maxZoomValue, GUILayout.Width(100));
flowchart.Zoom = GUILayout.HorizontalSlider(flowchart.Zoom, minZoomValue, maxZoomValue, GUILayout.Width(100));
GUILayout.FlexibleSpace();
GUILayout.BeginVertical();
GUILayout.Label(flowchart.name, EditorStyles.whiteBoldLabel);
if (flowchart.description.Length > 0)
if (flowchart.Description.Length > 0)
{
GUILayout.Label(flowchart.description, EditorStyles.helpBox);
GUILayout.Label(flowchart.Description, EditorStyles.helpBox);
}
GUILayout.EndVertical();
@ -189,7 +189,7 @@ namespace Fungus
GUILayout.FlexibleSpace();
flowchart.variablesScrollPos = GUILayout.BeginScrollView(flowchart.variablesScrollPos, GUILayout.MaxHeight(position.height * 0.75f));
flowchart.VariablesScrollPos = GUILayout.BeginScrollView(flowchart.VariablesScrollPos, GUILayout.MaxHeight(position.height * 0.75f));
GUILayout.FlexibleSpace();
@ -200,8 +200,8 @@ namespace Fungus
DestroyImmediate(flowchartEditor);
Rect variableWindowRect = GUILayoutUtility.GetLastRect();
if (flowchart.variablesExpanded &&
flowchart.variables.Count > 0)
if (flowchart.VariablesExpanded &&
flowchart.Variables.Count > 0)
{
variableWindowRect.y -= 20;
variableWindowRect.height += 20;
@ -226,16 +226,18 @@ namespace Fungus
foreach (Block block in blocks)
{
flowchart.scrollViewRect.xMin = Mathf.Min(flowchart.scrollViewRect.xMin, block.nodeRect.xMin - 400);
flowchart.scrollViewRect.xMax = Mathf.Max(flowchart.scrollViewRect.xMax, block.nodeRect.xMax + 400);
flowchart.scrollViewRect.yMin = Mathf.Min(flowchart.scrollViewRect.yMin, block.nodeRect.yMin - 400);
flowchart.scrollViewRect.yMax = Mathf.Max(flowchart.scrollViewRect.yMax, block.nodeRect.yMax + 400);
var newRect = new Rect();
newRect.xMin = Mathf.Min(flowchart.ScrollViewRect.xMin, block._NodeRect.xMin - 400);
newRect.xMax = Mathf.Max(flowchart.ScrollViewRect.xMax, block._NodeRect.xMax + 400);
newRect.yMin = Mathf.Min(flowchart.ScrollViewRect.yMin, block._NodeRect.yMin - 400);
newRect.yMax = Mathf.Max(flowchart.ScrollViewRect.yMax, block._NodeRect.yMax + 400);
flowchart.ScrollViewRect = newRect;
}
// Calc rect for script view
Rect scriptViewRect = new Rect(0, 0, this.position.width / flowchart.zoom, this.position.height / flowchart.zoom);
Rect scriptViewRect = new Rect(0, 0, this.position.width / flowchart.Zoom, this.position.height / flowchart.Zoom);
EditorZoomArea.Begin(flowchart.zoom, scriptViewRect);
EditorZoomArea.Begin(flowchart.Zoom, scriptViewRect);
DrawGrid(flowchart);
@ -245,7 +247,7 @@ namespace Fungus
Event.current.type == EventType.MouseDown &&
!mouseOverVariables)
{
flowchart.selectedBlock = null;
flowchart.SelectedBlock = null;
if (!EditorGUI.actionKey)
{
flowchart.ClearSelectedCommands();
@ -277,46 +279,49 @@ namespace Fungus
{
Block block = blocks[i];
float nodeWidthA = nodeStyle.CalcSize(new GUIContent(block.blockName)).x + 10;
float nodeWidthA = nodeStyle.CalcSize(new GUIContent(block.BlockName)).x + 10;
float nodeWidthB = 0f;
if (block.eventHandler != null)
if (block._EventHandler != null)
{
nodeWidthB = nodeStyle.CalcSize(new GUIContent(block.eventHandler.GetSummary())).x + 10;
nodeWidthB = nodeStyle.CalcSize(new GUIContent(block._EventHandler.GetSummary())).x + 10;
}
block.nodeRect.width = Mathf.Max(Mathf.Max(nodeWidthA, nodeWidthB), 120);
block.nodeRect.height = 40;
if (Event.current.button == 0)
{
Rect tempRect = block._NodeRect;
tempRect.width = Mathf.Max(Mathf.Max(nodeWidthA, nodeWidthB), 120);
tempRect.height = 40;
if (Event.current.type == EventType.MouseDrag && dragWindowId == i)
{
block.nodeRect.x += Event.current.delta.x;
block.nodeRect.y += Event.current.delta.y;
tempRect.x += Event.current.delta.x;
tempRect.y += Event.current.delta.y;
forceRepaintCount = 6;
}
else if (Event.current.type == EventType.MouseUp &&
dragWindowId == i)
{
Vector2 newPos = new Vector2(block.nodeRect.x, block.nodeRect.y);
Vector2 newPos = new Vector2(tempRect.x, tempRect.y);
block.nodeRect.x = startDragPosition.x;
block.nodeRect.y = startDragPosition.y;
tempRect.x = startDragPosition.x;
tempRect.y = startDragPosition.y;
Undo.RecordObject(block, "Node Position");
block.nodeRect.x = newPos.x;
block.nodeRect.y = newPos.y;
tempRect.x = newPos.x;
tempRect.y = newPos.y;
dragWindowId = -1;
forceRepaintCount = 6;
}
block._NodeRect = tempRect;
}
Rect windowRect = new Rect(block.nodeRect);
windowRect.x += flowchart.scrollPos.x;
windowRect.y += flowchart.scrollPos.y;
Rect windowRect = new Rect(block._NodeRect);
windowRect.x += flowchart.ScrollPos.x;
windowRect.y += flowchart.ScrollPos.y;
GUILayout.Window(i, windowRect, DrawWindow, "", windowStyle);
@ -330,10 +335,10 @@ namespace Fungus
// Draw Event Handler labels
foreach (Block block in blocks)
{
if (block.eventHandler != null)
if (block._EventHandler != null)
{
string handlerLabel = "";
EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(block.eventHandler.GetType());
EventHandlerInfoAttribute info = EventHandlerEditor.GetEventHandlerInfo(block._EventHandler.GetType());
if (info != null)
{
handlerLabel = "<" + info.EventHandlerName + "> ";
@ -345,10 +350,10 @@ namespace Fungus
handlerStyle.margin.bottom = 0;
handlerStyle.alignment = TextAnchor.MiddleCenter;
Rect rect = new Rect(block.nodeRect);
rect.height = handlerStyle.CalcHeight(new GUIContent(handlerLabel), block.nodeRect.width);
rect.x += flowchart.scrollPos.x;
rect.y += flowchart.scrollPos.y - rect.height;
Rect rect = new Rect(block._NodeRect);
rect.height = handlerStyle.CalcHeight(new GUIContent(handlerLabel), block._NodeRect.width);
rect.x += flowchart.ScrollPos.x;
rect.y += flowchart.ScrollPos.y - rect.height;
GUI.Label(rect, handlerLabel, handlerStyle);
}
@ -362,23 +367,23 @@ namespace Fungus
{
if (b.IsExecuting())
{
b.executingIconTimer = Time.realtimeSinceStartup + Block.executingIconFadeTime;
b.activeCommand.executingIconTimer = Time.realtimeSinceStartup + Block.executingIconFadeTime;
b.ExecutingIconTimer = Time.realtimeSinceStartup + Block.executingIconFadeTime;
b.ActiveCommand.ExecutingIconTimer = Time.realtimeSinceStartup + Block.executingIconFadeTime;
forceRepaintCount = 6;
}
if (b.executingIconTimer > Time.realtimeSinceStartup)
if (b.ExecutingIconTimer > Time.realtimeSinceStartup)
{
Rect rect = new Rect(b.nodeRect);
Rect rect = new Rect(b._NodeRect);
rect.x += flowchart.scrollPos.x - 37;
rect.y += flowchart.scrollPos.y + 3;
rect.x += flowchart.ScrollPos.x - 37;
rect.y += flowchart.ScrollPos.y + 3;
rect.width = 34;
rect.height = 34;
if (!b.IsExecuting())
{
float alpha = (b.executingIconTimer - Time.realtimeSinceStartup) / Block.executingIconFadeTime;
float alpha = (b.ExecutingIconTimer - Time.realtimeSinceStartup) / Block.executingIconFadeTime;
alpha = Mathf.Clamp01(alpha);
GUI.color = new Color(1f, 1f, 1f, alpha);
}
@ -408,15 +413,15 @@ namespace Fungus
return;
}
Vector2 min = blocks[0].nodeRect.min;
Vector2 max = blocks[0].nodeRect.max;
Vector2 min = blocks[0]._NodeRect.min;
Vector2 max = blocks[0]._NodeRect.max;
foreach (Block block in blocks)
{
min.x = Mathf.Min(min.x, block.nodeRect.center.x);
min.y = Mathf.Min(min.y, block.nodeRect.center.y);
max.x = Mathf.Max(max.x, block.nodeRect.center.x);
max.y = Mathf.Max(max.y, block.nodeRect.center.y);
min.x = Mathf.Min(min.x, block._NodeRect.center.x);
min.y = Mathf.Min(min.y, block._NodeRect.center.y);
max.x = Mathf.Max(max.x, block._NodeRect.center.x);
max.y = Mathf.Max(max.y, block._NodeRect.center.y);
}
Vector2 center = (min + max) * -0.5f;
@ -424,7 +429,7 @@ namespace Fungus
center.x += position.width * 0.5f;
center.y += position.height * 0.5f;
flowchart.centerPosition = center;
flowchart.CenterPosition = center;
}
protected virtual void PanAndZoom(Flowchart flowchart)
@ -454,7 +459,7 @@ namespace Fungus
if (drag)
{
flowchart.scrollPos += Event.current.delta;
flowchart.ScrollPos += Event.current.delta;
forceRepaintCount = 6;
}
@ -475,16 +480,16 @@ namespace Fungus
if (zoom)
{
flowchart.zoom -= Event.current.delta.y * 0.01f;
flowchart.zoom = Mathf.Clamp(flowchart.zoom, minZoomValue, maxZoomValue);
flowchart.Zoom -= Event.current.delta.y * 0.01f;
flowchart.Zoom = Mathf.Clamp(flowchart.Zoom, minZoomValue, maxZoomValue);
forceRepaintCount = 6;
}
}
protected virtual void DrawGrid(Flowchart flowchart)
{
float width = this.position.width / flowchart.zoom;
float height = this.position.height / flowchart.zoom;
float width = this.position.width / flowchart.Zoom;
float height = this.position.height / flowchart.Zoom;
// Match background color of scene view
if (EditorGUIUtility.isProSkin)
@ -502,14 +507,14 @@ namespace Fungus
float gridSize = 128f;
float x = flowchart.scrollPos.x % gridSize;
float x = flowchart.ScrollPos.x % gridSize;
while (x < width)
{
GLDraw.DrawLine(new Vector2(x, 0), new Vector2(x, height), color, 1f);
x += gridSize;
}
float y = (flowchart.scrollPos.y % gridSize);
float y = (flowchart.ScrollPos.y % gridSize);
while (y < height)
{
if (y >= 0)
@ -524,11 +529,11 @@ namespace Fungus
{
// Select the block and also select currently executing command
ShowBlockInspector(flowchart);
flowchart.selectedBlock = block;
flowchart.SelectedBlock = block;
flowchart.ClearSelectedCommands();
if (block.activeCommand != null)
if (block.ActiveCommand != null)
{
flowchart.AddSelectedCommand(block.activeCommand);
flowchart.AddSelectedCommand(block.ActiveCommand);
}
}
@ -537,7 +542,7 @@ namespace Fungus
Block newBlock = flowchart.CreateBlock(position);
Undo.RegisterCreatedObjectUndo(newBlock, "New Block");
ShowBlockInspector(flowchart);
flowchart.selectedBlock = newBlock;
flowchart.SelectedBlock = newBlock;
flowchart.ClearSelectedCommands();
return newBlock;
@ -545,7 +550,7 @@ namespace Fungus
protected virtual void DeleteBlock(Flowchart flowchart, Block block)
{
foreach (Command command in block.commandList)
foreach (Command command in block.CommandList)
{
Undo.DestroyObjectImmediate(command);
}
@ -574,8 +579,8 @@ namespace Fungus
Event.current.alt == false)
{
dragWindowId = windowId;
startDragPosition.x = block.nodeRect.x;
startDragPosition.y = block.nodeRect.y;
startDragPosition.x = block._NodeRect.x;
startDragPosition.y = block._NodeRect.y;
}
if (windowId < windowBlockMap.Count)
@ -588,11 +593,11 @@ namespace Fungus
}
}
bool selected = (flowchart.selectedBlock == block);
bool selected = (flowchart.SelectedBlock == block);
GUIStyle nodeStyleCopy = new GUIStyle(nodeStyle);
if (block.eventHandler != null)
if (block._EventHandler != null)
{
nodeStyleCopy.normal.background = selected ? FungusEditorResources.texEventNodeOn : FungusEditorResources.texEventNodeOff;
}
@ -624,17 +629,19 @@ namespace Fungus
nodeStyleCopy.normal.textColor = Color.black;
// Make sure node is wide enough to fit the node name text
float width = nodeStyleCopy.CalcSize(new GUIContent(block.blockName)).x;
block.nodeRect.width = Mathf.Max (block.nodeRect.width, width);
float width = nodeStyleCopy.CalcSize(new GUIContent(block.BlockName)).x;
Rect tempRect = block._NodeRect;
tempRect.width = Mathf.Max (block._NodeRect.width, width);
block._NodeRect = tempRect;
GUI.backgroundColor = Color.white;
GUILayout.Box(block.blockName, nodeStyleCopy, GUILayout.Width(block.nodeRect.width), GUILayout.Height(block.nodeRect.height));
GUILayout.Box(block.BlockName, nodeStyleCopy, GUILayout.Width(block._NodeRect.width), GUILayout.Height(block._NodeRect.height));
if (block.description.Length > 0)
if (block.Description.Length > 0)
{
GUIStyle descriptionStyle = new GUIStyle(EditorStyles.helpBox);
descriptionStyle.wordWrap = true;
GUILayout.Label(block.description, descriptionStyle);
GUILayout.Label(block.Description, descriptionStyle);
}
if (Event.current.type == EventType.ContextClick)
@ -657,9 +664,9 @@ namespace Fungus
List<Block> connectedBlocks = new List<Block>();
bool blockIsSelected = (flowchart.selectedBlock == block);
bool blockIsSelected = (flowchart.SelectedBlock == block);
foreach (Command command in block.commandList)
foreach (Command command in block.CommandList)
{
if (command == null)
{
@ -667,7 +674,7 @@ namespace Fungus
}
bool commandIsSelected = false;
foreach (Command selectedCommand in flowchart.selectedCommands)
foreach (Command selectedCommand in flowchart.SelectedCommands)
{
if (selectedCommand == command)
{
@ -676,7 +683,7 @@ namespace Fungus
}
}
bool highlight = command.isExecuting || (blockIsSelected && commandIsSelected);
bool highlight = command.IsExecuting || (blockIsSelected && commandIsSelected);
if (highlightedOnly && !highlight ||
!highlightedOnly && highlight)
@ -696,13 +703,13 @@ namespace Fungus
continue;
}
Rect startRect = new Rect(block.nodeRect);
startRect.x += flowchart.scrollPos.x;
startRect.y += flowchart.scrollPos.y;
Rect startRect = new Rect(block._NodeRect);
startRect.x += flowchart.ScrollPos.x;
startRect.y += flowchart.ScrollPos.y;
Rect endRect = new Rect(blockB.nodeRect);
endRect.x += flowchart.scrollPos.x;
endRect.y += flowchart.scrollPos.y;
Rect endRect = new Rect(blockB._NodeRect);
endRect.x += flowchart.ScrollPos.x;
endRect.y += flowchart.ScrollPos.y;
DrawRectConnection(startRect, endRect, highlight);
}
@ -769,18 +776,18 @@ namespace Fungus
Flowchart flowchart = GetFlowchart();
Block block = obj as Block;
Vector2 newPosition = new Vector2(block.nodeRect.position.x +
block.nodeRect.width + 20,
block.nodeRect.y);
Vector2 newPosition = new Vector2(block._NodeRect.position.x +
block._NodeRect.width + 20,
block._NodeRect.y);
Block oldBlock = block;
Block newBlock = FlowchartWindow.CreateBlock(flowchart, newPosition);
newBlock.blockName = flowchart.GetUniqueBlockKey(oldBlock.blockName + " (Copy)");
newBlock.BlockName = flowchart.GetUniqueBlockKey(oldBlock.BlockName + " (Copy)");
Undo.RecordObject(newBlock, "Duplicate Block");
foreach (Command command in oldBlock.commandList)
foreach (Command command in oldBlock.CommandList)
{
if (ComponentUtility.CopyComponent(command))
{
@ -790,8 +797,8 @@ namespace Fungus
Command pastedCommand = commands.Last<Command>();
if (pastedCommand != null)
{
pastedCommand.itemId = flowchart.NextItemId();
newBlock.commandList.Add (pastedCommand);
pastedCommand.ItemId = flowchart.NextItemId();
newBlock.CommandList.Add (pastedCommand);
}
}
@ -800,9 +807,9 @@ namespace Fungus
}
}
if (oldBlock.eventHandler != null)
if (oldBlock._EventHandler != null)
{
if (ComponentUtility.CopyComponent(oldBlock.eventHandler))
if (ComponentUtility.CopyComponent(oldBlock._EventHandler))
{
if (ComponentUtility.PasteComponentAsNew(flowchart.gameObject))
{
@ -810,8 +817,8 @@ namespace Fungus
EventHandler pastedEventHandler = eventHandlers.Last<EventHandler>();
if (pastedEventHandler != null)
{
pastedEventHandler.parentBlock = newBlock;
newBlock.eventHandler = pastedEventHandler;
pastedEventHandler.ParentBlock = newBlock;
newBlock._EventHandler = pastedEventHandler;
}
}
}

36
Assets/Fungus/Flowchart/Editor/InvokeMethodEditor.cs

@ -26,23 +26,23 @@ namespace Fungus
targetMethod = target as InvokeMethod;
if (targetMethod == null || targetMethod.targetObject == null)
if (targetMethod == null || targetMethod.TargetObject == null)
return;
SerializedObject objSerializedTarget = new SerializedObject(targetMethod);
string component = ShowComponents(objSerializedTarget, targetMethod.targetObject);
string component = ShowComponents(objSerializedTarget, targetMethod.TargetObject);
// show component methods if selected
if (!string.IsNullOrEmpty(component))
{
var method = ShowMethods(objSerializedTarget, targetMethod.targetObject, component);
var method = ShowMethods(objSerializedTarget, targetMethod.TargetObject, component);
// show method parameters if selected
if (method != null)
{
objSerializedTarget.ApplyModifiedProperties();
ShowParameters(objSerializedTarget, targetMethod.targetObject, method);
ShowParameters(objSerializedTarget, targetMethod.TargetObject, method);
ShowReturnValue(objSerializedTarget, method);
}
}
@ -172,7 +172,7 @@ namespace Fungus
if (isDrawn)
{
var vars = GetFungusVariablesByType(targetMethod.GetFlowchart().variables, objParam.ParameterType);
var vars = GetFungusVariablesByType(targetMethod.GetFlowchart().Variables, objParam.ParameterType);
var values = new string[] { "<Value>" };
var displayValue = values.Concat(vars).ToList();
@ -241,7 +241,7 @@ namespace Fungus
if (saveReturnValueProp.boolValue)
{
var vars = GetFungusVariablesByType(targetMethod.GetFlowchart().variables, method.ReturnType).ToList();
var vars = GetFungusVariablesByType(targetMethod.GetFlowchart().Variables, method.ReturnType).ToList();
int index = vars.IndexOf(returnValueKeyProp.stringValue);
index = EditorGUILayout.Popup(method.ReturnType.Name, index, vars.ToArray());
@ -367,51 +367,51 @@ namespace Fungus
if (type == typeof(int))
{
result = (from v in variables where v.GetType() == typeof(IntegerVariable) select v.key).ToArray();
result = (from v in variables where v.GetType() == typeof(IntegerVariable) select v.Key).ToArray();
}
else if (type == typeof(bool))
{
result = (from v in variables where v.GetType() == typeof(BooleanVariable) select v.key).ToArray();
result = (from v in variables where v.GetType() == typeof(BooleanVariable) select v.Key).ToArray();
}
else if (type == typeof(float))
{
result = (from v in variables where v.GetType() == typeof(FloatVariable) select v.key).ToArray();
result = (from v in variables where v.GetType() == typeof(FloatVariable) select v.Key).ToArray();
}
else if (type == typeof(string))
{
result = (from v in variables where v.GetType() == typeof(StringVariable) select v.key).ToArray();
result = (from v in variables where v.GetType() == typeof(StringVariable) select v.Key).ToArray();
}
else if (type == typeof(Color))
{
result = (from v in variables where v.GetType() == typeof(ColorVariable) select v.key).ToArray();
result = (from v in variables where v.GetType() == typeof(ColorVariable) select v.Key).ToArray();
}
else if (type == typeof(UnityEngine.GameObject))
{
result = (from v in variables where v.GetType() == typeof(GameObjectVariable) select v.key).ToArray();
result = (from v in variables where v.GetType() == typeof(GameObjectVariable) select v.Key).ToArray();
}
else if (type == typeof(UnityEngine.Material))
{
result = (from v in variables where v.GetType() == typeof(MaterialVariable) select v.key).ToArray();
result = (from v in variables where v.GetType() == typeof(MaterialVariable) select v.Key).ToArray();
}
else if (type == typeof(UnityEngine.Sprite))
{
result = (from v in variables where v.GetType() == typeof(SpriteVariable) select v.key).ToArray();
result = (from v in variables where v.GetType() == typeof(SpriteVariable) select v.Key).ToArray();
}
else if (type == typeof(UnityEngine.Texture))
{
result = (from v in variables where v.GetType() == typeof(TextureVariable) select v.key).ToArray();
result = (from v in variables where v.GetType() == typeof(TextureVariable) select v.Key).ToArray();
}
else if (type == typeof(UnityEngine.Vector2))
{
result = (from v in variables where v.GetType() == typeof(Vector2Variable) select v.key).ToArray();
result = (from v in variables where v.GetType() == typeof(Vector2Variable) select v.Key).ToArray();
}
else if (type == typeof(UnityEngine.Vector3))
{
result = (from v in variables where v.GetType() == typeof(Vector3Variable) select v.key).ToArray();
result = (from v in variables where v.GetType() == typeof(Vector3Variable) select v.Key).ToArray();
}
else if (type.IsSubclassOf(typeof(UnityEngine.Object)))
{
result = (from v in variables where v.GetType() == typeof(ObjectVariable) select v.key).ToArray();
result = (from v in variables where v.GetType() == typeof(ObjectVariable) select v.Key).ToArray();
}
return result;

4
Assets/Fungus/Flowchart/Editor/LabelEditor.cs

@ -32,7 +32,7 @@ namespace Fungus
int index = 0;
int selectedIndex = 0;
foreach (Command command in block.commandList)
foreach (Command command in block.CommandList)
{
Label label = command as Label;
if (label == null)
@ -40,7 +40,7 @@ namespace Fungus
continue;
}
labelKeys.Add(label.key);
labelKeys.Add(label.Key);
labelObjects.Add(label);
index++;

2
Assets/Fungus/Flowchart/Editor/SetVariableEditor.cs

@ -73,7 +73,7 @@ namespace Fungus
}
int selectedIndex = 0;
switch (t.setOperator)
switch (t._SetOperator)
{
default:
case SetVariable.SetOperator.Assign:

8
Assets/Fungus/Flowchart/Editor/VariableEditor.cs

@ -50,7 +50,7 @@ namespace Fungus
variableKeys.Add(defaultText);
variableObjects.Add(null);
List<Variable> variables = flowchart.variables;
List<Variable> variables = flowchart.Variables;
int index = 0;
int selectedIndex = 0;
@ -63,7 +63,7 @@ namespace Fungus
// occurs we just skip displaying the property for this frame.
if (selectedVariable != null &&
selectedVariable.gameObject != flowchart.gameObject &&
selectedVariable.scope == VariableScope.Private)
selectedVariable.Scope == VariableScope.Private)
{
property.objectReferenceValue = null;
return;
@ -79,7 +79,7 @@ namespace Fungus
}
}
variableKeys.Add(v.key);
variableKeys.Add(v.Key);
variableObjects.Add(v);
index++;
@ -109,7 +109,7 @@ namespace Fungus
}
}
variableKeys.Add(fs.name + " / " + v.key);
variableKeys.Add(fs.name + " / " + v.Key);
variableObjects.Add(v);
index++;

18
Assets/Fungus/Flowchart/Editor/VariableListAdaptor.cs

@ -133,15 +133,15 @@ namespace Fungus
// Highlight if an active or selected command is referencing this variable
bool highlight = false;
if (flowchart.selectedBlock != null)
if (flowchart.SelectedBlock != null)
{
if (Application.isPlaying && flowchart.selectedBlock.IsExecuting())
if (Application.isPlaying && flowchart.SelectedBlock.IsExecuting())
{
highlight = flowchart.selectedBlock.activeCommand.HasReference(variable);
highlight = flowchart.SelectedBlock.ActiveCommand.HasReference(variable);
}
else if (!Application.isPlaying && flowchart.selectedCommands.Count > 0)
else if (!Application.isPlaying && flowchart.SelectedCommands.Count > 0)
{
foreach (Command selectedCommand in flowchart.selectedCommands)
foreach (Command selectedCommand in flowchart.SelectedCommands)
{
if (selectedCommand == null)
{
@ -163,8 +163,8 @@ namespace Fungus
GUI.Box(position, "");
}
string key = variable.key;
VariableScope scope = variable.scope;
string key = variable.Key;
VariableScope scope = variable.Scope;
// To access properties in a monobehavior, you have to new a SerializedObject
// http://answers.unity3d.com/questions/629803/findrelativeproperty-never-worked-for-me-how-does.html
@ -174,7 +174,7 @@ namespace Fungus
GUI.Label(rects[0], variableInfo.VariableType);
key = EditorGUI.TextField(rects[1], variable.key);
key = EditorGUI.TextField(rects[1], variable.Key);
SerializedProperty keyProp = variableObject.FindProperty("key");
keyProp.stringValue = flowchart.GetUniqueVariableKey(key, variable);
@ -182,7 +182,7 @@ namespace Fungus
EditorGUI.PropertyField(rects[2], defaultProp, new GUIContent(""));
SerializedProperty scopeProp = variableObject.FindProperty("scope");
scope = (VariableScope)EditorGUI.EnumPopup(rects[3], variable.scope);
scope = (VariableScope)EditorGUI.EnumPopup(rects[3], variable.Scope);
scopeProp.enumValueIndex = (int)scope;
variableObject.ApplyModifiedProperties();

89
Assets/Fungus/Flowchart/Scripts/Block.cs

@ -22,39 +22,44 @@ namespace Fungus
Executing,
}
[NonSerialized]
public ExecutionState executionState;
protected ExecutionState executionState;
[HideInInspector]
public int itemId = -1; // Invalid flowchart item id
public ExecutionState State { get { return executionState; } }
[SerializeField] protected int itemId = -1; // Invalid flowchart item id
public int ItemId { get { return itemId; } set { itemId = value; } }
[FormerlySerializedAs("sequenceName")]
[Tooltip("The name of the block node as displayed in the Flowchart window")]
public string blockName = "New Block";
[SerializeField] protected string blockName = "New Block";
public string BlockName { get { return blockName; } set { blockName = value; } }
[TextArea(2, 5)]
[Tooltip("Description text to display under the block node")]
public string description = "";
[SerializeField] protected string description = "";
public string Description { get { return description; } }
[Tooltip("An optional Event Handler which can execute the block when an event occurs")]
public EventHandler eventHandler;
[SerializeField] protected EventHandler eventHandler;
public EventHandler _EventHandler { get { return eventHandler; } set { eventHandler = value; } }
[HideInInspector]
[System.NonSerialized]
public Command activeCommand;
protected Command activeCommand;
public Command ActiveCommand { get { return activeCommand; } }
// Index of last command executed before the current one
// -1 indicates no previous command
[HideInInspector]
[System.NonSerialized]
public int previousActiveCommandIndex = -1;
protected int previousActiveCommandIndex = -1;
public float ExecutingIconTimer { get; set; }
[HideInInspector]
[System.NonSerialized]
public float executingIconTimer;
[SerializeField] protected List<Command> commandList = new List<Command>();
[HideInInspector]
public List<Command> commandList = new List<Command>();
public List<Command> CommandList { get { return commandList; } }
protected int executionCount;
@ -66,8 +71,9 @@ namespace Fungus
/**
* Controls the next command to execute in the block execution coroutine.
*/
[NonSerialized]
public int jumpToCommandIndex = -1;
protected int jumpToCommandIndex = -1;
public int JumpToCommandIndex { set { jumpToCommandIndex = value; } }
protected bool executionInfoSet = false;
@ -88,8 +94,8 @@ namespace Fungus
continue;
}
command.parentBlock = this;
command.commandIndex = index++;
command.ParentBlock = this;
command.CommandIndex = index++;
}
// Ensure all commands are at their correct indent level
@ -114,7 +120,7 @@ namespace Fungus
continue;
}
command.commandIndex = index++;
command.CommandIndex = index++;
}
}
#endif
@ -124,19 +130,6 @@ namespace Fungus
return GetComponent<Flowchart>();
}
public virtual bool HasError()
{
foreach (Command command in commandList)
{
if (command.errorMessage.Length > 0)
{
return true;
}
}
return false;
}
public virtual bool IsExecuting()
{
return (executionState == ExecutionState.Executing);
@ -179,7 +172,7 @@ namespace Fungus
#if UNITY_EDITOR
// Select the executing block & the first command
flowchart.selectedBlock = this;
flowchart.SelectedBlock = this;
if (commandList.Count > 0)
{
flowchart.ClearSelectedCommands();
@ -205,7 +198,7 @@ namespace Fungus
commandList[i].GetType() == typeof(Comment) ||
commandList[i].GetType() == typeof(Label)))
{
i = commandList[i].commandIndex + 1;
i = commandList[i].CommandIndex + 1;
}
if (i >= commandList.Count)
@ -220,7 +213,7 @@ namespace Fungus
}
else
{
previousActiveCommandIndex = activeCommand.commandIndex;
previousActiveCommandIndex = activeCommand.CommandIndex;
}
Command command = commandList[i];
@ -229,18 +222,18 @@ namespace Fungus
if (flowchart.gameObject.activeInHierarchy)
{
// Auto select a command in some situations
if ((flowchart.selectedCommands.Count == 0 && i == 0) ||
(flowchart.selectedCommands.Count == 1 && flowchart.selectedCommands[0].commandIndex == previousActiveCommandIndex))
if ((flowchart.SelectedCommands.Count == 0 && i == 0) ||
(flowchart.SelectedCommands.Count == 1 && flowchart.SelectedCommands[0].CommandIndex == previousActiveCommandIndex))
{
flowchart.ClearSelectedCommands();
flowchart.AddSelectedCommand(commandList[i]);
}
}
command.isExecuting = true;
command.IsExecuting = true;
// This icon timer is managed by the FlowchartWindow class, but we also need to
// set it here in case a command starts and finishes execution before the next window update.
command.executingIconTimer = Time.realtimeSinceStartup + executingIconFadeTime;
command.ExecutingIconTimer = Time.realtimeSinceStartup + executingIconFadeTime;
command.Execute();
// Wait until the executing command sets another command to jump to via Command.Continue()
@ -250,13 +243,13 @@ namespace Fungus
}
#if UNITY_EDITOR
if (flowchart.stepPause > 0f)
if (flowchart.StepPause > 0f)
{
yield return new WaitForSeconds(flowchart.stepPause);
yield return new WaitForSeconds(flowchart.StepPause);
}
#endif
command.isExecuting = false;
command.IsExecuting = false;
}
executionState = ExecutionState.Idle;
@ -273,7 +266,7 @@ namespace Fungus
// Tell the executing command to stop immediately
if (activeCommand != null)
{
activeCommand.isExecuting = false;
activeCommand.IsExecuting = false;
activeCommand.OnStopExecuting();
}
@ -323,7 +316,7 @@ namespace Fungus
// Negative indent level is not permitted
indentLevel = Math.Max(indentLevel, 0);
command.indentLevel = indentLevel;
command.IndentLevel = indentLevel;
if (command.OpenBlock())
{

39
Assets/Fungus/Flowchart/Scripts/Command.cs

@ -39,36 +39,37 @@ namespace Fungus
{
[FormerlySerializedAs("commandId")]
[HideInInspector]
public int itemId = -1; // Invalid flowchart item id
[SerializeField] protected int itemId = -1; // Invalid flowchart item id
[HideInInspector]
public string errorMessage = "";
public int ItemId { get { return itemId; } set { itemId = value; } }
protected string errorMessage = "";
public string ErrorMessage { get { return errorMessage; } }
[HideInInspector]
public int indentLevel;
[SerializeField] protected int indentLevel;
public int IndentLevel { get { return indentLevel; } set { indentLevel = value; } }
[NonSerialized]
public int commandIndex;
public int CommandIndex { get; set; }
/**
* Set to true by the parent block while the command is executing.
*/
[NonSerialized]
public bool isExecuting;
public bool IsExecuting { get; set; }
/**
* Timer used to control appearance of executing icon in inspector.
*/
[NonSerialized]
public float executingIconTimer;
public float ExecutingIconTimer { get; set; }
/**
* Reference to the Block object that this command belongs to.
* This reference is only populated at runtime and in the editor when the
* block is selected.
*/
[NonSerialized]
public Block parentBlock;
public Block ParentBlock { get; set; }
public virtual Flowchart GetFlowchart()
{
@ -89,27 +90,27 @@ namespace Fungus
public virtual void Continue()
{
// This is a noop if the Block has already been stopped
if (isExecuting)
if (IsExecuting)
{
Continue(commandIndex + 1);
Continue(CommandIndex + 1);
}
}
public virtual void Continue(int nextCommandIndex)
{
OnExit();
if (parentBlock != null)
if (ParentBlock != null)
{
parentBlock.jumpToCommandIndex = nextCommandIndex;
ParentBlock.JumpToCommandIndex = nextCommandIndex;
}
}
public virtual void StopParentBlock()
{
OnExit();
if (parentBlock != null)
if (ParentBlock != null)
{
parentBlock.Stop();
ParentBlock.Stop();
}
}
@ -215,7 +216,7 @@ namespace Fungus
return "";
}
string localizationId = GetFlowchart().localizationId;
string localizationId = GetFlowchart().LocalizationId;
if (localizationId.Length == 0)
{
localizationId = flowchart.name;

16
Assets/Fungus/Flowchart/Scripts/Commands/Break.cs

@ -21,13 +21,13 @@ namespace Fungus
// Find index of previous while command
int whileIndex = -1;
int whileIndentLevel = -1;
for (int i = commandIndex - 1; i >=0; --i)
for (int i = CommandIndex - 1; i >=0; --i)
{
While whileCommand = parentBlock.commandList[i] as While;
While whileCommand = ParentBlock.CommandList[i] as While;
if (whileCommand != null)
{
whileIndex = i;
whileIndentLevel = whileCommand.indentLevel;
whileIndentLevel = whileCommand.IndentLevel;
break;
}
}
@ -40,18 +40,18 @@ namespace Fungus
}
// Find matching End statement at same indent level as While
for (int i = whileIndex + 1; i < parentBlock.commandList.Count; ++i)
for (int i = whileIndex + 1; i < ParentBlock.CommandList.Count; ++i)
{
End endCommand = parentBlock.commandList[i] as End;
End endCommand = ParentBlock.CommandList[i] as End;
if (endCommand != null &&
endCommand.indentLevel == whileIndentLevel)
endCommand.IndentLevel == whileIndentLevel)
{
// Sanity check that break command is actually between the While and End commands
if (commandIndex > whileIndex && commandIndex < endCommand.commandIndex)
if (CommandIndex > whileIndex && CommandIndex < endCommand.CommandIndex)
{
// Continue at next command after End
Continue (endCommand.commandIndex + 1);
Continue (endCommand.CommandIndex + 1);
return;
}
else

18
Assets/Fungus/Flowchart/Scripts/Commands/Call.cs

@ -19,15 +19,15 @@ namespace Fungus
public class Call : Command
{
[Tooltip("Flowchart which contains the block to execute. If none is specified then the current Flowchart is used.")]
public Flowchart targetFlowchart;
[SerializeField] protected Flowchart targetFlowchart;
[FormerlySerializedAs("targetSequence")]
[Tooltip("Block to start executing")]
public Block targetBlock;
[SerializeField] protected Block targetBlock;
[Tooltip("Command index to start executing")]
[FormerlySerializedAs("commandIndex")]
public int startIndex;
[SerializeField] protected int startIndex;
public enum CallMode
{
@ -37,7 +37,7 @@ namespace Fungus
}
[Tooltip("Select if the calling block should stop or continue executing commands, or wait until the called block finishes.")]
public CallMode callMode;
[SerializeField] protected CallMode callMode;
public override void OnEnter()
{
@ -46,7 +46,7 @@ namespace Fungus
if (targetBlock != null)
{
// Check if calling your own parent block
if (targetBlock == parentBlock)
if (targetBlock == ParentBlock)
{
// Just ignore the callmode in this case, and jump to first command in list
Continue(0);
@ -58,7 +58,7 @@ namespace Fungus
if (callMode == CallMode.WaitUntilFinished)
{
onComplete = delegate {
flowchart.selectedBlock = parentBlock;
flowchart.SelectedBlock = ParentBlock;
Continue();
};
}
@ -68,9 +68,9 @@ namespace Fungus
{
// If the executing block is currently selected then follow the execution
// onto the next block in the inspector.
if (flowchart.selectedBlock == parentBlock)
if (flowchart.SelectedBlock == ParentBlock)
{
flowchart.selectedBlock = targetBlock;
flowchart.SelectedBlock = targetBlock;
}
StartCoroutine(targetBlock.Execute(startIndex, onComplete));
@ -110,7 +110,7 @@ namespace Fungus
}
else
{
summary = targetBlock.blockName;
summary = targetBlock.BlockName;
}
switch (callMode)

6
Assets/Fungus/Flowchart/Scripts/Commands/CallMethod.cs

@ -18,13 +18,13 @@ namespace Fungus
public class CallMethod : Command
{
[Tooltip("Target monobehavior which contains the method we want to call")]
public GameObject targetObject;
[SerializeField] protected GameObject targetObject;
[Tooltip("Name of the method to call")]
public string methodName = "";
[SerializeField] protected string methodName = "";
[Tooltip("Delay (in seconds) before the method will be called")]
public float delay;
[SerializeField] protected float delay;
public override void OnEnter()
{

4
Assets/Fungus/Flowchart/Scripts/Commands/Comment.cs

@ -16,11 +16,11 @@ namespace Fungus
public class Comment : Command
{
[Tooltip("Name of Commenter")]
public string commenterName = "";
[SerializeField] protected string commenterName = "";
[Tooltip("Text to display for this comment")]
[TextArea(2,4)]
public string commentText = "";
[SerializeField] protected string commentText = "";
public override void OnEnter()
{

2
Assets/Fungus/Flowchart/Scripts/Commands/Condition.cs

@ -23,7 +23,7 @@ namespace Fungus
public abstract class Condition : Command
{
[Tooltip("The type of comparison to be performed")]
public CompareOperator compareOperator;
[SerializeField] protected CompareOperator compareOperator;
public static string GetOperatorDescription(CompareOperator compareOperator)
{

4
Assets/Fungus/Flowchart/Scripts/Commands/DebugLog.cs

@ -22,10 +22,10 @@ namespace Fungus
}
[Tooltip("Display type of debug log info")]
public DebugLogType logType;
[SerializeField] protected DebugLogType logType;
[Tooltip("Text to write to the debug log. Supports variable substitution, e.g. {$Myvar}")]
public StringDataMulti logMessage;
[SerializeField] protected StringDataMulti logMessage;
public override void OnEnter ()
{

2
Assets/Fungus/Flowchart/Scripts/Commands/DeleteSaveKey.cs

@ -16,7 +16,7 @@ namespace Fungus
public class DeleteSaveKey : Command
{
[Tooltip("Name of the saved value. Supports variable substition e.g. \"player_{$PlayerNumber}")]
public string key = "";
[SerializeField] protected string key = "";
public override void OnEnter()
{

2
Assets/Fungus/Flowchart/Scripts/Commands/Destroy.cs

@ -18,7 +18,7 @@ namespace Fungus
public class Destroy : Command
{
[Tooltip("Reference to game object to destroy")]
public GameObjectData _targetGameObject;
[SerializeField] protected GameObjectData _targetGameObject;
public override void OnEnter()
{

12
Assets/Fungus/Flowchart/Scripts/Commands/Else.cs

@ -17,13 +17,13 @@ namespace Fungus
{
public override void OnEnter()
{
if (parentBlock == null)
if (ParentBlock == null)
{
return;
}
// Stop if this is the last command in the list
if (commandIndex >= parentBlock.commandList.Count - 1)
if (CommandIndex >= ParentBlock.CommandList.Count - 1)
{
StopParentBlock();
return;
@ -31,17 +31,17 @@ namespace Fungus
// Find the next End command at the same indent level as this Else command
int indent = indentLevel;
for (int i = commandIndex + 1; i < parentBlock.commandList.Count; ++i)
for (int i = CommandIndex + 1; i < ParentBlock.CommandList.Count; ++i)
{
Command command = parentBlock.commandList[i];
Command command = ParentBlock.CommandList[i];
if (command.indentLevel == indent)
if (command.IndentLevel == indent)
{
System.Type type = command.GetType();
if (type == typeof(End))
{
// Execute command immediately after the EndIf command
Continue(command.commandIndex + 1);
Continue(command.CommandIndex + 1);
return;
}
}

12
Assets/Fungus/Flowchart/Scripts/Commands/ElseIf.cs

@ -20,7 +20,7 @@ namespace Fungus
public override void OnEnter()
{
System.Type previousCommandType = parentBlock.GetPreviousActiveCommandType();
System.Type previousCommandType = ParentBlock.GetPreviousActiveCommandType();
if (previousCommandType == typeof(If) ||
previousCommandType == typeof(ElseIf) )
@ -34,7 +34,7 @@ namespace Fungus
// but will also jump to a following Else command.
// Stop if this is the last command in the list
if (commandIndex >= parentBlock.commandList.Count - 1)
if (CommandIndex >= ParentBlock.CommandList.Count - 1)
{
StopParentBlock();
return;
@ -42,17 +42,17 @@ namespace Fungus
// Find the next End command at the same indent level as this Else If command
int indent = indentLevel;
for (int i = commandIndex + 1; i < parentBlock.commandList.Count; ++i)
for (int i = CommandIndex + 1; i < ParentBlock.CommandList.Count; ++i)
{
Command command = parentBlock.commandList[i];
Command command = ParentBlock.CommandList[i];
if (command.indentLevel == indent)
if (command.IndentLevel == indent)
{
System.Type type = command.GetType();
if (type == typeof(End))
{
// Execute command immediately after the Else or End command
Continue(command.commandIndex + 1);
Continue(command.CommandIndex + 1);
return;
}
}

9
Assets/Fungus/Flowchart/Scripts/Commands/End.cs

@ -16,16 +16,15 @@ namespace Fungus
[AddComponentMenu("")]
public class End : Command
{
[NonSerialized]
public bool loop = false;
public bool Loop { get; set; }
public override void OnEnter()
{
if (loop)
if (Loop)
{
for (int i = commandIndex - 1; i >= 0; --i)
for (int i = CommandIndex - 1; i >= 0; --i)
{
System.Type commandType = parentBlock.commandList[i].GetType();
System.Type commandType = ParentBlock.CommandList[i].GetType();
if (commandType == typeof(While))
{
Continue(i);

26
Assets/Fungus/Flowchart/Scripts/Commands/If.cs

@ -21,23 +21,23 @@ namespace Fungus
typeof(IntegerVariable),
typeof(FloatVariable),
typeof(StringVariable))]
public Variable variable;
[SerializeField] protected Variable variable;
[Tooltip("Boolean value to compare against")]
public BooleanData booleanData;
[SerializeField] protected BooleanData booleanData;
[Tooltip("Integer value to compare against")]
public IntegerData integerData;
[SerializeField] protected IntegerData integerData;
[Tooltip("Float value to compare against")]
public FloatData floatData;
[SerializeField] protected FloatData floatData;
[Tooltip("String value to compare against")]
public StringDataMulti stringData;
[SerializeField] protected StringDataMulti stringData;
public override void OnEnter()
{
if (parentBlock == null)
if (ParentBlock == null)
{
return;
}
@ -100,16 +100,16 @@ namespace Fungus
protected virtual void OnFalse()
{
// Last command in block
if (commandIndex >= parentBlock.commandList.Count)
if (CommandIndex >= ParentBlock.CommandList.Count)
{
StopParentBlock();
return;
}
// Find the next Else, ElseIf or End command at the same indent level as this If command
for (int i = commandIndex + 1; i < parentBlock.commandList.Count; ++i)
for (int i = CommandIndex + 1; i < ParentBlock.CommandList.Count; ++i)
{
Command nextCommand = parentBlock.commandList[i];
Command nextCommand = ParentBlock.CommandList[i];
if (nextCommand == null)
{
@ -121,7 +121,7 @@ namespace Fungus
if (!nextCommand.enabled ||
nextCommand.GetType() == typeof(Comment) ||
nextCommand.GetType() == typeof(Label) ||
nextCommand.indentLevel != indentLevel)
nextCommand.IndentLevel != indentLevel)
{
continue;
}
@ -130,7 +130,7 @@ namespace Fungus
if (type == typeof(Else) ||
type == typeof(End))
{
if (i >= parentBlock.commandList.Count - 1)
if (i >= ParentBlock.CommandList.Count - 1)
{
// Last command in Block, so stop
StopParentBlock();
@ -138,7 +138,7 @@ namespace Fungus
else
{
// Execute command immediately after the Else or End command
Continue(nextCommand.commandIndex + 1);
Continue(nextCommand.CommandIndex + 1);
return;
}
}
@ -162,7 +162,7 @@ namespace Fungus
return "Error: No variable selected";
}
string summary = variable.key + " ";
string summary = variable.Key + " ";
summary += Condition.GetOperatorDescription(compareOperator) + " ";
if (variable.GetType() == typeof(BooleanVariable))

30
Assets/Fungus/Flowchart/Scripts/Commands/InvokeEvent.cs

@ -35,36 +35,36 @@ namespace Fungus
}
[Tooltip("Delay (in seconds) before the methods will be called")]
public float delay;
[SerializeField] protected float delay;
public InvokeType invokeType;
[SerializeField] protected InvokeType invokeType;
[Tooltip("List of methods to call. Supports methods with no parameters or exactly one string, int, float or object parameter.")]
public UnityEvent staticEvent = new UnityEvent();
[SerializeField] protected UnityEvent staticEvent = new UnityEvent();
[Tooltip("Boolean parameter to pass to the invoked methods.")]
public BooleanData booleanParameter;
[SerializeField] protected BooleanData booleanParameter;
[Tooltip("List of methods to call. Supports methods with one boolean parameter.")]
public BooleanEvent booleanEvent = new BooleanEvent();
[SerializeField] protected BooleanEvent booleanEvent = new BooleanEvent();
[Tooltip("Integer parameter to pass to the invoked methods.")]
public IntegerData integerParameter;
[SerializeField] protected IntegerData integerParameter;
[Tooltip("List of methods to call. Supports methods with one integer parameter.")]
public IntegerEvent integerEvent = new IntegerEvent();
[SerializeField] protected IntegerEvent integerEvent = new IntegerEvent();
[Tooltip("Float parameter to pass to the invoked methods.")]
public FloatData floatParameter;
[SerializeField] protected FloatData floatParameter;
[Tooltip("List of methods to call. Supports methods with one float parameter.")]
public FloatEvent floatEvent = new FloatEvent();
[SerializeField] protected FloatEvent floatEvent = new FloatEvent();
[Tooltip("String parameter to pass to the invoked methods.")]
public StringDataMulti stringParameter;
[SerializeField] protected StringDataMulti stringParameter;
[Tooltip("List of methods to call. Supports methods with one string parameter.")]
public StringEvent stringEvent = new StringEvent();
[SerializeField] protected StringEvent stringEvent = new StringEvent();
public override void OnEnter()
{
@ -89,16 +89,16 @@ namespace Fungus
staticEvent.Invoke();
break;
case InvokeType.DynamicBoolean:
booleanEvent.Invoke(booleanParameter);
booleanEvent.Invoke(booleanParameter.Value);
break;
case InvokeType.DynamicInteger:
integerEvent.Invoke(integerParameter);
integerEvent.Invoke(integerParameter.Value);
break;
case InvokeType.DynamicFloat:
floatEvent.Invoke(floatParameter);
floatEvent.Invoke(floatParameter.Value);
break;
case InvokeType.DynamicString:
stringEvent.Invoke(stringParameter);
stringEvent.Invoke(stringParameter.Value);
break;
}
}

26
Assets/Fungus/Flowchart/Scripts/Commands/InvokeMethod.cs

@ -21,51 +21,53 @@ namespace Fungus
public class InvokeMethod : Command
{
[Tooltip("GameObject containing the component method to be invoked")]
public GameObject targetObject;
[SerializeField] protected GameObject targetObject;
public GameObject TargetObject { get { return targetObject; } }
[HideInInspector]
[Tooltip("Name of assembly containing the target component")]
public string targetComponentAssemblyName;
[SerializeField] protected string targetComponentAssemblyName;
[HideInInspector]
[Tooltip("Full name of the target component")]
public string targetComponentFullname;
[SerializeField] protected string targetComponentFullname;
[HideInInspector]
[Tooltip("Display name of the target component")]
public string targetComponentText;
[SerializeField] protected string targetComponentText;
[HideInInspector]
[Tooltip("Name of target method to invoke on the target component")]
public string targetMethod;
[SerializeField] protected string targetMethod;
[HideInInspector]
[Tooltip("Display name of target method to invoke on the target component")]
public string targetMethodText;
[SerializeField] protected string targetMethodText;
[HideInInspector]
[Tooltip("List of parameters to pass to the invoked method")]
public InvokeMethodParameter[] methodParameters;
[SerializeField] protected InvokeMethodParameter[] methodParameters;
[HideInInspector]
[Tooltip("If true, store the return value in a flowchart variable of the same type.")]
public bool saveReturnValue;
[SerializeField] protected bool saveReturnValue;
[HideInInspector]
[Tooltip("Name of Fungus variable to store the return value in")]
public string returnValueVariableKey;
[SerializeField] protected string returnValueVariableKey;
[HideInInspector]
[Tooltip("The type of the return value")]
public string returnValueType;
[SerializeField] protected string returnValueType;
[HideInInspector]
[Tooltip("If true, list all inherited methods for the component")]
public bool showInherited;
[SerializeField] protected bool showInherited;
[HideInInspector]
[Tooltip("The coroutine call behavior for methods that return IEnumerator")]
public Fungus.Call.CallMode callMode;
[SerializeField] protected Call.CallMode callMode;
protected Type componentType;
protected Component objComponent;

10
Assets/Fungus/Flowchart/Scripts/Commands/Jump.cs

@ -16,7 +16,7 @@ namespace Fungus
public class Jump : Command
{
[Tooltip("Name of a label in this block to jump to")]
public StringData _targetLabel = new StringData("");
[SerializeField] protected StringData _targetLabel = new StringData("");
public override void OnEnter()
{
@ -26,13 +26,13 @@ namespace Fungus
return;
}
foreach (Command command in parentBlock.commandList)
foreach (Command command in ParentBlock.CommandList)
{
Label label = command as Label;
if (label != null &&
label.key == _targetLabel.Value)
label.Key == _targetLabel.Value)
{
Continue(label.commandIndex + 1);
Continue(label.CommandIndex + 1);
return;
}
}
@ -65,7 +65,7 @@ namespace Fungus
{
if (targetLabelOLD != null)
{
_targetLabel.Value = targetLabelOLD.key;
_targetLabel.Value = targetLabelOLD.Key;
targetLabelOLD = null;
}
}

4
Assets/Fungus/Flowchart/Scripts/Commands/Label.cs

@ -16,7 +16,9 @@ namespace Fungus
public class Label : Command
{
[Tooltip("Display name for the label")]
public string key = "";
[SerializeField] protected string key = "";
public string Key { get { return key; } }
public override void OnEnter()
{

4
Assets/Fungus/Flowchart/Scripts/Commands/LoadScene.cs

@ -21,10 +21,10 @@ namespace Fungus
public class LoadScene : Command
{
[Tooltip("Name of the scene to load. The scene must also be added to the build settings.")]
public StringData _sceneName = new StringData("");
[SerializeField] protected StringData _sceneName = new StringData("");
[Tooltip("Image to display while loading the scene")]
public Texture2D loadingImage;
[SerializeField] protected Texture2D loadingImage;
public override void OnEnter()
{

4
Assets/Fungus/Flowchart/Scripts/Commands/LoadVariable.cs

@ -16,7 +16,7 @@ namespace Fungus
public class LoadVariable : Command
{
[Tooltip("Name of the saved value. Supports variable substition e.g. \"player_{$PlayerNumber}\"")]
public string key = "";
[SerializeField] protected string key = "";
[Tooltip("Variable to store the value in.")]
[VariableProperty(typeof(BooleanVariable),
@ -90,7 +90,7 @@ namespace Fungus
return "Error: No variable selected";
}
return "'" + key + "' into " + variable.key;
return "'" + key + "' into " + variable.Key;
}
public override Color GetButtonColor()

2
Assets/Fungus/Flowchart/Scripts/Commands/OpenURL.cs

@ -16,7 +16,7 @@ namespace Fungus
public class LinkToWebsite : Command
{
[Tooltip("URL to open in the browser")]
public StringData url = new StringData();
[SerializeField] protected StringData url = new StringData();
public override void OnEnter()
{

8
Assets/Fungus/Flowchart/Scripts/Commands/RandomFloat.cs

@ -16,13 +16,13 @@ namespace Fungus
{
[Tooltip("The variable whos value will be set")]
[VariableProperty(typeof(FloatVariable))]
public FloatVariable variable;
[SerializeField] protected FloatVariable variable;
[Tooltip("Minimum value for random range")]
public FloatData minValue;
[SerializeField] protected FloatData minValue;
[Tooltip("Maximum value for random range")]
public FloatData maxValue;
[SerializeField] protected FloatData maxValue;
public override void OnEnter()
{
@ -41,7 +41,7 @@ namespace Fungus
return "Error: Variable not selected";
}
return variable.key;
return variable.Key;
}
public override bool HasReference(Variable variable)

8
Assets/Fungus/Flowchart/Scripts/Commands/RandomInteger.cs

@ -16,13 +16,13 @@ namespace Fungus
{
[Tooltip("The variable whos value will be set")]
[VariableProperty(typeof(IntegerVariable))]
public IntegerVariable variable;
[SerializeField] protected IntegerVariable variable;
[Tooltip("Minimum value for random range")]
public IntegerData minValue;
[SerializeField] protected IntegerData minValue;
[Tooltip("Maximum value for random range")]
public IntegerData maxValue;
[SerializeField] protected IntegerData maxValue;
public override void OnEnter()
{
@ -41,7 +41,7 @@ namespace Fungus
return "Error: Variable not selected";
}
return variable.key;
return variable.Key;
}
public override bool HasReference(Variable variable)

6
Assets/Fungus/Flowchart/Scripts/Commands/ReadTextFile.cs

@ -16,11 +16,11 @@ namespace Fungus
public class ReadTextFile : Command
{
[Tooltip("Text file to read into the string variable")]
public TextAsset textFile;
[SerializeField] protected TextAsset textFile;
[Tooltip("String variable to store the tex file contents in")]
[VariableProperty(typeof(StringVariable))]
public StringVariable stringVariable;
[SerializeField] protected StringVariable stringVariable;
public override void OnEnter()
{
@ -48,7 +48,7 @@ namespace Fungus
return "Error: Text file not selected";
}
return stringVariable.key;
return stringVariable.Key;
}
public override bool HasReference(Variable variable)

4
Assets/Fungus/Flowchart/Scripts/Commands/Reset.cs

@ -16,10 +16,10 @@ namespace Fungus
public class Reset : Command
{
[Tooltip("Reset state of all commands in the script")]
public bool resetCommands = true;
[SerializeField] protected bool resetCommands = true;
[Tooltip("Reset variables back to their default values")]
public bool resetVariables = true;
[SerializeField] protected bool resetVariables = true;
public override void OnEnter()
{

4
Assets/Fungus/Flowchart/Scripts/Commands/SaveVariable.cs

@ -18,7 +18,7 @@ namespace Fungus
public class SaveVariable : Command
{
[Tooltip("Name of the saved value. Supports variable substition e.g. \"player_{$PlayerNumber}")]
public string key = "";
[SerializeField] protected string key = "";
[Tooltip("Variable to read the value from. Only Boolean, Integer, Float and String are supported.")]
[VariableProperty(typeof(BooleanVariable),
@ -92,7 +92,7 @@ namespace Fungus
return "Error: No variable selected";
}
return variable.key + " into '" + key + "'";
return variable.Key + " into '" + key + "'";
}
public override Color GetButtonColor()

4
Assets/Fungus/Flowchart/Scripts/Commands/SendMessage.cs

@ -23,10 +23,10 @@ namespace Fungus
}
[Tooltip("Target flowchart(s) to send the message to")]
public MessageTarget messageTarget;
[SerializeField] protected MessageTarget messageTarget;
[Tooltip("Name of the message to send")]
public StringData _message = new StringData("");
[SerializeField] protected StringData _message = new StringData("");
public override void OnEnter()
{

4
Assets/Fungus/Flowchart/Scripts/Commands/SetActive.cs

@ -18,10 +18,10 @@ namespace Fungus
public class SetActive : Command
{
[Tooltip("Reference to game object to enable / disable")]
public GameObjectData _targetGameObject;
[SerializeField] protected GameObjectData _targetGameObject;
[Tooltip("Set to true to enable the game object")]
public BooleanData activeState;
[SerializeField] protected BooleanData activeState;
public override void OnEnter()
{

2
Assets/Fungus/Flowchart/Scripts/Commands/SetSaveProfile.cs

@ -21,7 +21,7 @@ namespace Fungus
public static string saveProfile = "";
[Tooltip("Name of save profile to make active.")]
public string saveProfileName = "";
[SerializeField] protected string saveProfileName = "";
public override void OnEnter()
{

16
Assets/Fungus/Flowchart/Scripts/Commands/SetVariable.cs

@ -29,22 +29,24 @@ namespace Fungus
typeof(IntegerVariable),
typeof(FloatVariable),
typeof(StringVariable))]
public Variable variable;
[SerializeField] protected Variable variable;
[Tooltip("The type of math operation to be performed")]
public SetOperator setOperator;
[SerializeField] protected SetOperator setOperator;
public SetOperator _SetOperator { get { return setOperator; } }
[Tooltip("Boolean value to set with")]
public BooleanData booleanData;
[SerializeField] protected BooleanData booleanData;
[Tooltip("Integer value to set with")]
public IntegerData integerData;
[SerializeField] protected IntegerData integerData;
[Tooltip("Float value to set with")]
public FloatData floatData;
[SerializeField] protected FloatData floatData;
[Tooltip("String value to set with")]
public StringDataMulti stringData;
[SerializeField] protected StringDataMulti stringData;
public override void OnEnter()
{
@ -60,7 +62,7 @@ namespace Fungus
return "Error: Variable not selected";
}
string description = variable.key;
string description = variable.Key;
switch (setOperator)
{

8
Assets/Fungus/Flowchart/Scripts/Commands/SpawnObject.cs

@ -20,16 +20,16 @@ namespace Fungus
public class SpawnObject : Command
{
[Tooltip("Game object to copy when spawning. Can be a scene object or a prefab.")]
public GameObjectData _sourceObject;
[SerializeField] protected GameObjectData _sourceObject;
[Tooltip("Transform to use for position of newly spawned object.")]
public TransformData _parentTransform;
[SerializeField] protected TransformData _parentTransform;
[Tooltip("Local position of newly spawned object.")]
public Vector3Data _spawnPosition;
[SerializeField] protected Vector3Data _spawnPosition;
[Tooltip("Local rotation of newly spawned object.")]
public Vector3Data _spawnRotation;
[SerializeField] protected Vector3Data _spawnRotation;
public override void OnEnter()
{

4
Assets/Fungus/Flowchart/Scripts/Commands/StopBlock.cs

@ -15,10 +15,10 @@ namespace Fungus
public class StopBlock : Command
{
[Tooltip("Flowchart containing the Block. If none is specified, the parent Flowchart is used.")]
public Flowchart flowchart;
[SerializeField] protected Flowchart flowchart;
[Tooltip("Name of the Block to stop")]
public StringData blockName = new StringData("");
[SerializeField] protected StringData blockName = new StringData("");
public override void OnEnter()
{

4
Assets/Fungus/Flowchart/Scripts/Commands/StopFlowchart.cs

@ -16,10 +16,10 @@ namespace Fungus
public class StopFlowchart : Command
{
[Tooltip("Stop all executing Blocks in the Flowchart that contains this command")]
public bool stopParentFlowchart;
[SerializeField] protected bool stopParentFlowchart;
[Tooltip("Stop all executing Blocks in a list of target Flowcharts")]
public List<Flowchart> targetFlowcharts = new List<Flowchart>();
[SerializeField] protected List<Flowchart> targetFlowcharts = new List<Flowchart>();
public override void OnEnter()
{

2
Assets/Fungus/Flowchart/Scripts/Commands/Wait.cs

@ -18,7 +18,7 @@ namespace Fungus
public class Wait : Command
{
[Tooltip("Duration to wait for")]
public FloatData _duration = new FloatData(1);
[SerializeField] protected FloatData _duration = new FloatData(1);
public override void OnEnter()
{

10
Assets/Fungus/Flowchart/Scripts/Commands/While.cs

@ -26,12 +26,12 @@ namespace Fungus
// Find next End statement at same indent level
End endCommand = null;
for (int i = commandIndex + 1; i < parentBlock.commandList.Count; ++i)
for (int i = CommandIndex + 1; i < ParentBlock.CommandList.Count; ++i)
{
End command = parentBlock.commandList[i] as End;
End command = ParentBlock.CommandList[i] as End;
if (command != null &&
command.indentLevel == indentLevel)
command.IndentLevel == indentLevel)
{
endCommand = command;
break;
@ -41,13 +41,13 @@ namespace Fungus
if (execute)
{
// Tell the following end command to loop back
endCommand.loop = true;
endCommand.Loop = true;
Continue();
}
else
{
// Continue at next command after End
Continue (endCommand.commandIndex + 1);
Continue (endCommand.CommandIndex + 1);
}
}

10
Assets/Fungus/Flowchart/Scripts/EventHandler.cs

@ -41,7 +41,9 @@ namespace Fungus
{
[HideInInspector]
[FormerlySerializedAs("parentSequence")]
public Block parentBlock;
[SerializeField] protected Block parentBlock;
public Block ParentBlock { get { return parentBlock; } set { parentBlock = value; } }
/**
* The Event Handler should call this method when the event is detected.
@ -53,7 +55,7 @@ namespace Fungus
return false;
}
if (parentBlock.eventHandler != this)
if (parentBlock._EventHandler != this)
{
return false;
}
@ -61,9 +63,9 @@ namespace Fungus
Flowchart flowchart = parentBlock.GetFlowchart();
// Auto-follow the executing block if none is currently selected
if (flowchart.selectedBlock == null)
if (flowchart.SelectedBlock == null)
{
flowchart.selectedBlock = parentBlock;
flowchart.SelectedBlock = parentBlock;
}
return flowchart.ExecuteBlock(parentBlock);

4
Assets/Fungus/Flowchart/Scripts/EventHandlers/KeyPressed.cs

@ -22,10 +22,10 @@ namespace Fungus
}
[Tooltip("The type of keypress to activate on")]
public KeyPressType keyPressType;
[SerializeField] protected KeyPressType keyPressType;
[Tooltip("Keycode of the key to activate on")]
public KeyCode keyCode;
[SerializeField] protected KeyCode keyCode;
protected virtual void Update()
{

2
Assets/Fungus/Flowchart/Scripts/EventHandlers/MessageReceived.cs

@ -15,7 +15,7 @@ namespace Fungus
public class MessageReceived : EventHandler
{
[Tooltip("Fungus message to listen for")]
public string message = "";
[SerializeField] protected string message = "";
public void OnSendFungusMessage(string message)
{

146
Assets/Fungus/Flowchart/Scripts/Flowchart.cs

@ -45,126 +45,161 @@ namespace Fungus
* Variable to track flowchart's version so components can update to new versions.
*/
[HideInInspector]
public int version = 0; // Default to 0 to always trigger an update for older versions of Fungus.
[SerializeField] protected int version = 0; // Default to 0 to always trigger an update for older versions of Fungus.
public int Version { set { version = value; } }
/**
* Scroll position of Flowchart editor window.
*/
[HideInInspector]
public Vector2 scrollPos;
[SerializeField] protected Vector2 scrollPos;
public Vector2 ScrollPos { get { return scrollPos; } set { scrollPos = value; } }
/**
* Scroll position of Flowchart variables window.
*/
[HideInInspector]
public Vector2 variablesScrollPos;
[SerializeField] protected Vector2 variablesScrollPos;
public Vector2 VariablesScrollPos { get { return variablesScrollPos; } set { variablesScrollPos = value; } }
/**
* Show the variables pane.
*/
[HideInInspector]
public bool variablesExpanded = true;
[SerializeField] protected bool variablesExpanded = true;
public bool VariablesExpanded { get { return variablesExpanded; } set { variablesExpanded = value; } }
/**
* Height of command block view in inspector.
*/
[HideInInspector]
public float blockViewHeight = 400;
[SerializeField] protected float blockViewHeight = 400;
public float BlockViewHeight { get { return blockViewHeight; } set { blockViewHeight = value; } }
/**
* Zoom level of Flowchart editor window
*/
[HideInInspector]
public float zoom = 1f;
[SerializeField] protected float zoom = 1f;
public float Zoom { get { return zoom; } set { zoom = value; } }
/**
* Scrollable area for Flowchart editor window.
*/
[HideInInspector]
public Rect scrollViewRect;
[SerializeField] protected Rect scrollViewRect;
public Rect ScrollViewRect { get { return scrollViewRect; } set { scrollViewRect = value; } }
/**
* Currently selected block in the Flowchart editor.
*/
[HideInInspector]
[FormerlySerializedAs("selectedSequence")]
public Block selectedBlock;
[SerializeField] protected Block selectedBlock;
public Block SelectedBlock { get { return selectedBlock; } set { selectedBlock = value; } }
/**
* Currently selected command in the Flowchart editor.
*/
[HideInInspector]
public List<Command> selectedCommands = new List<Command>();
[SerializeField] protected List<Command> selectedCommands = new List<Command>();
public List<Command> SelectedCommands { get { return selectedCommands; } }
/**
* The list of variables that can be accessed by the Flowchart.
*/
[HideInInspector]
public List<Variable> variables = new List<Variable>();
[SerializeField] protected List<Variable> variables = new List<Variable>();
public List<Variable> Variables { get { return variables; } }
[TextArea(3, 5)]
[Tooltip("Description text displayed in the Flowchart editor window")]
public string description = "";
[SerializeField] protected string description = "";
public string Description { get { return description; } }
/**
* Slow down execution in the editor to make it easier to visualise program flow.
*/
[Range(0f, 5f)]
[Tooltip("Adds a pause after each execution step to make it easier to visualise program flow. Editor only, has no effect in platform builds.")]
public float stepPause = 0f;
[SerializeField] protected float stepPause = 0f;
public float StepPause { get { return stepPause; } }
/**
* Use command color when displaying the command list in the inspector.
*/
[Tooltip("Use command color when displaying the command list in the Fungus Editor window")]
public bool colorCommands = true;
[SerializeField] protected bool colorCommands = true;
public bool ColorCommands { get { return colorCommands; } }
/**
* Hides the Flowchart block and command components in the inspector.
* Deselect to inspect the block and command components that make up the Flowchart.
*/
[Tooltip("Hides the Flowchart block and command components in the inspector")]
public bool hideComponents = true;
[SerializeField] protected bool hideComponents = true;
/**
* Saves the selected block and commands when saving the scene.
* Helps avoid version control conflicts if you've only changed the active selection.
*/
[Tooltip("Saves the selected block and commands when saving the scene.")]
public bool saveSelection = true;
[SerializeField] protected bool saveSelection = true;
public bool SaveSelection { get { return saveSelection; } }
/**
* Unique identifier for identifying this flowchart in localized string keys.
*/
[Tooltip("Unique identifier for this flowchart in localized string keys. If no id is specified then the name of the Flowchart object will be used.")]
public string localizationId = "";
[SerializeField] protected string localizationId = "";
public string LocalizationId { get { return localizationId; } }
/**
* Display line numbers in the command list in the Block inspector.
*/
[Tooltip("Display line numbers in the command list in the Block inspector.")]
public bool showLineNumbers = false;
[SerializeField] protected bool showLineNumbers = false;
public bool ShowLineNumbers { get { return showLineNumbers; } }
/**
* List of commands to hide in the Add Command menu. Use this to restrict the set of commands available when editing a Flowchart.
*/
[Tooltip("List of commands to hide in the Add Command menu. Use this to restrict the set of commands available when editing a Flowchart.")]
public List<string> hideCommands = new List<string>();
[SerializeField] protected List<string> hideCommands = new List<string>();
[Tooltip("Lua Environment to be used by default for all Execute Lua commands in this Flowchart")]
public LuaEnvironment luaEnvironment;
[SerializeField] protected LuaEnvironment luaEnvironment;
public LuaEnvironment _LuaEnvironment { get { return luaEnvironment; } }
/**
* The ExecuteLua command adds a global Lua variable with this name bound to the flowchart prior to executing.
*/
[Tooltip("The ExecuteLua command adds a global Lua variable with this name bound to the flowchart prior to executing.")]
public string luaBindingName = "flowchart";
[SerializeField] protected string luaBindingName = "flowchart";
public string LuaBindingName { get { return luaBindingName; } }
/**
* Position in the center of all blocks in the flowchart.
*/
[NonSerialized]
public Vector2 centerPosition = Vector2.zero;
public Vector2 CenterPosition { set; get; }
/**
* Cached list of flowchart objects in the scene for fast lookup
@ -186,13 +221,13 @@ namespace Fungus
Block[] blocks = GetComponents<Block>();
foreach (Block block in blocks)
{
maxId = Math.Max(maxId, block.itemId);
maxId = Math.Max(maxId, block.ItemId);
}
Command[] commands = GetComponents<Command>();
foreach (Command command in commands)
{
maxId = Math.Max(maxId, command.itemId);
maxId = Math.Max(maxId, command.ItemId);
}
return maxId + 1;
}
@ -292,23 +327,23 @@ namespace Fungus
Block[] blocks = GetComponents<Block>();
foreach (Block block in blocks)
{
if (block.itemId == -1 ||
usedIds.Contains(block.itemId))
if (block.ItemId == -1 ||
usedIds.Contains(block.ItemId))
{
block.itemId = NextItemId();
block.ItemId = NextItemId();
}
usedIds.Add(block.itemId);
usedIds.Add(block.ItemId);
}
Command[] commands = GetComponents<Command>();
foreach (Command command in commands)
{
if (command.itemId == -1 ||
usedIds.Contains(command.itemId))
if (command.ItemId == -1 ||
usedIds.Contains(command.ItemId))
{
command.itemId = NextItemId();
command.ItemId = NextItemId();
}
usedIds.Add(command.itemId);
usedIds.Add(command.ItemId);
}
}
@ -337,7 +372,7 @@ namespace Fungus
bool found = false;
foreach (Block block in blocks)
{
if (block.commandList.Contains(command))
if (block.CommandList.Contains(command))
{
found = true;
break;
@ -355,7 +390,7 @@ namespace Fungus
bool found = false;
foreach (Block block in blocks)
{
if (block.eventHandler == eventHandler)
if (block._EventHandler == eventHandler)
{
found = true;
break;
@ -381,10 +416,9 @@ namespace Fungus
public virtual Block CreateBlock(Vector2 position)
{
Block b = CreateBlockComponent(gameObject);
b.nodeRect.x = position.x;
b.nodeRect.y = position.y;
b.blockName = GetUniqueBlockKey(b.blockName, b);
b.itemId = NextItemId();
b._NodeRect = new Rect(position.x, position.y, 0, 0);
b.BlockName = GetUniqueBlockKey(b.BlockName, b);
b.ItemId = NextItemId();
return b;
}
@ -397,7 +431,7 @@ namespace Fungus
Block [] blocks = GetComponents<Block>();
foreach (Block block in blocks)
{
if (block.blockName == blockName)
if (block.BlockName == blockName)
{
return block;
}
@ -416,7 +450,7 @@ namespace Fungus
Block block = null;
foreach (Block b in GetComponents<Block>())
{
if (b.blockName == blockName)
if (b.BlockName == blockName)
{
block = b;
break;
@ -537,12 +571,12 @@ namespace Fungus
{
if (variable == null ||
variable == ignoreVariable ||
variable.key == null)
variable.Key == null)
{
continue;
}
if (variable.key.Equals(key, StringComparison.CurrentCultureIgnoreCase))
if (variable.Key.Equals(key, StringComparison.CurrentCultureIgnoreCase))
{
collision = true;
suffix++;
@ -580,12 +614,12 @@ namespace Fungus
foreach(Block block in blocks)
{
if (block == ignoreBlock ||
block.blockName == null)
block.BlockName == null)
{
continue;
}
if (block.blockName.Equals(key, StringComparison.CurrentCultureIgnoreCase))
if (block.BlockName.Equals(key, StringComparison.CurrentCultureIgnoreCase))
{
collision = true;
suffix++;
@ -614,13 +648,13 @@ namespace Fungus
baseKey = "New Label";
}
Block block = ignoreLabel.parentBlock;
Block block = ignoreLabel.ParentBlock;
string key = baseKey;
while (true)
{
bool collision = false;
foreach(Command command in block.commandList)
foreach(Command command in block.CommandList)
{
Label label = command as Label;
if (label == null ||
@ -629,7 +663,7 @@ namespace Fungus
continue;
}
if (label.key.Equals(key, StringComparison.CurrentCultureIgnoreCase))
if (label.Key.Equals(key, StringComparison.CurrentCultureIgnoreCase))
{
collision = true;
suffix++;
@ -655,7 +689,7 @@ namespace Fungus
{
foreach (Variable variable in variables)
{
if (variable != null && variable.key == key)
if (variable != null && variable.Key == key)
{
return variable;
}
@ -674,7 +708,7 @@ namespace Fungus
{
foreach (Variable variable in variables)
{
if (variable != null && variable.key == key)
if (variable != null && variable.Key == key)
{
return variable as T;
}
@ -692,7 +726,7 @@ namespace Fungus
{
foreach (Variable v in variables)
{
if (v != null && v.key == key)
if (v != null && v.Key == key)
{
T variable = v as T;
if (variable != null)
@ -714,7 +748,7 @@ namespace Fungus
List<Variable> publicVariables = new List<Variable>();
foreach (Variable v in variables)
{
if (v != null && v.scope == VariableScope.Public)
if (v != null && v.Scope == VariableScope.Public)
{
publicVariables.Add(v);
}
@ -1004,8 +1038,8 @@ namespace Fungus
if (variable == null)
continue;
if (variable.scope == VariableScope.Public &&
variable.key == key)
if (variable.Scope == VariableScope.Public &&
variable.Key == key)
{
string value = variable.ToString();
input.Replace(match.Value, value);
@ -1032,7 +1066,7 @@ namespace Fungus
}
// Use the string builder from StringSubstituter for efficiency.
StringBuilder sb = stringSubstituer.stringBuilder;
StringBuilder sb = stringSubstituer._StringBuilder;
sb.Length = 0;
sb.Append(input);
@ -1053,8 +1087,8 @@ namespace Fungus
if (variable == null)
continue;
if (variable.scope == VariableScope.Private &&
variable.key == key)
if (variable.Scope == VariableScope.Private &&
variable.Key == key)
{
string value = variable.ToString();
sb.Replace(match.Value, value);

4
Assets/Fungus/Flowchart/Scripts/FungusState.cs

@ -14,7 +14,9 @@ namespace Fungus
[AddComponentMenu("")]
public class FungusState : MonoBehaviour
{
public Flowchart selectedFlowchart;
[SerializeField] protected Flowchart selectedFlowchart;
public Flowchart SelectedFlowchart { get { return selectedFlowchart; } set { selectedFlowchart = value; } }
}
}

4
Assets/Fungus/Flowchart/Scripts/Node.cs

@ -12,7 +12,9 @@ namespace Fungus
[AddComponentMenu("")]
public class Node : MonoBehaviour
{
public Rect nodeRect = new Rect(0, 0, 120, 30);
[SerializeField] protected Rect nodeRect = new Rect(0, 0, 120, 30);
public Rect _NodeRect { get { return nodeRect; } set { nodeRect = value; } }
}
}

8
Assets/Fungus/Flowchart/Scripts/Variable.cs

@ -51,9 +51,13 @@ namespace Fungus
[RequireComponent(typeof(Flowchart))]
public abstract class Variable : MonoBehaviour
{
public VariableScope scope;
[SerializeField] protected VariableScope scope;
public string key = "";
public VariableScope Scope { get { return scope; } }
[SerializeField] protected string key = "";
public string Key { get { return key; } set { key = value; } }
public abstract void OnReset();
}

2
Assets/Fungus/Flowchart/Scripts/VariableTypes/AnimatorVariable.cs

@ -49,7 +49,7 @@ namespace Fungus
}
else
{
return animatorRef.key;
return animatorRef.Key;
}
}
}

2
Assets/Fungus/Flowchart/Scripts/VariableTypes/AudioSourceVariable.cs

@ -49,7 +49,7 @@ namespace Fungus
}
else
{
return audioSourceRef.key;
return audioSourceRef.Key;
}
}
}

2
Assets/Fungus/Flowchart/Scripts/VariableTypes/BooleanVariable.cs

@ -73,7 +73,7 @@ namespace Fungus
}
else
{
return booleanRef.key;
return booleanRef.Key;
}
}
}

2
Assets/Fungus/Flowchart/Scripts/VariableTypes/ColorVariable.cs

@ -49,7 +49,7 @@ namespace Fungus
}
else
{
return colorRef.key;
return colorRef.Key;
}
}
}

2
Assets/Fungus/Flowchart/Scripts/VariableTypes/FloatVariable.cs

@ -81,7 +81,7 @@ namespace Fungus
}
else
{
return floatRef.key;
return floatRef.Key;
}
}
}

2
Assets/Fungus/Flowchart/Scripts/VariableTypes/GameObjectVariable.cs

@ -49,7 +49,7 @@ namespace Fungus
}
else
{
return gameObjectRef.key;
return gameObjectRef.Key;
}
}
}

2
Assets/Fungus/Flowchart/Scripts/VariableTypes/IntegerVariable.cs

@ -81,7 +81,7 @@ namespace Fungus
}
else
{
return integerRef.key;
return integerRef.Key;
}
}
}

2
Assets/Fungus/Flowchart/Scripts/VariableTypes/MaterialVariable.cs

@ -49,7 +49,7 @@ namespace Fungus
}
else
{
return materialRef.key;
return materialRef.Key;
}
}
}

2
Assets/Fungus/Flowchart/Scripts/VariableTypes/ObjectVariable.cs

@ -49,7 +49,7 @@ namespace Fungus
}
else
{
return objectRef.key;
return objectRef.Key;
}
}
}

2
Assets/Fungus/Flowchart/Scripts/VariableTypes/SpriteVariable.cs

@ -49,7 +49,7 @@ namespace Fungus
}
else
{
return spriteRef.key;
return spriteRef.Key;
}
}
}

4
Assets/Fungus/Flowchart/Scripts/VariableTypes/StringVariable.cs

@ -80,7 +80,7 @@ namespace Fungus
}
else
{
return stringRef.key;
return stringRef.Key;
}
}
}
@ -130,7 +130,7 @@ namespace Fungus
}
else
{
return stringRef.key;
return stringRef.Key;
}
}
}

2
Assets/Fungus/Flowchart/Scripts/VariableTypes/TextureVariable.cs

@ -49,7 +49,7 @@ namespace Fungus
}
else
{
return textureRef.key;
return textureRef.Key;
}
}
}

2
Assets/Fungus/Flowchart/Scripts/VariableTypes/TransformVariable.cs

@ -49,7 +49,7 @@ namespace Fungus
}
else
{
return transformRef.key;
return transformRef.Key;
}
}
}

2
Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector2Variable.cs

@ -49,7 +49,7 @@ namespace Fungus
}
else
{
return vector2Ref.key;
return vector2Ref.Key;
}
}
}

2
Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector3Variable.cs

@ -49,7 +49,7 @@ namespace Fungus
}
else
{
return vector3Ref.key;
return vector3Ref.Key;
}
}
}

8
Assets/Fungus/Lua/Scripts/Commands/ExecuteLua.cs

@ -59,14 +59,14 @@ namespace Fungus
}
// Cache a descriptive name to use in Lua error messages
friendlyName = gameObject.name + "." + parentBlock.blockName + "." + "ExecuteLua #" + commandIndex.ToString();
friendlyName = gameObject.name + "." + ParentBlock.BlockName + "." + "ExecuteLua #" + CommandIndex.ToString();
Flowchart flowchart = GetFlowchart();
// See if a Lua Environment has been assigned to this Flowchart
if (luaEnvironment == null)
{
luaEnvironment = flowchart.luaEnvironment;
luaEnvironment = flowchart._LuaEnvironment;
}
// No Lua Environment specified so just use any available or create one.
@ -79,12 +79,12 @@ namespace Fungus
luaFunction = luaEnvironment.LoadLuaString(s, friendlyName);
// Add a binding to the parent flowchart
if (flowchart.luaBindingName != "")
if (flowchart.LuaBindingName != "")
{
Table globals = luaEnvironment.Interpreter.Globals;
if (globals != null)
{
globals[flowchart.luaBindingName] = flowchart;
globals[flowchart.LuaBindingName] = flowchart;
}
}

2
Assets/Fungus/Narrative/Scripts/Commands/Menu.cs

@ -83,7 +83,7 @@ namespace Fungus
return "Error: No button text selected";
}
return text + " : " + targetBlock.blockName;
return text + " : " + targetBlock.BlockName;
}
public override Color GetButtonColor()

2
Assets/Fungus/Narrative/Scripts/Commands/MenuTimer.cs

@ -54,7 +54,7 @@ namespace Fungus
return "Error: No target block selected";
}
return targetBlock.blockName;
return targetBlock.BlockName;
}
public override Color GetButtonColor()

2
Assets/Fungus/Narrative/Scripts/Localization.cs

@ -232,7 +232,7 @@ namespace Fungus
Block[] blocks = flowchart.GetComponents<Block>();
foreach (Block block in blocks)
{
foreach (Command command in block.commandList)
foreach (Command command in block.CommandList)
{
ILocalizable localizable = command as ILocalizable;
if (localizable != null)

2
Assets/Fungus/Narrative/Scripts/MenuDialog.cs

@ -142,7 +142,7 @@ namespace Fungus
#if UNITY_EDITOR
// Select the new target block in the Flowchart window
Flowchart flowchart = block.GetFlowchart();
flowchart.selectedBlock = block;
flowchart.SelectedBlock = block;
#endif
gameObject.SetActive(false);

8
Assets/Fungus/Sprite/Scripts/Clickable2D.cs

@ -16,13 +16,15 @@ namespace Fungus
public class Clickable2D : MonoBehaviour, IPointerClickHandler, IPointerEnterHandler, IPointerExitHandler
{
[Tooltip("Is object clicking enabled")]
public bool clickEnabled = true;
[SerializeField] protected bool clickEnabled = true;
public bool ClickEnabled { set { clickEnabled = value; } }
[Tooltip("Mouse texture to use when hovering mouse over object")]
public Texture2D hoverCursor;
[SerializeField] protected Texture2D hoverCursor;
[Tooltip("Use the UI Event System to check for clicks. Clicks that hit an overlapping UI object will be ignored. Camera must have a PhysicsRaycaster component, or a Physics2DRaycaster for 2D colliders.")]
public bool useEventSystem;
[SerializeField] protected bool useEventSystem;
#region Legacy OnMouseX methods
protected virtual void OnMouseDown()

8
Assets/Fungus/Sprite/Scripts/Commands/FadeSprite.cs

@ -37,17 +37,9 @@ namespace Fungus
return;
}
CameraController cameraController = CameraController.GetInstance();
if (waitUntilFinished)
{
cameraController.waiting = true;
}
SpriteFader.FadeSprite(spriteRenderer, _targetColor.Value, _duration.Value, Vector2.zero, delegate {
if (waitUntilFinished)
{
cameraController.waiting = false;
Continue();
}
});

6
Assets/Fungus/Sprite/Scripts/Commands/SetClickable2D.cs

@ -16,16 +16,16 @@ namespace Fungus
public class SetClickable2D : Command
{
[Tooltip("Reference to Clickable2D component on a gameobject")]
public Clickable2D targetClickable2D;
[SerializeField] protected Clickable2D targetClickable2D;
[Tooltip("Set to true to enable the component")]
public BooleanData activeState;
[SerializeField] protected BooleanData activeState;
public override void OnEnter()
{
if (targetClickable2D != null)
{
targetClickable2D.clickEnabled = activeState.Value;
targetClickable2D.ClickEnabled = activeState.Value;
}
Continue();

6
Assets/Fungus/Sprite/Scripts/Commands/SetCollider.cs

@ -16,13 +16,13 @@ namespace Fungus
public class SetCollider : Command
{
[Tooltip("A list of gameobjects containing collider components to be set active / inactive")]
public List<GameObject> targetObjects = new List<GameObject>();
[SerializeField] protected List<GameObject> targetObjects = new List<GameObject>();
[Tooltip("All objects with this tag will have their collider set active / inactive")]
public string targetTag = "";
[SerializeField] protected string targetTag = "";
[Tooltip("Set to true to enable the collider components")]
public BooleanData activeState;
[SerializeField] protected BooleanData activeState;
public override void OnEnter()
{

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save