Browse Source

Refactored comments

master
Christopher 9 years ago
parent
commit
da678c640b
  1. 82
      Assets/Fungus/Flowchart/Scripts/Block.cs
  2. 166
      Assets/Fungus/Flowchart/Scripts/Command.cs
  3. 13
      Assets/Fungus/Flowchart/Scripts/CommandCopyBuffer.cs
  4. 6
      Assets/Fungus/Flowchart/Scripts/Commands/Break.cs
  5. 5
      Assets/Fungus/Flowchart/Scripts/Commands/Call.cs
  6. 9
      Assets/Fungus/Flowchart/Scripts/Commands/CallMethod.cs
  7. 5
      Assets/Fungus/Flowchart/Scripts/Commands/Comment.cs
  8. 2
      Assets/Fungus/Flowchart/Scripts/Commands/Condition.cs
  9. 4
      Assets/Fungus/Flowchart/Scripts/Commands/DebugLog.cs
  10. 5
      Assets/Fungus/Flowchart/Scripts/Commands/DeleteSaveKey.cs
  11. 5
      Assets/Fungus/Flowchart/Scripts/Commands/Destroy.cs
  12. 5
      Assets/Fungus/Flowchart/Scripts/Commands/Else.cs
  13. 8
      Assets/Fungus/Flowchart/Scripts/Commands/ElseIf.cs
  14. 6
      Assets/Fungus/Flowchart/Scripts/Commands/End.cs
  15. 6
      Assets/Fungus/Flowchart/Scripts/Commands/If.cs
  16. 9
      Assets/Fungus/Flowchart/Scripts/Commands/InvokeEvent.cs
  17. 5
      Assets/Fungus/Flowchart/Scripts/Commands/InvokeMethod.cs
  18. 3
      Assets/Fungus/Flowchart/Scripts/Commands/Jump.cs
  19. 5
      Assets/Fungus/Flowchart/Scripts/Commands/Label.cs
  20. 10
      Assets/Fungus/Flowchart/Scripts/Commands/LoadScene.cs
  21. 5
      Assets/Fungus/Flowchart/Scripts/Commands/LoadVariable.cs
  22. 5
      Assets/Fungus/Flowchart/Scripts/Commands/OpenURL.cs
  23. 5
      Assets/Fungus/Flowchart/Scripts/Commands/Quit.cs
  24. 4
      Assets/Fungus/Flowchart/Scripts/Commands/RandomFloat.cs
  25. 4
      Assets/Fungus/Flowchart/Scripts/Commands/RandomInteger.cs
  26. 5
      Assets/Fungus/Flowchart/Scripts/Commands/ReadTextFile.cs
  27. 5
      Assets/Fungus/Flowchart/Scripts/Commands/Reset.cs
  28. 7
      Assets/Fungus/Flowchart/Scripts/Commands/SaveVariable.cs
  29. 4
      Assets/Fungus/Flowchart/Scripts/Commands/SendMessage.cs
  30. 5
      Assets/Fungus/Flowchart/Scripts/Commands/SetActive.cs
  31. 3
      Assets/Fungus/Flowchart/Scripts/Commands/SetSaveProfile.cs
  32. 5
      Assets/Fungus/Flowchart/Scripts/Commands/SetVariable.cs
  33. 7
      Assets/Fungus/Flowchart/Scripts/Commands/SpawnObject.cs
  34. 5
      Assets/Fungus/Flowchart/Scripts/Commands/Stop.cs
  35. 5
      Assets/Fungus/Flowchart/Scripts/Commands/StopBlock.cs
  36. 4
      Assets/Fungus/Flowchart/Scripts/Commands/StopFlowchart.cs
  37. 5
      Assets/Fungus/Flowchart/Scripts/Commands/Wait.cs
  38. 6
      Assets/Fungus/Flowchart/Scripts/Commands/While.cs
  39. 39
      Assets/Fungus/Flowchart/Scripts/EventHandler.cs
  40. 6
      Assets/Fungus/Flowchart/Scripts/EventHandlers/FlowchartEnabled.cs
  41. 6
      Assets/Fungus/Flowchart/Scripts/EventHandlers/GameStarted.cs
  42. 4
      Assets/Fungus/Flowchart/Scripts/EventHandlers/KeyPressed.cs
  43. 4
      Assets/Fungus/Flowchart/Scripts/EventHandlers/MessageReceived.cs
  44. 422
      Assets/Fungus/Flowchart/Scripts/Flowchart.cs
  45. 9
      Assets/Fungus/Flowchart/Scripts/FungusState.cs
  46. 7
      Assets/Fungus/Flowchart/Scripts/Node.cs
  47. 23
      Assets/Fungus/Flowchart/Scripts/SceneLoader.cs
  48. 6
      Assets/Fungus/Flowchart/Scripts/StringFormatter.cs
  49. 20
      Assets/Fungus/Flowchart/Scripts/Variable.cs
  50. 7
      Assets/Fungus/Flowchart/Scripts/VariableTypes/AnimatorVariable.cs
  51. 7
      Assets/Fungus/Flowchart/Scripts/VariableTypes/AudioSourceVariable.cs
  52. 7
      Assets/Fungus/Flowchart/Scripts/VariableTypes/BooleanVariable.cs
  53. 6
      Assets/Fungus/Flowchart/Scripts/VariableTypes/ColorVariable.cs
  54. 6
      Assets/Fungus/Flowchart/Scripts/VariableTypes/FloatVariable.cs
  55. 6
      Assets/Fungus/Flowchart/Scripts/VariableTypes/GameObjectVariable.cs
  56. 6
      Assets/Fungus/Flowchart/Scripts/VariableTypes/IntegerVariable.cs
  57. 6
      Assets/Fungus/Flowchart/Scripts/VariableTypes/MaterialVariable.cs
  58. 6
      Assets/Fungus/Flowchart/Scripts/VariableTypes/ObjectVariable.cs
  59. 6
      Assets/Fungus/Flowchart/Scripts/VariableTypes/SpriteVariable.cs
  60. 8
      Assets/Fungus/Flowchart/Scripts/VariableTypes/StringVariable.cs
  61. 6
      Assets/Fungus/Flowchart/Scripts/VariableTypes/TextureVariable.cs
  62. 6
      Assets/Fungus/Flowchart/Scripts/VariableTypes/TransformVariable.cs
  63. 6
      Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector2Variable.cs
  64. 6
      Assets/Fungus/Flowchart/Scripts/VariableTypes/Vector3Variable.cs

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

@ -11,6 +11,9 @@ using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// A container for a sequence of Fungus comands.
/// </summary>
[ExecuteInEditMode] [ExecuteInEditMode]
[RequireComponent(typeof(Flowchart))] [RequireComponent(typeof(Flowchart))]
[AddComponentMenu("")] [AddComponentMenu("")]
@ -22,58 +25,72 @@ namespace Fungus
Executing, Executing,
} }
/// <summary>
/// The execution state of the Block.
/// </summary>
protected ExecutionState executionState; protected ExecutionState executionState;
public ExecutionState State { get { return executionState; } } public ExecutionState State { get { return executionState; } }
/// <summary>
/// Unique identifier for the Block.
/// </summary>
[SerializeField] protected int itemId = -1; // Invalid flowchart item id [SerializeField] protected int itemId = -1; // Invalid flowchart item id
public int ItemId { get { return itemId; } set { itemId = value; } } public int ItemId { get { return itemId; } set { itemId = value; } }
/// <summary>
/// The name of the block node as displayed in the Flowchart window.
/// </summary>
[FormerlySerializedAs("sequenceName")] [FormerlySerializedAs("sequenceName")]
[Tooltip("The name of the block node as displayed in the Flowchart window")] [Tooltip("The name of the block node as displayed in the Flowchart window")]
[SerializeField] protected string blockName = "New Block"; [SerializeField] protected string blockName = "New Block";
public string BlockName { get { return blockName; } set { blockName = value; } } public string BlockName { get { return blockName; } set { blockName = value; } }
/// <summary>
/// Description text to display under the block node
/// </summary>
[TextArea(2, 5)] [TextArea(2, 5)]
[Tooltip("Description text to display under the block node")] [Tooltip("Description text to display under the block node")]
[SerializeField] protected string description = ""; [SerializeField] protected string description = "";
public string Description { get { return description; } } public string Description { get { return description; } }
/// <summary>
/// An optional Event Handler which can execute the block when an event occurs.
/// </summary>
[Tooltip("An optional Event Handler which can execute the block when an event occurs")] [Tooltip("An optional Event Handler which can execute the block when an event occurs")]
[SerializeField] protected EventHandler eventHandler; [SerializeField] protected EventHandler eventHandler;
public EventHandler _EventHandler { get { return eventHandler; } set { eventHandler = value; } } public EventHandler _EventHandler { get { return eventHandler; } set { eventHandler = value; } }
/// <summary>
/// The currently executing command.
/// </summary>
protected Command activeCommand; protected Command activeCommand;
public Command ActiveCommand { get { return activeCommand; } } public Command ActiveCommand { get { return activeCommand; } }
// Index of last command executed before the current one /// <summary>
// -1 indicates no previous command // Index of last command executed before the current one.
// -1 indicates no previous command.
/// </summary>
protected int previousActiveCommandIndex = -1; protected int previousActiveCommandIndex = -1;
public float ExecutingIconTimer { get; set; } public float ExecutingIconTimer { get; set; }
/// <summary>
/// The list of commands in the sequence.
/// </summary>
[SerializeField] protected List<Command> commandList = new List<Command>(); [SerializeField] protected List<Command> commandList = new List<Command>();
public List<Command> CommandList { get { return commandList; } } public List<Command> CommandList { get { return commandList; } }
protected int executionCount; /// <summary>
/// Controls the next command to execute in the block execution coroutine.
/// </summary>
protected int jumpToCommandIndex = -1;
public int JumpToCommandIndex { set { jumpToCommandIndex = value; } }
/** /// <summary>
* Duration of fade for executing icon displayed beside blocks & commands. /// Duration of fade for executing icon displayed beside blocks & commands.
*/ /// </summary>
public const float executingIconFadeTime = 0.5f; public const float executingIconFadeTime = 0.5f;
/** protected int executionCount;
* Controls the next command to execute in the block execution coroutine.
*/
protected int jumpToCommandIndex = -1;
public int JumpToCommandIndex { set { jumpToCommandIndex = value; } }
protected bool executionInfoSet = false; protected bool executionInfoSet = false;
@ -82,6 +99,9 @@ namespace Fungus
SetExecutionInfo(); SetExecutionInfo();
} }
/// <summary>
/// Populate the command metadata used to control execution.
/// </summary>
protected virtual void SetExecutionInfo() protected virtual void SetExecutionInfo()
{ {
// Give each child command a reference back to its parent block // Give each child command a reference back to its parent block
@ -125,16 +145,25 @@ namespace Fungus
} }
#endif #endif
/// <summary>
/// Returns the parent Flowchart for this Block.
/// </summary>
public virtual Flowchart GetFlowchart() public virtual Flowchart GetFlowchart()
{ {
return GetComponent<Flowchart>(); return GetComponent<Flowchart>();
} }
/// <summary>
/// Returns true if the Block is executing a command.
/// </summary>
public virtual bool IsExecuting() public virtual bool IsExecuting()
{ {
return (executionState == ExecutionState.Executing); return (executionState == ExecutionState.Executing);
} }
/// <summary>
/// Returns the number of times this Block has executed.
/// </summary>
public virtual int GetExecutionCount() public virtual int GetExecutionCount()
{ {
return executionCount; return executionCount;
@ -261,6 +290,9 @@ namespace Fungus
} }
} }
/// <summary>
/// Stop executing commands in this Block.
/// </summary>
public virtual void Stop() public virtual void Stop()
{ {
// Tell the executing command to stop immediately // Tell the executing command to stop immediately
@ -274,6 +306,9 @@ namespace Fungus
jumpToCommandIndex = int.MaxValue; jumpToCommandIndex = int.MaxValue;
} }
/// <summary>
/// Returns a list of all Blocks connected to this one.
/// </summary>
public virtual List<Block> GetConnectedBlocks() public virtual List<Block> GetConnectedBlocks()
{ {
List<Block> connectedBlocks = new List<Block>(); List<Block> connectedBlocks = new List<Block>();
@ -287,6 +322,10 @@ namespace Fungus
return connectedBlocks; return connectedBlocks;
} }
/// <summary>
/// Returns the type of the previously executing command.
/// </summary>
/// <returns>The previous active command type.</returns>
public virtual System.Type GetPreviousActiveCommandType() public virtual System.Type GetPreviousActiveCommandType()
{ {
if (previousActiveCommandIndex >= 0 && if (previousActiveCommandIndex >= 0 &&
@ -298,6 +337,9 @@ namespace Fungus
return null; return null;
} }
/// <summary>
/// Recalculate the indent levels for all commands in the list.
/// </summary>
public virtual void UpdateIndentLevels() public virtual void UpdateIndentLevels()
{ {
int indentLevel = 0; int indentLevel = 0;

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

@ -6,21 +6,22 @@
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization; using UnityEngine.Serialization;
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Attribute class for Fungus commands.
/// </summary>
public class CommandInfoAttribute : Attribute public class CommandInfoAttribute : Attribute
{ {
/** /// <summary>
* Metadata atribute for the Command class. /// Metadata atribute for the Command class.
* @param category The category to place this command in. /// </summary>
* @param commandName The display name of the command. /// <param name="category">The category to place this command in.</param>
* @param helpText Help information to display in the inspector. /// <param name="commandName">The display name of the command.</param>
* @param priority If two command classes have the same name, the one with highest priority is listed. Negative priority removess the command from the list. /// <param name="helpText">Help information to display in the inspector.</param>
*/ /// <param name="priority">If two command classes have the same name, the one with highest priority is listed. Negative priority removess the command from the list.</param>///
public CommandInfoAttribute(string category, string commandName, string helpText, int priority = 0) public CommandInfoAttribute(string category, string commandName, string helpText, int priority = 0)
{ {
this.Category = category; this.Category = category;
@ -35,42 +36,59 @@ namespace Fungus
public int Priority { get; set; } public int Priority { get; set; }
} }
/// <summary>
/// Base class for Commands. Commands can be added to Blocks to create an execution sequence.
/// </summary>
public class Command : MonoBehaviour public class Command : MonoBehaviour
{ {
/// <summary>
/// Unique identifier for this command.
/// Unique for this Flowchart.
/// </summary>
[FormerlySerializedAs("commandId")] [FormerlySerializedAs("commandId")]
[HideInInspector] [HideInInspector]
[SerializeField] protected int itemId = -1; // Invalid flowchart item id [SerializeField] protected int itemId = -1; // Invalid flowchart item id
public int ItemId { get { return itemId; } set { itemId = value; } } public int ItemId { get { return itemId; } set { itemId = value; } }
/// <summary>
/// Error message to display in the command inspector.
/// </summary>
protected string errorMessage = ""; protected string errorMessage = "";
public string ErrorMessage { get { return errorMessage; } } public string ErrorMessage { get { return errorMessage; } }
/// <summary>
/// Indent depth of the current commands.
/// Commands are indented inside If, While, etc. sections.
/// </summary>
[HideInInspector] [HideInInspector]
[SerializeField] protected int indentLevel; [SerializeField] protected int indentLevel;
public int IndentLevel { get { return indentLevel; } set { indentLevel = value; } } public int IndentLevel { get { return indentLevel; } set { indentLevel = value; } }
/// <summary>
/// Index of the command in the parent block's command list.
/// </summary>
public int CommandIndex { get; set; } public int CommandIndex { get; set; }
/** /// <summary>
* Set to true by the parent block while the command is executing. /// Set to true by the parent block while the command is executing.
*/ /// </summary>
public bool IsExecuting { get; set; } public bool IsExecuting { get; set; }
/** /// <summary>
* Timer used to control appearance of executing icon in inspector. /// Timer used to control appearance of executing icon in inspector.
*/ /// </summary>
public float ExecutingIconTimer { get; set; } public float ExecutingIconTimer { get; set; }
/** /// <summary>
* Reference to the Block object that this command belongs to. /// Reference to the Block object that this command belongs to.
* This reference is only populated at runtime and in the editor when the /// This reference is only populated at runtime and in the editor when the
* block is selected. /// block is selected.
*/ /// </summary>
public Block ParentBlock { get; set; } public Block ParentBlock { get; set; }
/// <summary>
/// Returns the Flowchart that this command belongs to.
/// </summary>
public virtual Flowchart GetFlowchart() public virtual Flowchart GetFlowchart()
{ {
Flowchart flowchart = GetComponent<Flowchart>(); Flowchart flowchart = GetComponent<Flowchart>();
@ -82,11 +100,17 @@ namespace Fungus
return flowchart; return flowchart;
} }
/// <summary>
/// Execute the command.
/// </summary>
public virtual void Execute() public virtual void Execute()
{ {
OnEnter(); OnEnter();
} }
/// <summary>
/// End execution of this command and continue execution at the next command.
/// </summary>
public virtual void Continue() public virtual void Continue()
{ {
// This is a noop if the Block has already been stopped // This is a noop if the Block has already been stopped
@ -96,6 +120,10 @@ namespace Fungus
} }
} }
/// <summary>
/// End execution of this command and continue execution at a specific command index.
/// </summary>
/// <param name="nextCommandIndex">Next command index.</param>
public virtual void Continue(int nextCommandIndex) public virtual void Continue(int nextCommandIndex)
{ {
OnExit(); OnExit();
@ -105,6 +133,9 @@ namespace Fungus
} }
} }
/// <summary>
/// Stops the parent Block executing.
/// </summary>
public virtual void StopParentBlock() public virtual void StopParentBlock()
{ {
OnExit(); OnExit();
@ -114,99 +145,122 @@ namespace Fungus
} }
} }
/** /// <summary>
* Called when the parent block has been requested to stop executing, and /// Called when the parent block has been requested to stop executing, and
* this command is the currently executing command. /// this command is the currently executing command.
* Use this callback to terminate any asynchronous operations and /// Use this callback to terminate any asynchronous operations and
* cleanup state so that the command is ready to execute again later on. /// cleanup state so that the command is ready to execute again later on.
*/ /// </summary>
public virtual void OnStopExecuting() public virtual void OnStopExecuting()
{} {}
/** /// <summary>
* Called when the new command is added to a block in the editor. /// Called when the new command is added to a block in the editor.
*/ /// </summary>
public virtual void OnCommandAdded(Block parentBlock) public virtual void OnCommandAdded(Block parentBlock)
{} {}
/** /// <summary>
* Called when the command is deleted from a block in the editor. /// Called when the command is deleted from a block in the editor.
*/ /// </summary>
public virtual void OnCommandRemoved(Block parentBlock) public virtual void OnCommandRemoved(Block parentBlock)
{} {}
/// <summary>
/// Called when this command starts execution.
/// </summary>
public virtual void OnEnter() public virtual void OnEnter()
{} {}
/// <summary>
/// Called when this command ends execution.
/// </summary>
public virtual void OnExit() public virtual void OnExit()
{} {}
/// <summary>
/// Called when this command is reset. This happens when the Reset command is used.
/// </summary>
public virtual void OnReset() public virtual void OnReset()
{} {}
/// <summary>
/// Populates a list with the Blocks that this command references.
/// </summary>
public virtual void GetConnectedBlocks(ref List<Block> connectedBlocks) public virtual void GetConnectedBlocks(ref List<Block> connectedBlocks)
{} {}
/// <summary>
/// Returns true if this command references the variable.
/// Used to highlight variables in the variable list when a command is selected.
/// </summary>
public virtual bool HasReference(Variable variable) public virtual bool HasReference(Variable variable)
{ {
return false; return false;
} }
/// <summary>
/// Returns the summary text to display in the command inspector.
/// </summary>
public virtual string GetSummary() public virtual string GetSummary()
{ {
return ""; return "";
} }
/// <summary>
/// Returns the help text to display for this command.
/// </summary>
public virtual string GetHelpText() public virtual string GetHelpText()
{ {
return ""; return "";
} }
/** /// <summary>
* This command starts a block of commands. /// Return true if this command opens a block of commands. Used for indenting commands.
*/ /// </summary>
public virtual bool OpenBlock() public virtual bool OpenBlock()
{ {
return false; return false;
} }
/** /// <summary>
* This command ends a block of commands. /// Return true if this command closes a block of commands. Used for indenting commands.
*/ /// </summary>
public virtual bool CloseBlock() public virtual bool CloseBlock()
{ {
return false; return false;
} }
/** /// <summary>
* Return the color for the command background in inspector. /// Return the color for the command background in inspector.
*/ /// </summary>
/// <returns>The button color.</returns>
public virtual Color GetButtonColor() public virtual Color GetButtonColor()
{ {
return Color.white; return Color.white;
} }
/** /// <summary>
* Returns true if the specified property should be displayed in the inspector. /// Returns true if the specified property should be displayed in the inspector.
* This is useful for hiding certain properties based on the value of another property. /// This is useful for hiding certain properties based on the value of another property.
*/ /// </summary>
public virtual bool IsPropertyVisible(string propertyName) public virtual bool IsPropertyVisible(string propertyName)
{ {
return true; return true;
} }
/** /// <summary>
* Returns true if the specified property should be displayed as a reorderable list in the inspector. /// Returns true if the specified property should be displayed as a reorderable list in the inspector.
* This only applies for array properties and has no effect for non-array properties. /// This only applies for array properties and has no effect for non-array properties.
*/ /// </summary>
public virtual bool IsReorderableArray(string propertyName) public virtual bool IsReorderableArray(string propertyName)
{ {
return false; return false;
} }
/** /// <summary>
* Returns the localization id for the Flowchart that contains this command. /// Returns the localization id for the Flowchart that contains this command.
*/ /// </summary>
public virtual string GetFlowchartLocalizationId() public virtual string GetFlowchartLocalizationId()
{ {
// If no localization id has been set then use the Flowchart name // If no localization id has been set then use the Flowchart name
@ -224,7 +278,5 @@ namespace Fungus
return localizationId; return localizationId;
} }
} }
} }

13
Assets/Fungus/Flowchart/Scripts/CommandCopyBuffer.cs

@ -4,20 +4,21 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Temporary buffer object used when copying and pasting commands.
/// </summary>
[AddComponentMenu("")] [AddComponentMenu("")]
public class CommandCopyBuffer : Block public class CommandCopyBuffer : Block
{ {
protected static CommandCopyBuffer instance; protected static CommandCopyBuffer instance;
/** /// <summary>
* Returns the CommandCopyBuffer singleton instance. /// Returns the CommandCopyBuffer singleton instance.
* Will create a CommandCopyBuffer game object if none currently exists. /// Will create a CommandCopyBuffer game object if none currently exists.
*/ /// </summary>
static public CommandCopyBuffer GetInstance() static public CommandCopyBuffer GetInstance()
{ {
if (instance == null) if (instance == null)

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

@ -4,12 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Force a loop to terminate immediately.
/// </summary>
[CommandInfo("Flow", [CommandInfo("Flow",
"Break", "Break",
"Force a loop to terminate immediately.")] "Force a loop to terminate immediately.")]

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

@ -5,13 +5,14 @@
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization; using UnityEngine.Serialization;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System; using System;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Execute another block in the same Flowchart as the command, or in a different Flowchart.
/// </summary>
[CommandInfo("Flow", [CommandInfo("Flow",
"Call", "Call",
"Execute another block in the same Flowchart as the command, or in a different Flowchart.")] "Execute another block in the same Flowchart as the command, or in a different Flowchart.")]

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

@ -4,13 +4,14 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
namespace Fungus namespace Fungus
{ {
// This command is called "Call Method" because a) it's more descriptive than Send Message and we're already have /// <summary>
// a Send Message command for sending messages to trigger block execution. /// Calls a named method on a GameObject using the GameObject.SendMessage() system.
/// This command is called "Call Method" because a) it's more descriptive than Send Message and we're already have
/// a Send Message command for sending messages to trigger block execution.
/// </summary>
[CommandInfo("Scripting", [CommandInfo("Scripting",
"Call Method", "Call Method",
"Calls a named method on a GameObject using the GameObject.SendMessage() system.")] "Calls a named method on a GameObject using the GameObject.SendMessage() system.")]

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

@ -4,11 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Use comments to record design notes and reminders about your game.
/// </summary>
[CommandInfo("", [CommandInfo("",
"Comment", "Comment",
"Use comments to record design notes and reminders about your game.")] "Use comments to record design notes and reminders about your game.")]

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

@ -4,8 +4,6 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {

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

@ -4,10 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Writes a log message to the debug console.
/// </summary>
[CommandInfo("Scripting", [CommandInfo("Scripting",
"Debug Log", "Debug Log",
"Writes a log message to the debug console.")] "Writes a log message to the debug console.")]

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

@ -4,11 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Deletes a saved value from permanent storage.
/// </summary>
[CommandInfo("Variable", [CommandInfo("Variable",
"Delete Save Key", "Delete Save Key",
"Deletes a saved value from permanent storage.")] "Deletes a saved value from permanent storage.")]

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

@ -5,11 +5,12 @@
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization; using UnityEngine.Serialization;
using System.Collections;
using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Destroys a specified game object in the scene.
/// </summary>
[CommandInfo("Scripting", [CommandInfo("Scripting",
"Destroy", "Destroy",
"Destroys a specified game object in the scene.")] "Destroys a specified game object in the scene.")]

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

@ -4,11 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Marks the start of a command block to be executed when the preceding If statement is False.
/// </summary>
[CommandInfo("Flow", [CommandInfo("Flow",
"Else", "Else",
"Marks the start of a command block to be executed when the preceding If statement is False.")] "Marks the start of a command block to be executed when the preceding If statement is False.")]

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

@ -4,20 +4,18 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Marks the start of a command block to be executed when the preceding If statement is False and the test expression is true.
/// </summary>
[CommandInfo("Flow", [CommandInfo("Flow",
"Else If", "Else If",
"Marks the start of a command block to be executed when the preceding If statement is False and the test expression is true.")] "Marks the start of a command block to be executed when the preceding If statement is False and the test expression is true.")]
[AddComponentMenu("")] [AddComponentMenu("")]
public class ElseIf : If public class ElseIf : If
{ {
public override void OnEnter() public override void OnEnter()
{ {
System.Type previousCommandType = ParentBlock.GetPreviousActiveCommandType(); System.Type previousCommandType = ParentBlock.GetPreviousActiveCommandType();

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

@ -4,12 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Marks the end of a conditional block.
/// </summary>
[CommandInfo("Flow", [CommandInfo("Flow",
"End", "End",
"Marks the end of a conditional block.")] "Marks the end of a conditional block.")]

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

@ -4,12 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// If the test expression is true, execute the following command block.
/// </summary>
[CommandInfo("Flow", [CommandInfo("Flow",
"If", "If",
"If the test expression is true, execute the following command block.")] "If the test expression is true, execute the following command block.")]

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

@ -4,20 +4,21 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
using System; using System;
using UnityEngine.Events; using UnityEngine.Events;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Calls a list of component methods via the Unity Event System (as used in the Unity UI)
/// This command is more efficient than the Invoke Method command but can only pass a single parameter and doesn't support return values.
/// This command uses the UnityEvent system to call methods in script. http://docs.unity3d.com/Manual/UnityEvents.html
/// </summary>
[CommandInfo("Scripting", [CommandInfo("Scripting",
"Invoke Event", "Invoke Event",
"Calls a list of component methods via the Unity Event System (as used in the Unity UI). " + "Calls a list of component methods via the Unity Event System (as used in the Unity UI). " +
"This command is more efficient than the Invoke Method command but can only pass a single parameter and doesn't support return values.")] "This command is more efficient than the Invoke Method command but can only pass a single parameter and doesn't support return values.")]
[AddComponentMenu("")] [AddComponentMenu("")]
// This command uses the UnityEvent system to call methods in script.
// http://docs.unity3d.com/Manual/UnityEvents.html
public class InvokeEvent : Command public class InvokeEvent : Command
{ {
[Serializable] public class BooleanEvent : UnityEvent<bool> {} [Serializable] public class BooleanEvent : UnityEvent<bool> {}

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

@ -6,7 +6,6 @@
using UnityEngine; using UnityEngine;
using System.Collections; using System.Collections;
using System.Reflection; using System.Reflection;
using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using System; using System;
using UnityEngine.Events; using UnityEngine.Events;
@ -14,7 +13,9 @@ using MarkerMetro.Unity.WinLegacy.Reflection;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Invokes a method of a component via reflection. Supports passing multiple parameters and storing returned values in a Fungus variable.
/// </summary>
[CommandInfo("Scripting", [CommandInfo("Scripting",
"Invoke Method", "Invoke Method",
"Invokes a method of a component via reflection. Supports passing multiple parameters and storing returned values in a Fungus variable.")] "Invokes a method of a component via reflection. Supports passing multiple parameters and storing returned values in a Fungus variable.")]

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

@ -8,6 +8,9 @@ using UnityEngine.Serialization;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Move execution to a specific Label command in the same block.
/// </summary>
[CommandInfo("Flow", [CommandInfo("Flow",
"Jump", "Jump",
"Move execution to a specific Label command in the same block")] "Move execution to a specific Label command in the same block")]

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

@ -4,11 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Marks a position in the command list for execution to jump to.
/// </summary>
[CommandInfo("Flow", [CommandInfo("Flow",
"Label", "Label",
"Marks a position in the command list for execution to jump to.")] "Marks a position in the command list for execution to jump to.")]

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

@ -5,11 +5,15 @@
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization; using UnityEngine.Serialization;
using System;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Loads a new Unity scene and displays an optional loading image. This is useful
/// for splitting a large game across multiple scene files to reduce peak memory
/// usage. Previously loaded assets will be released before loading the scene to free up memory.
/// The scene to be loaded must be added to the scene list in Build Settings.")]
/// </summary>
[CommandInfo("Flow", [CommandInfo("Flow",
"Load Scene", "Load Scene",
"Loads a new Unity scene and displays an optional loading image. This is useful " + "Loads a new Unity scene and displays an optional loading image. This is useful " +
@ -38,7 +42,7 @@ namespace Fungus
return "Error: No scene name selected"; return "Error: No scene name selected";
} }
return _sceneName; return _sceneName.Value;
} }
public override Color GetButtonColor() public override Color GetButtonColor()

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

@ -4,11 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Loads a saved value and stores it in a Boolean, Integer, Float or String variable. If the key is not found then the variable is not modified.
/// </summary>
[CommandInfo("Variable", [CommandInfo("Variable",
"Load Variable", "Load Variable",
"Loads a saved value and stores it in a Boolean, Integer, Float or String variable. If the key is not found then the variable is not modified.")] "Loads a saved value and stores it in a Boolean, Integer, Float or String variable. If the key is not found then the variable is not modified.")]

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

@ -4,12 +4,13 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
using Fungus; using Fungus;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Opens the specified URL in the browser.
/// </summary>
[CommandInfo("Scripting", [CommandInfo("Scripting",
"Open URL", "Open URL",
"Opens the specified URL in the browser.")] "Opens the specified URL in the browser.")]

5
Assets/Fungus/Flowchart/Scripts/Commands/Quit.cs

@ -4,11 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Quits the application. Does not work in Editor or Webplayer builds. Shouldn't generally be used on iOS.
/// </summary>
[CommandInfo("Flow", [CommandInfo("Flow",
"Quit", "Quit",
"Quits the application. Does not work in Editor or Webplayer builds. Shouldn't generally be used on iOS.")] "Quits the application. Does not work in Editor or Webplayer builds. Shouldn't generally be used on iOS.")]

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

@ -4,10 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Sets an float variable to a random value in the defined range.
/// </summary>
[CommandInfo("Variable", [CommandInfo("Variable",
"Random Float", "Random Float",
"Sets an float variable to a random value in the defined range.")] "Sets an float variable to a random value in the defined range.")]

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

@ -4,10 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Sets an integer variable to a random value in the defined range.
/// </summary>
[CommandInfo("Variable", [CommandInfo("Variable",
"Random Integer", "Random Integer",
"Sets an integer variable to a random value in the defined range.")] "Sets an integer variable to a random value in the defined range.")]

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

@ -4,12 +4,13 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
using Fungus; using Fungus;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Reads in a text file and stores the contents in a string variable.
/// </summary>
[CommandInfo("Variable", [CommandInfo("Variable",
"Read Text File", "Read Text File",
"Reads in a text file and stores the contents in a string variable")] "Reads in a text file and stores the contents in a string variable")]

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

@ -4,11 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Resets the state of all commands and variables in the Flowchart.
/// </summary>
[CommandInfo("Variable", [CommandInfo("Variable",
"Reset", "Reset",
"Resets the state of all commands and variables in the Flowchart.")] "Resets the state of all commands and variables in the Flowchart.")]

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

@ -4,11 +4,14 @@
*/ */
using UnityEngine; using UnityEngine;
using System;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Save an Boolean, Integer, Float or String variable to persistent storage using a string key.
/// The value can be loaded again later using the Load Variable command. You can also
/// use the Set Save Profile command to manage separate save profiles for multiple players.
/// </summary>
[CommandInfo("Variable", [CommandInfo("Variable",
"Save Variable", "Save Variable",
"Save an Boolean, Integer, Float or String variable to persistent storage using a string key. " + "Save an Boolean, Integer, Float or String variable to persistent storage using a string key. " +

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

@ -5,10 +5,12 @@
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization; using UnityEngine.Serialization;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Sends a message to either the owner Flowchart or all Flowcharts in the scene. Blocks can listen for this message using a Message Received event handler.
/// </summary>
[CommandInfo("Flow", [CommandInfo("Flow",
"Send Message", "Send Message",
"Sends a message to either the owner Flowchart or all Flowcharts in the scene. Blocks can listen for this message using a Message Received event handler.")] "Sends a message to either the owner Flowchart or all Flowcharts in the scene. Blocks can listen for this message using a Message Received event handler.")]

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

@ -5,11 +5,12 @@
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization; using UnityEngine.Serialization;
using System.Collections;
using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Sets a game object in the scene to be active / inactive.
/// </summary>
[CommandInfo("Scripting", [CommandInfo("Scripting",
"Set Active", "Set Active",
"Sets a game object in the scene to be active / inactive.")] "Sets a game object in the scene to be active / inactive.")]

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

@ -9,6 +9,9 @@ using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Sets the active profile that the Save Variable and Load Variable commands will use. This is useful to crete multiple player save games. Once set, the profile applies across all Flowcharts and will also persist across scene loads.
/// </summary>
[CommandInfo("Variable", [CommandInfo("Variable",
"Set Save Profile", "Set Save Profile",
"Sets the active profile that the Save Variable and Load Variable commands will use. This is useful to crete multiple player save games. Once set, the profile applies across all Flowcharts and will also persist across scene loads.")] "Sets the active profile that the Save Variable and Load Variable commands will use. This is useful to crete multiple player save games. Once set, the profile applies across all Flowcharts and will also persist across scene loads.")]

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

@ -4,10 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Sets a Boolean, Integer, Float or String variable to a new value using a simple arithmetic operation. The value can be a constant or reference another variable of the same type.
/// </summary>
[CommandInfo("Variable", [CommandInfo("Variable",
"Set Variable", "Set Variable",
"Sets a Boolean, Integer, Float or String variable to a new value using a simple arithmetic operation. The value can be a constant or reference another variable of the same type.")] "Sets a Boolean, Integer, Float or String variable to a new value using a simple arithmetic operation. The value can be a constant or reference another variable of the same type.")]
@ -33,7 +35,6 @@ namespace Fungus
[Tooltip("The type of math operation to be performed")] [Tooltip("The type of math operation to be performed")]
[SerializeField] protected SetOperator setOperator; [SerializeField] protected SetOperator setOperator;
public SetOperator _SetOperator { get { return setOperator; } } public SetOperator _SetOperator { get { return setOperator; } }
[Tooltip("Boolean value to set with")] [Tooltip("Boolean value to set with")]

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

@ -5,13 +5,12 @@
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization; using UnityEngine.Serialization;
using System.Collections;
namespace Fungus namespace Fungus
{ {
// This command is called "Call Method" because a) it's more descriptive than Send Message and we're already have /// <summary>
// a Send Message command for sending messages to trigger block execution. /// Spawns a new object based on a reference to a scene or prefab game object.
/// </summary>
[CommandInfo("Scripting", [CommandInfo("Scripting",
"Spawn Object", "Spawn Object",
"Spawns a new object based on a reference to a scene or prefab game object.")] "Spawns a new object based on a reference to a scene or prefab game object.")]

5
Assets/Fungus/Flowchart/Scripts/Commands/Stop.cs

@ -4,11 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Stop executing the Block that contains this command.
/// </summary>
[CommandInfo("Flow", [CommandInfo("Flow",
"Stop", "Stop",
"Stop executing the Block that contains this command.")] "Stop executing the Block that contains this command.")]

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

@ -4,11 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Stops executing the named Block.
/// </summary>
[CommandInfo("Flow", [CommandInfo("Flow",
"Stop Block", "Stop Block",
"Stops executing the named Block")] "Stops executing the named Block")]

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

@ -4,11 +4,13 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Stops execution of all Blocks in a Flowchart.
/// </summary>
[CommandInfo("Flow", [CommandInfo("Flow",
"Stop Flowchart", "Stop Flowchart",
"Stops execution of all Blocks in a Flowchart")] "Stops execution of all Blocks in a Flowchart")]

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

@ -5,11 +5,12 @@
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization; using UnityEngine.Serialization;
using System;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Waits for period of time before executing the next command in the block.
/// </summary>
[CommandInfo("Flow", [CommandInfo("Flow",
"Wait", "Wait",
"Waits for period of time before executing the next command in the block.")] "Waits for period of time before executing the next command in the block.")]

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

@ -4,12 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Continuously loop through a block of commands while the condition is true. Use the Break command to force the loop to terminate immediately.
/// </summary>
[CommandInfo("Flow", [CommandInfo("Flow",
"While", "While",
"Continuously loop through a block of commands while the condition is true. Use the Break command to force the loop to terminate immediately.")] "Continuously loop through a block of commands while the condition is true. Use the Break command to force the loop to terminate immediately.")]

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

@ -6,12 +6,12 @@
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization; using UnityEngine.Serialization;
using System; using System;
using System.Collections;
using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Attribute class for Fungus event handlers.
/// </summary>
public class EventHandlerInfoAttribute : Attribute public class EventHandlerInfoAttribute : Attribute
{ {
public EventHandlerInfoAttribute(string category, string eventHandlerName, string helpText) public EventHandlerInfoAttribute(string category, string eventHandlerName, string helpText)
@ -26,28 +26,31 @@ namespace Fungus
public string HelpText { get; set; } public string HelpText { get; set; }
} }
/** /// <summary>
* A Block may have an associated Event Handler which starts executing commands when /// A Block may have an associated Event Handler which starts executing commands when
* a specific event occurs. /// a specific event occurs.
* To create a custom Event Handler, simply subclass EventHandler and call the ExecuteBlock() method /// To create a custom Event Handler, simply subclass EventHandler and call the ExecuteBlock() method
* when the event occurs. /// when the event occurs.
* Add an EventHandlerInfo attibute and your new EventHandler class will automatically appear in the /// Add an EventHandlerInfo attibute and your new EventHandler class will automatically appear in the
* 'Execute On Event' dropdown menu when a block is selected. /// 'Execute On Event' dropdown menu when a block is selected.
*/ /// </summary>
[RequireComponent(typeof(Block))] [RequireComponent(typeof(Block))]
[RequireComponent(typeof(Flowchart))] [RequireComponent(typeof(Flowchart))]
[AddComponentMenu("")] [AddComponentMenu("")]
public class EventHandler : MonoBehaviour public class EventHandler : MonoBehaviour
{ {
/// <summary>
/// Returns the parent Block which owns this Event Handler.
/// </summary>
/// <value>The parent block.</value>
[HideInInspector] [HideInInspector]
[FormerlySerializedAs("parentSequence")] [FormerlySerializedAs("parentSequence")]
[SerializeField] protected Block parentBlock; [SerializeField] protected Block parentBlock;
public Block ParentBlock { get { return parentBlock; } set { parentBlock = value; } } public Block ParentBlock { get { return parentBlock; } set { parentBlock = value; } }
/** /// <summary>
* The Event Handler should call this method when the event is detected. /// The Event Handler should call this method when the event is detected.
*/ /// </summary>
public virtual bool ExecuteBlock() public virtual bool ExecuteBlock()
{ {
if (parentBlock == null) if (parentBlock == null)
@ -71,9 +74,9 @@ namespace Fungus
return flowchart.ExecuteBlock(parentBlock); return flowchart.ExecuteBlock(parentBlock);
} }
/** /// <summary>
* Returns a custom summary for the event handler. /// Returns custom summary text for the event handler.
*/ /// </summary>
public virtual string GetSummary() public virtual string GetSummary()
{ {
return ""; return "";

6
Assets/Fungus/Flowchart/Scripts/EventHandlers/FlowchartEnabled.cs

@ -4,12 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// The block will execute when the Flowchart game object is enabled.
/// </summary>
[EventHandlerInfo("", [EventHandlerInfo("",
"Flowchart Enabled", "Flowchart Enabled",
"The block will execute when the Flowchart game object is enabled.")] "The block will execute when the Flowchart game object is enabled.")]

6
Assets/Fungus/Flowchart/Scripts/EventHandlers/GameStarted.cs

@ -4,12 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// The block will execute when the game starts playing.
/// </summary>
[EventHandlerInfo("", [EventHandlerInfo("",
"Game Started", "Game Started",
"The block will execute when the game starts playing.")] "The block will execute when the game starts playing.")]

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

@ -4,10 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// The block will execute when a key press event occurs.
/// </summary>
[EventHandlerInfo("Input", [EventHandlerInfo("Input",
"Key Pressed", "Key Pressed",
"The block will execute when a key press event occurs.")] "The block will execute when a key press event occurs.")]

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

@ -4,10 +4,12 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// The block will execute when the specified message is received from a Send Message command.
/// </summary>
[EventHandlerInfo("", [EventHandlerInfo("",
"Message Received", "Message Received",
"The block will execute when the specified message is received from a Send Message command.")] "The block will execute when the specified message is received from a Send Message command.")]

422
Assets/Fungus/Flowchart/Scripts/Flowchart.cs

@ -14,207 +14,194 @@ using System.Text.RegularExpressions;
namespace Fungus namespace Fungus
{ {
/** /// <summary>
* Interface for Flowchart components which can be updated when the /// Interface for Flowchart components which can be updated when the
* scene loads in the editor. This is used to maintain backwards /// scene loads in the editor. This is used to maintain backwards
* compatibility with earlier versions of Fungus. /// compatibility with earlier versions of Fungus.
*/ /// </summary>
interface IUpdateable interface IUpdateable
{ {
void UpdateToVersion(int oldVersion, int newVersion); void UpdateToVersion(int oldVersion, int newVersion);
} }
/** /// <summary>
* Visual scripting controller for the Flowchart programming language. /// Visual scripting controller for the Flowchart programming language.
* Flowchart objects may be edited visually using the Flowchart editor window. /// Flowchart objects may be edited visually using the Flowchart editor window.
*/ /// </summary>
[ExecuteInEditMode] [ExecuteInEditMode]
public class Flowchart : MonoBehaviour, StringSubstituter.ISubstitutionHandler public class Flowchart : MonoBehaviour, StringSubstituter.ISubstitutionHandler
{ {
/** /// <summary>
* The current version of the Flowchart. Used for updating components. /// The current version of the Flowchart. Used for updating components.
*/ /// </summary>
public const int CURRENT_VERSION = 1; public const int CURRENT_VERSION = 1;
/** /// <summary>
* The name of the initial block in a new flowchart. /// The name of the initial block in a new flowchart.
*/ /// </summary>
public const string DEFAULT_BLOCK_NAME = "New Block"; public const string DEFAULT_BLOCK_NAME = "New Block";
/** /// <summary>
* Variable to track flowchart's version so components can update to new versions. /// Variable to track flowchart's version so components can update to new versions.
*/ /// </summary>
[HideInInspector] [HideInInspector]
[SerializeField] protected 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; } } public int Version { set { version = value; } }
/** /// <summary>
* Scroll position of Flowchart editor window. /// Scroll position of Flowchart editor window.
*/ /// </summary>
[HideInInspector] [HideInInspector]
[SerializeField] protected Vector2 scrollPos; [SerializeField] protected Vector2 scrollPos;
public Vector2 ScrollPos { get { return scrollPos; } set { scrollPos = value; } } public Vector2 ScrollPos { get { return scrollPos; } set { scrollPos = value; } }
/** /// <summary>
* Scroll position of Flowchart variables window. /// Scroll position of Flowchart variables window.
*/ /// </summary>
[HideInInspector] [HideInInspector]
[SerializeField] protected Vector2 variablesScrollPos; [SerializeField] protected Vector2 variablesScrollPos;
public Vector2 VariablesScrollPos { get { return variablesScrollPos; } set { variablesScrollPos = value; } } public Vector2 VariablesScrollPos { get { return variablesScrollPos; } set { variablesScrollPos = value; } }
/** /// <summary>
* Show the variables pane. /// Show the variables pane.
*/ /// </summary>
[HideInInspector] [HideInInspector]
[SerializeField] protected bool variablesExpanded = true; [SerializeField] protected bool variablesExpanded = true;
public bool VariablesExpanded { get { return variablesExpanded; } set { variablesExpanded = value; } } public bool VariablesExpanded { get { return variablesExpanded; } set { variablesExpanded = value; } }
/** /// <summary>
* Height of command block view in inspector. /// Height of command block view in inspector.
*/ /// </summary>
[HideInInspector] [HideInInspector]
[SerializeField] protected float blockViewHeight = 400; [SerializeField] protected float blockViewHeight = 400;
public float BlockViewHeight { get { return blockViewHeight; } set { blockViewHeight = value; } } public float BlockViewHeight { get { return blockViewHeight; } set { blockViewHeight = value; } }
/** /// <summary>
* Zoom level of Flowchart editor window /// Zoom level of Flowchart editor window.
*/ /// </summary>
[HideInInspector] [HideInInspector]
[SerializeField] protected float zoom = 1f; [SerializeField] protected float zoom = 1f;
public float Zoom { get { return zoom; } set { zoom = value; } } public float Zoom { get { return zoom; } set { zoom = value; } }
/** /// <summary>
* Scrollable area for Flowchart editor window. /// Scrollable area for Flowchart editor window.
*/ /// </summary>
[HideInInspector] [HideInInspector]
[SerializeField] protected Rect scrollViewRect; [SerializeField] protected Rect scrollViewRect;
public Rect ScrollViewRect { get { return scrollViewRect; } set { scrollViewRect = value; } } public Rect ScrollViewRect { get { return scrollViewRect; } set { scrollViewRect = value; } }
/** /// <summary>
* Currently selected block in the Flowchart editor. /// Currently selected block in the Flowchart editor.
*/ /// </summary>
[HideInInspector] [HideInInspector]
[FormerlySerializedAs("selectedSequence")] [FormerlySerializedAs("selectedSequence")]
[SerializeField] protected Block selectedBlock; [SerializeField] protected Block selectedBlock;
public Block SelectedBlock { get { return selectedBlock; } set { selectedBlock = value; } } public Block SelectedBlock { get { return selectedBlock; } set { selectedBlock = value; } }
/** /// <summary>
* Currently selected command in the Flowchart editor. /// Currently selected command in the Flowchart editor.
*/ /// </summary>
[HideInInspector] [HideInInspector]
[SerializeField] protected List<Command> selectedCommands = new List<Command>(); [SerializeField] protected List<Command> selectedCommands = new List<Command>();
public List<Command> SelectedCommands { get { return selectedCommands; } } public List<Command> SelectedCommands { get { return selectedCommands; } }
/** /// <summary>
* The list of variables that can be accessed by the Flowchart. /// The list of variables that can be accessed by the Flowchart.
*/ /// </summary>
[HideInInspector] [HideInInspector]
[SerializeField] protected List<Variable> variables = new List<Variable>(); [SerializeField] protected List<Variable> variables = new List<Variable>();
public List<Variable> Variables { get { return variables; } } public List<Variable> Variables { get { return variables; } }
/// <summary>
/// Description text displayed in the Flowchart editor window
/// </summary>
[TextArea(3, 5)] [TextArea(3, 5)]
[Tooltip("Description text displayed in the Flowchart editor window")] [Tooltip("Description text displayed in the Flowchart editor window")]
[SerializeField] protected string description = ""; [SerializeField] protected string description = "";
public string Description { get { return description; } } public string Description { get { return description; } }
/** /// <summary>
* Slow down execution in the editor to make it easier to visualise program flow. /// Slow down execution in the editor to make it easier to visualise program flow.
*/ /// </summary>
[Range(0f, 5f)] [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.")] [Tooltip("Adds a pause after each execution step to make it easier to visualise program flow. Editor only, has no effect in platform builds.")]
[SerializeField] protected float stepPause = 0f; [SerializeField] protected float stepPause = 0f;
public float StepPause { get { return stepPause; } } public float StepPause { get { return stepPause; } }
/** /// <summary>
* Use command color when displaying the command list in the inspector. /// Use command color when displaying the command list in the inspector.
*/ /// </summary>
[Tooltip("Use command color when displaying the command list in the Fungus Editor window")] [Tooltip("Use command color when displaying the command list in the Fungus Editor window")]
[SerializeField] protected bool colorCommands = true; [SerializeField] protected bool colorCommands = true;
public bool ColorCommands { get { return colorCommands; } } public bool ColorCommands { get { return colorCommands; } }
/** /// <summary>
* Hides the Flowchart block and command components in the inspector. /// Hides the Flowchart block and command components in the inspector.
* Deselect to inspect the block and command components that make up the Flowchart. /// Deselect to inspect the block and command components that make up the Flowchart.
*/ /// </summary>
[Tooltip("Hides the Flowchart block and command components in the inspector")] [Tooltip("Hides the Flowchart block and command components in the inspector. Deselect to inspect the block and command components that make up the Flowchart.")]
[SerializeField] protected bool hideComponents = true; [SerializeField] protected bool hideComponents = true;
/** /// <summary>
* Saves the selected block and commands when saving the scene. /// Saves the selected block and commands when saving the scene. Helps avoid version control conflicts if you've only changed the active selection.
* Helps avoid version control conflicts if you've only changed the active selection. /// </summary>
*/ [Tooltip("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.")]
[SerializeField] protected bool saveSelection = true; [SerializeField] protected bool saveSelection = true;
public bool SaveSelection { get { return saveSelection; } } public bool SaveSelection { get { return saveSelection; } }
/** /// <summary>
* Unique identifier for identifying this flowchart in localized string keys. /// Unique identifier for identifying this flowchart in localized string keys.
*/ /// </summary>
[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.")] [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.")]
[SerializeField] protected string localizationId = ""; [SerializeField] protected string localizationId = "";
public string LocalizationId { get { return localizationId; } } public string LocalizationId { get { return localizationId; } }
/** /// <summary>
* Display line numbers in the command list in the Block inspector. /// Display line numbers in the command list in the Block inspector.
*/ /// </summary>
[Tooltip("Display line numbers in the command list in the Block inspector.")] [Tooltip("Display line numbers in the command list in the Block inspector.")]
[SerializeField] protected bool showLineNumbers = false; [SerializeField] protected bool showLineNumbers = false;
public bool ShowLineNumbers { get { return showLineNumbers; } } public bool ShowLineNumbers { get { return showLineNumbers; } }
/** /// <summary>
* List of commands to hide in the Add Command menu. Use this to restrict the set of commands available when editing a Flowchart. /// List of commands to hide in the Add Command menu. Use this to restrict the set of commands available when editing a Flowchart.
*/ /// </summary>
[Tooltip("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.")]
[SerializeField] protected List<string> hideCommands = new List<string>(); [SerializeField] protected List<string> hideCommands = new List<string>();
/// <summary>
/// Lua Environment to be used by default for all Execute Lua commands in this Flowchart.
/// </summary>
[Tooltip("Lua Environment to be used by default for all Execute Lua commands in this Flowchart")] [Tooltip("Lua Environment to be used by default for all Execute Lua commands in this Flowchart")]
[SerializeField] protected LuaEnvironment luaEnvironment; [SerializeField] protected LuaEnvironment luaEnvironment;
public LuaEnvironment _LuaEnvironment { get { return luaEnvironment; } } public LuaEnvironment _LuaEnvironment { get { return luaEnvironment; } }
/** /// <summary>
* The ExecuteLua command adds a global Lua variable with this name bound to the flowchart prior to executing. /// The ExecuteLua command adds a global Lua variable with this name bound to the flowchart prior to executing.
*/ /// </summary>
[Tooltip("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.")]
[SerializeField] protected string luaBindingName = "flowchart"; [SerializeField] protected string luaBindingName = "flowchart";
public string LuaBindingName { get { return luaBindingName; } } public string LuaBindingName { get { return luaBindingName; } }
/** /// <summary>
* Position in the center of all blocks in the flowchart. /// Position in the center of all blocks in the flowchart.
*/ /// </summary>
public Vector2 CenterPosition { set; get; } public Vector2 CenterPosition { set; get; }
/** /// <summary>
* Cached list of flowchart objects in the scene for fast lookup /// Cached list of flowchart objects in the scene for fast lookup.
*/ /// </summary>
public static List<Flowchart> cachedFlowcharts = new List<Flowchart>(); public static List<Flowchart> cachedFlowcharts = new List<Flowchart>();
protected static bool eventSystemPresent; protected static bool eventSystemPresent;
protected StringSubstituter stringSubstituer; protected StringSubstituter stringSubstituer;
/** /// <summary>
* Returns the next id to assign to a new flowchart item. /// Returns the next id to assign to a new flowchart item.
* Item ids increase monotically so they are guaranteed to /// Item ids increase monotically so they are guaranteed to
* be unique within a Flowchart. /// be unique within a Flowchart.
*/ /// </summary>
public int NextItemId() public int NextItemId()
{ {
int maxId = -1; int maxId = -1;
@ -410,9 +397,9 @@ namespace Fungus
return block; return block;
} }
/** /// <summary>
* Create a new block node which you can then add commands to. /// Create a new block node which you can then add commands to.
*/ /// </summary>
public virtual Block CreateBlock(Vector2 position) public virtual Block CreateBlock(Vector2 position)
{ {
Block b = CreateBlockComponent(gameObject); Block b = CreateBlockComponent(gameObject);
@ -423,9 +410,9 @@ namespace Fungus
return b; return b;
} }
/** /// <summary>
* Returns the named Block in the flowchart, or null if not found. /// Returns the named Block in the flowchart, or null if not found.
*/ /// </summary>
public virtual Block FindBlock(string blockName) public virtual Block FindBlock(string blockName)
{ {
Block [] blocks = GetComponents<Block>(); Block [] blocks = GetComponents<Block>();
@ -440,11 +427,9 @@ namespace Fungus
return null; return null;
} }
/** /// <summary>
* Execute a child block in the Flowchart. /// Execute a child block in the Flowchart.
* You can use this method in a UI event. e.g. to handle a button click. /// You can use this method in a UI event. e.g. to handle a button click.
* Returns true if the Block started execution.
*/
public virtual void ExecuteBlock(string blockName) public virtual void ExecuteBlock(string blockName)
{ {
Block block = null; Block block = null;
@ -469,12 +454,12 @@ namespace Fungus
} }
} }
/** /// <summary>
* Execute a child block in the flowchart. /// Execute a child block in the flowchart.
* The block must be in an idle state to be executed. /// The block must be in an idle state to be executed.
* This version provides extra options to control how the block is executed. /// This version provides extra options to control how the block is executed.
* Returns true if the Block started execution. /// Returns true if the Block started execution.
*/ /// </summary>
public virtual bool ExecuteBlock(Block block, int commandIndex = 0, Action onComplete = null) public virtual bool ExecuteBlock(Block block, int commandIndex = 0, Action onComplete = null)
{ {
if (block == null) if (block == null)
@ -501,9 +486,9 @@ namespace Fungus
return true; return true;
} }
/** /// <summary>
* Stop all executing Blocks in this Flowchart. /// Stop all executing Blocks in this Flowchart.
*/ /// </summary>
public virtual void StopAllBlocks() public virtual void StopAllBlocks()
{ {
Block [] blocks = GetComponents<Block>(); Block [] blocks = GetComponents<Block>();
@ -516,10 +501,10 @@ namespace Fungus
} }
} }
/** /// <summary>
* Sends a message to this Flowchart only. /// Sends a message to this Flowchart only.
* Any block with a matching MessageReceived event handler will start executing. /// Any block with a matching MessageReceived event handler will start executing.
*/ /// </summary>
public virtual void SendFungusMessage(string messageName) public virtual void SendFungusMessage(string messageName)
{ {
MessageReceived[] eventHandlers = GetComponents<MessageReceived>(); MessageReceived[] eventHandlers = GetComponents<MessageReceived>();
@ -529,10 +514,10 @@ namespace Fungus
} }
} }
/** /// <summary>
* Sends a message to all Flowchart objects in the current scene. /// Sends a message to all Flowchart objects in the current scene.
* Any block with a matching MessageReceived event handler will start executing. /// Any block with a matching MessageReceived event handler will start executing.
*/ /// </summary>
public static void BroadcastFungusMessage(string messageName) public static void BroadcastFungusMessage(string messageName)
{ {
MessageReceived[] eventHandlers = UnityEngine.Object.FindObjectsOfType<MessageReceived>(); MessageReceived[] eventHandlers = UnityEngine.Object.FindObjectsOfType<MessageReceived>();
@ -542,9 +527,9 @@ namespace Fungus
} }
} }
/** /// <summary>
* Returns a new variable key that is guaranteed not to clash with any existing variable in the list. /// Returns a new variable key that is guaranteed not to clash with any existing variable in the list.
*/ /// </summary>
public virtual string GetUniqueVariableKey(string originalKey, Variable ignoreVariable = null) public virtual string GetUniqueVariableKey(string originalKey, Variable ignoreVariable = null)
{ {
int suffix = 0; int suffix = 0;
@ -591,9 +576,9 @@ namespace Fungus
} }
} }
/** /// <summary>
* Returns a new Block key that is guaranteed not to clash with any existing Block in the Flowchart. /// Returns a new Block key that is guaranteed not to clash with any existing Block in the Flowchart.
*/ /// </summary>
public virtual string GetUniqueBlockKey(string originalKey, Block ignoreBlock = null) public virtual string GetUniqueBlockKey(string originalKey, Block ignoreBlock = null)
{ {
int suffix = 0; int suffix = 0;
@ -634,9 +619,9 @@ namespace Fungus
} }
} }
/** /// <summary>
* Returns a new Label key that is guaranteed not to clash with any existing Label in the Block. /// Returns a new Label key that is guaranteed not to clash with any existing Label in the Block.
*/ /// </summary>
public virtual string GetUniqueLabelKey(string originalKey, Label ignoreLabel) public virtual string GetUniqueLabelKey(string originalKey, Label ignoreLabel)
{ {
int suffix = 0; int suffix = 0;
@ -678,13 +663,13 @@ namespace Fungus
} }
} }
/** /// <summary>
* Returns the variable with the specified key, or null if the key is not found. /// Returns the variable with the specified key, or null if the key is not found.
* You will need to cast the returned variable to the correct sub-type. /// You will need to cast the returned variable to the correct sub-type.
* You can then access the variable's value using the Value property. e.g. /// You can then access the variable's value using the Value property. e.g.
* BooleanVariable boolVar = flowchart.GetVariable("MyBool") as BooleanVariable; /// BooleanVariable boolVar = flowchart.GetVariable("MyBool") as BooleanVariable;
* boolVar.Value = false; /// boolVar.Value = false;
*/ /// </summary>
public Variable GetVariable(string key) public Variable GetVariable(string key)
{ {
foreach (Variable variable in variables) foreach (Variable variable in variables)
@ -698,12 +683,12 @@ namespace Fungus
return null; return null;
} }
/** /// <summary>
* Returns the variable with the specified key, or null if the key is not found. /// Returns the variable with the specified key, or null if the key is not found.
* You can then access the variable's value using the Value property. e.g. /// You can then access the variable's value using the Value property. e.g.
* BooleanVariable boolVar = flowchart.GetVariable<BooleanVariable>("MyBool"); /// BooleanVariable boolVar = flowchart.GetVariable<BooleanVariable>("MyBool");
* boolVar.Value = false; /// boolVar.Value = false;
*/ /// </summary>
public T GetVariable<T>(string key) where T : Variable public T GetVariable<T>(string key) where T : Variable
{ {
foreach (Variable variable in variables) foreach (Variable variable in variables)
@ -718,10 +703,10 @@ namespace Fungus
return null; return null;
} }
/** /// <summary>
* Register a new variable with the Flowchart at runtime. /// Register a new variable with the Flowchart at runtime.
* The variable should be added as a component on the Flowchart game object. /// The variable should be added as a component on the Flowchart game object.
*/ /// </summary>
public void SetVariable<T>(string key, T newvariable) where T : Variable public void SetVariable<T>(string key, T newvariable) where T : Variable
{ {
foreach (Variable v in variables) foreach (Variable v in variables)
@ -740,9 +725,9 @@ namespace Fungus
Debug.LogWarning("Variable " + key + " not found."); Debug.LogWarning("Variable " + key + " not found.");
} }
/** /// <summary>
* Gets a list of all variables with public scope in this Flowchart. /// Gets a list of all variables with public scope in this Flowchart.
*/ /// </summary>
public virtual List<Variable> GetPublicVariables() public virtual List<Variable> GetPublicVariables()
{ {
List<Variable> publicVariables = new List<Variable>(); List<Variable> publicVariables = new List<Variable>();
@ -757,10 +742,10 @@ namespace Fungus
return publicVariables; return publicVariables;
} }
/** /// <summary>
* Gets the value of a boolean variable. /// Gets the value of a boolean variable.
* Returns false if the variable key does not exist. /// Returns false if the variable key does not exist.
*/ /// </summary>
public virtual bool GetBooleanVariable(string key) public virtual bool GetBooleanVariable(string key)
{ {
BooleanVariable variable = GetVariable<BooleanVariable>(key); BooleanVariable variable = GetVariable<BooleanVariable>(key);
@ -775,10 +760,10 @@ namespace Fungus
} }
} }
/** /// <summary>
* Sets the value of a boolean variable. /// Sets the value of a boolean variable.
* The variable must already be added to the list of variables for this Flowchart. /// The variable must already be added to the list of variables for this Flowchart.
*/ /// </summary>
public virtual void SetBooleanVariable(string key, bool value) public virtual void SetBooleanVariable(string key, bool value)
{ {
BooleanVariable variable = GetVariable<BooleanVariable>(key); BooleanVariable variable = GetVariable<BooleanVariable>(key);
@ -788,10 +773,10 @@ namespace Fungus
} }
} }
/** /// <summary>
* Gets the value of an integer variable. /// Gets the value of an integer variable.
* Returns 0 if the variable key does not exist. /// Returns 0 if the variable key does not exist.
*/ /// </summary>
public virtual int GetIntegerVariable(string key) public virtual int GetIntegerVariable(string key)
{ {
IntegerVariable variable = GetVariable<IntegerVariable>(key); IntegerVariable variable = GetVariable<IntegerVariable>(key);
@ -806,10 +791,10 @@ namespace Fungus
} }
} }
/** /// <summary>
* Sets the value of an integer variable. /// Sets the value of an integer variable.
* The variable must already be added to the list of variables for this Flowchart. /// The variable must already be added to the list of variables for this Flowchart.
*/ /// </summary>
public virtual void SetIntegerVariable(string key, int value) public virtual void SetIntegerVariable(string key, int value)
{ {
IntegerVariable variable = GetVariable<IntegerVariable>(key); IntegerVariable variable = GetVariable<IntegerVariable>(key);
@ -819,10 +804,10 @@ namespace Fungus
} }
} }
/** /// <summary>
* Gets the value of a float variable. /// Gets the value of a float variable.
* Returns 0 if the variable key does not exist. /// Returns 0 if the variable key does not exist.
*/ /// </summary>
public virtual float GetFloatVariable(string key) public virtual float GetFloatVariable(string key)
{ {
FloatVariable variable = GetVariable<FloatVariable>(key); FloatVariable variable = GetVariable<FloatVariable>(key);
@ -837,10 +822,10 @@ namespace Fungus
} }
} }
/** /// <summary>
* Sets the value of a float variable. /// Sets the value of a float variable.
* The variable must already be added to the list of variables for this Flowchart. /// The variable must already be added to the list of variables for this Flowchart.
*/ /// </summary>
public virtual void SetFloatVariable(string key, float value) public virtual void SetFloatVariable(string key, float value)
{ {
FloatVariable variable = GetVariable<FloatVariable>(key); FloatVariable variable = GetVariable<FloatVariable>(key);
@ -850,10 +835,10 @@ namespace Fungus
} }
} }
/** /// <summary>
* Gets the value of a string variable. /// Gets the value of a string variable.
* Returns the empty string if the variable key does not exist. /// Returns the empty string if the variable key does not exist.
*/ /// </summary>
public virtual string GetStringVariable(string key) public virtual string GetStringVariable(string key)
{ {
StringVariable variable = GetVariable<StringVariable>(key); StringVariable variable = GetVariable<StringVariable>(key);
@ -868,10 +853,10 @@ namespace Fungus
} }
} }
/** /// <summary>
* Sets the value of a string variable. /// Sets the value of a string variable.
* The variable must already be added to the list of variables for this Flowchart. /// The variable must already be added to the list of variables for this Flowchart.
*/ /// </summary>
public virtual void SetStringVariable(string key, string value) public virtual void SetStringVariable(string key, string value)
{ {
StringVariable variable = GetVariable<StringVariable>(key); StringVariable variable = GetVariable<StringVariable>(key);
@ -881,9 +866,9 @@ namespace Fungus
} }
} }
/** /// <summary>
* Set the block objects to be hidden or visible depending on the hideComponents property. /// Set the block objects to be hidden or visible depending on the hideComponents property.
*/ /// </summary>
public virtual void UpdateHideFlags() public virtual void UpdateHideFlags()
{ {
if (hideComponents) if (hideComponents)
@ -927,11 +912,17 @@ namespace Fungus
} }
/// <summary>
/// Clears the list of selected commands.
/// </summary>
public virtual void ClearSelectedCommands() public virtual void ClearSelectedCommands()
{ {
selectedCommands.Clear(); selectedCommands.Clear();
} }
/// <summary>
/// Adds a command to the list of selected commands.
/// </summary>
public virtual void AddSelectedCommand(Command command) public virtual void AddSelectedCommand(Command command)
{ {
if (!selectedCommands.Contains(command)) if (!selectedCommands.Contains(command))
@ -940,6 +931,9 @@ namespace Fungus
} }
} }
/// <summary>
/// Reset the commands and variables in the Flowchart.
/// </summary>
public virtual void Reset(bool resetCommands, bool resetVariables) public virtual void Reset(bool resetCommands, bool resetVariables)
{ {
if (resetCommands) if (resetCommands)
@ -960,9 +954,9 @@ namespace Fungus
} }
} }
/** /// <summary>
* Override this in a Flowchart subclass to filter which commands are shown in the Add Command list. /// Override this in a Flowchart subclass to filter which commands are shown in the Add Command list.
*/ /// </summary>
public virtual bool IsCommandSupported(CommandInfoAttribute commandInfo) public virtual bool IsCommandSupported(CommandInfoAttribute commandInfo)
{ {
foreach (string key in hideCommands) foreach (string key in hideCommands)
@ -978,9 +972,9 @@ namespace Fungus
return true; return true;
} }
/** /// <summary>
* Returns true if there are any executing blocks in this Flowchart. /// Returns true if there are any executing blocks in this Flowchart.
*/ /// </summary>
public virtual bool HasExecutingBlocks() public virtual bool HasExecutingBlocks()
{ {
Block[] blocks = GetComponents<Block>(); Block[] blocks = GetComponents<Block>();
@ -994,9 +988,9 @@ namespace Fungus
return false; return false;
} }
/** /// <summary>
* Returns a list of all executing blocks in this Flowchart. /// Returns a list of all executing blocks in this Flowchart.
*/ /// </summary>
public virtual List<Block> GetExecutingBlocks() public virtual List<Block> GetExecutingBlocks()
{ {
List<Block> executingBlocks = new List<Block>(); List<Block> executingBlocks = new List<Block>();
@ -1013,11 +1007,11 @@ namespace Fungus
return executingBlocks; return executingBlocks;
} }
/** /// <summary>
* Implementation of StringSubstituter.ISubstitutionHandler which matches any public variable in the Flowchart. /// Implementation of StringSubstituter.ISubstitutionHandler which matches any public variable in the Flowchart.
* To perform full variable substitution with all substitution handlers in the scene, you should /// To perform full variable substitution with all substitution handlers in the scene, you should
* use the SubstituteVariables() method instead. /// use the SubstituteVariables() method instead.
*/ /// </summary>
[MoonSharp.Interpreter.MoonSharpHidden] [MoonSharp.Interpreter.MoonSharpHidden]
public virtual bool SubstituteStrings(StringBuilder input) public virtual bool SubstituteStrings(StringBuilder input)
{ {
@ -1052,12 +1046,12 @@ namespace Fungus
return modified; return modified;
} }
/** /// <summary>
* Substitute variables in the input text with the format {$VarName} /// Substitute variables in the input text with the format {$VarName}
* This will first match with private variables in this Flowchart, and then /// This will first match with private variables in this Flowchart, and then
* with public variables in all Flowcharts in the scene (and any component /// with public variables in all Flowcharts in the scene (and any component
* in the scene that implements StringSubstituter.ISubstitutionHandler). /// in the scene that implements StringSubstituter.ISubstitutionHandler).
*/ /// </summary>
public virtual string SubstituteVariables(string input) public virtual string SubstituteVariables(string input)
{ {
if (stringSubstituer == null) if (stringSubstituer == null)

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

@ -4,18 +4,17 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
// Used by the Flowchart window to serialize the currently active Flowchart object /// Used by the Flowchart window to serialize the currently active Flowchart object
// so that the same Flowchart can be displayed while editing & playing. /// so that the same Flowchart can be displayed while editing & playing.
/// </summary>
[AddComponentMenu("")] [AddComponentMenu("")]
public class FungusState : MonoBehaviour public class FungusState : MonoBehaviour
{ {
[SerializeField] protected Flowchart selectedFlowchart; [SerializeField] protected Flowchart selectedFlowchart;
public Flowchart SelectedFlowchart { get { return selectedFlowchart; } set { selectedFlowchart = value; } } public Flowchart SelectedFlowchart { get { return selectedFlowchart; } set { selectedFlowchart = value; } }
} }

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

@ -4,17 +4,16 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Base class for Flowchart nodes.
/// </summary>
[AddComponentMenu("")] [AddComponentMenu("")]
public class Node : MonoBehaviour public class Node : MonoBehaviour
{ {
[SerializeField] protected 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; } } public Rect _NodeRect { get { return nodeRect; } set { nodeRect = value; } }
} }
} }

23
Assets/Fungus/Flowchart/Scripts/SceneLoader.cs

@ -9,27 +9,26 @@
using UnityEngine.SceneManagement; using UnityEngine.SceneManagement;
#endif #endif
using System.Collections; using System.Collections;
using System;
namespace Fungus namespace Fungus
{ {
/** /// <summary>
* Helper component for loading a new scene. /// Helper component for loading a new scene.
* A fullscreen loading image is displayed while loading the new scene. /// A fullscreen loading image is displayed while loading the new scene.
* All Rooms are destroyed and unused assets are released from memory before loading the new scene to minimize memory footprint. /// All Rooms are destroyed and unused assets are released from memory before loading the new scene to minimize memory footprint.
* For streaming Web Player builds, the loading image will be displayed until the requested level has finished downloading. /// For streaming Web Player builds, the loading image will be displayed until the requested level has finished downloading.
*/ /// </summary>
public class SceneLoader : MonoBehaviour public class SceneLoader : MonoBehaviour
{ {
protected Texture2D loadingTexture; protected Texture2D loadingTexture;
protected string sceneToLoad; protected string sceneToLoad;
protected bool displayedImage; protected bool displayedImage;
/** /// <summary>
* Asynchronously load a new scene. /// Asynchronously load a new scene.
* @param _sceneToLoad The name of the scene to load. Scenes must be added in project build settings. /// </summary>
* @param _loadingTexture Loading image to display while loading the new scene. /// <param name="_sceneToLoad">The name of the scene to load. Scenes must be added in project build settings.</param>
*/ /// <param name="_loadingTexture">Loading image to display while loading the new scene.</param>
static public void LoadScene(string _sceneToLoad, Texture2D _loadingTexture) static public void LoadScene(string _sceneToLoad, Texture2D _loadingTexture)
{ {
// Unity does not provide a way to check if the named scene actually exists in the project. // Unity does not provide a way to check if the named scene actually exists in the project.

6
Assets/Fungus/Flowchart/Scripts/StringFormatter.cs

@ -3,14 +3,14 @@
* It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE) * It is released for free under the MIT open source license (https://github.com/snozbot/fungus/blob/master/LICENSE)
*/ */
using UnityEngine;
using System.IO;
using System.Collections;
using System.Text; using System.Text;
using System; using System;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Misc string formatting functions.
/// </summary>
public class StringFormatter public class StringFormatter
{ {
public static string[] FormatEnumNames(Enum e, string firstLabel) public static string[] FormatEnumNames(Enum e, string firstLabel)

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

@ -5,17 +5,21 @@
using UnityEngine; using UnityEngine;
using System; using System;
using System.Collections;
using System.Collections.Generic;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Scope types for Variables.
/// </summary>
public enum VariableScope public enum VariableScope
{ {
Private, Private,
Public Public
} }
/// <summary>
/// Attribute class for variables.
/// </summary>
public class VariableInfoAttribute : Attribute public class VariableInfoAttribute : Attribute
{ {
public VariableInfoAttribute(string category, string variableType, int order = 0) public VariableInfoAttribute(string category, string variableType, int order = 0)
@ -30,6 +34,9 @@ namespace Fungus
public int Order { get; set; } public int Order { get; set; }
} }
/// <summary>
/// Attribute class for variable properties.
/// </summary>
public class VariablePropertyAttribute : PropertyAttribute public class VariablePropertyAttribute : PropertyAttribute
{ {
public VariablePropertyAttribute (params System.Type[] variableTypes) public VariablePropertyAttribute (params System.Type[] variableTypes)
@ -48,24 +55,27 @@ namespace Fungus
public System.Type[] VariableTypes { get; set; } public System.Type[] VariableTypes { get; set; }
} }
/// <summary>
/// Abstract base class for variables.
/// </summary>
[RequireComponent(typeof(Flowchart))] [RequireComponent(typeof(Flowchart))]
public abstract class Variable : MonoBehaviour public abstract class Variable : MonoBehaviour
{ {
[SerializeField] protected VariableScope scope; [SerializeField] protected VariableScope scope;
public VariableScope Scope { get { return scope; } } public VariableScope Scope { get { return scope; } }
[SerializeField] protected string key = ""; [SerializeField] protected string key = "";
public string Key { get { return key; } set { key = value; } } public string Key { get { return key; } set { key = value; } }
public abstract void OnReset(); public abstract void OnReset();
} }
/// <summary>
/// Generic concrete base class for variables.
/// </summary>
public abstract class VariableBase<T> : Variable public abstract class VariableBase<T> : Variable
{ {
[SerializeField] protected T value; [SerializeField] protected T value;
public T Value { get { return this.value; } set { this.value = value; } } public T Value { get { return this.value; } set { this.value = value; } }
protected T startValue; protected T startValue;

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

@ -4,16 +4,21 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Animator variable type.
/// </summary>
[VariableInfo("Other", "Animator")] [VariableInfo("Other", "Animator")]
[AddComponentMenu("")] [AddComponentMenu("")]
[System.Serializable] [System.Serializable]
public class AnimatorVariable : VariableBase<Animator> public class AnimatorVariable : VariableBase<Animator>
{} {}
/// <summary>
/// Container for an Animator variable reference or constant value.
/// </summary>
[System.Serializable] [System.Serializable]
public struct AnimatorData public struct AnimatorData
{ {

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

@ -4,16 +4,21 @@
*/ */
using UnityEngine; using UnityEngine;
using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// AudioSource variable type.
/// </summary>
[VariableInfo("Other", "AudioSource")] [VariableInfo("Other", "AudioSource")]
[AddComponentMenu("")] [AddComponentMenu("")]
[System.Serializable] [System.Serializable]
public class AudioSourceVariable : VariableBase<AudioSource> public class AudioSourceVariable : VariableBase<AudioSource>
{} {}
/// <summary>
/// Container for an AudioSource variable reference or constant value.
/// </summary>
[System.Serializable] [System.Serializable]
public struct AudioSourceData public struct AudioSourceData
{ {

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

@ -9,7 +9,9 @@ using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Boolean variable type.
/// </summary>
[VariableInfo("", "Boolean")] [VariableInfo("", "Boolean")]
[AddComponentMenu("")] [AddComponentMenu("")]
[System.Serializable] [System.Serializable]
@ -38,6 +40,9 @@ namespace Fungus
} }
/// <summary>
/// Container for a Boolean variable reference or constant value.
/// </summary>
[System.Serializable] [System.Serializable]
public struct BooleanData public struct BooleanData
{ {

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

@ -8,12 +8,18 @@ using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Color variable type.
/// </summary>
[VariableInfo("Other", "Color")] [VariableInfo("Other", "Color")]
[AddComponentMenu("")] [AddComponentMenu("")]
[System.Serializable] [System.Serializable]
public class ColorVariable : VariableBase<Color> public class ColorVariable : VariableBase<Color>
{} {}
/// <summary>
/// Container for a Color variable reference or constant value.
/// </summary>
[System.Serializable] [System.Serializable]
public struct ColorData public struct ColorData
{ {

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

@ -8,6 +8,9 @@ using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Float variable type.
/// </summary>
[VariableInfo("", "Float")] [VariableInfo("", "Float")]
[AddComponentMenu("")] [AddComponentMenu("")]
[System.Serializable] [System.Serializable]
@ -46,6 +49,9 @@ namespace Fungus
} }
} }
/// <summary>
/// Container for an float variable reference or constant value.
/// </summary>
[System.Serializable] [System.Serializable]
public struct FloatData public struct FloatData
{ {

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

@ -8,12 +8,18 @@ using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// GameObject variable type.
/// </summary>
[VariableInfo("Other", "GameObject")] [VariableInfo("Other", "GameObject")]
[AddComponentMenu("")] [AddComponentMenu("")]
[System.Serializable] [System.Serializable]
public class GameObjectVariable : VariableBase<GameObject> public class GameObjectVariable : VariableBase<GameObject>
{} {}
/// <summary>
/// Container for a GameObject variable reference or constant value.
/// </summary>
[System.Serializable] [System.Serializable]
public struct GameObjectData public struct GameObjectData
{ {

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

@ -8,6 +8,9 @@ using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Integer variable type.
/// </summary>
[VariableInfo("", "Integer")] [VariableInfo("", "Integer")]
[AddComponentMenu("")] [AddComponentMenu("")]
[System.Serializable] [System.Serializable]
@ -46,6 +49,9 @@ namespace Fungus
} }
} }
/// <summary>
/// Container for an integer variable reference or constant value.
/// </summary>
[System.Serializable] [System.Serializable]
public struct IntegerData public struct IntegerData
{ {

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

@ -8,12 +8,18 @@ using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Material variable type.
/// </summary>
[VariableInfo("Other", "Material")] [VariableInfo("Other", "Material")]
[AddComponentMenu("")] [AddComponentMenu("")]
[System.Serializable] [System.Serializable]
public class MaterialVariable : VariableBase<Material> public class MaterialVariable : VariableBase<Material>
{} {}
/// <summary>
/// Container for a Material variable reference or constant value.
/// </summary>
[System.Serializable] [System.Serializable]
public struct MaterialData public struct MaterialData
{ {

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

@ -8,12 +8,18 @@ using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Object variable type.
/// </summary>
[VariableInfo("Other", "Object")] [VariableInfo("Other", "Object")]
[AddComponentMenu("")] [AddComponentMenu("")]
[System.Serializable] [System.Serializable]
public class ObjectVariable : VariableBase<Object> public class ObjectVariable : VariableBase<Object>
{} {}
/// <summary>
/// Container for an Object variable reference or constant value.
/// </summary>
[System.Serializable] [System.Serializable]
public struct ObjectData public struct ObjectData
{ {

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

@ -8,12 +8,18 @@ using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Sprite variable type.
/// </summary>
[VariableInfo("Other", "Sprite")] [VariableInfo("Other", "Sprite")]
[AddComponentMenu("")] [AddComponentMenu("")]
[System.Serializable] [System.Serializable]
public class SpriteVariable : VariableBase<Sprite> public class SpriteVariable : VariableBase<Sprite>
{} {}
/// <summary>
/// Container for a Sprite variable reference or constant value.
/// </summary>
[System.Serializable] [System.Serializable]
public struct SpriteData public struct SpriteData
{ {

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

@ -8,7 +8,9 @@ using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// String variable type.
/// </summary>
[VariableInfo("", "String")] [VariableInfo("", "String")]
[AddComponentMenu("")] [AddComponentMenu("")]
[System.Serializable] [System.Serializable]
@ -37,7 +39,7 @@ namespace Fungus
} }
/// <summary> /// <summary>
/// Can contain a reference to a StringVariable or a string constant. /// Container for a string variable reference or constant value.
/// Appears as a single line property in the inspector. /// Appears as a single line property in the inspector.
/// For a multi-line property, use StringDataMulti. /// For a multi-line property, use StringDataMulti.
/// </summary> /// </summary>
@ -86,7 +88,7 @@ namespace Fungus
} }
/// <summary> /// <summary>
/// Can contain a reference to a StringVariable or a string constant. /// Container for a string variable reference or constant value.
/// Appears as a multi-line property in the inspector. /// Appears as a multi-line property in the inspector.
/// For a single-line property, use StringData. /// For a single-line property, use StringData.
/// </summary> /// </summary>

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

@ -8,12 +8,18 @@ using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Texture variable type.
/// </summary>
[VariableInfo("Other", "Texture")] [VariableInfo("Other", "Texture")]
[AddComponentMenu("")] [AddComponentMenu("")]
[System.Serializable] [System.Serializable]
public class TextureVariable : VariableBase<Texture> public class TextureVariable : VariableBase<Texture>
{} {}
/// <summary>
/// Container for a Texture variable reference or constant value.
/// </summary>
[System.Serializable] [System.Serializable]
public struct TextureData public struct TextureData
{ {

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

@ -8,12 +8,18 @@ using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Transform variable type.
/// </summary>
[VariableInfo("Other", "Transform")] [VariableInfo("Other", "Transform")]
[AddComponentMenu("")] [AddComponentMenu("")]
[System.Serializable] [System.Serializable]
public class TransformVariable : VariableBase<Transform> public class TransformVariable : VariableBase<Transform>
{} {}
/// <summary>
/// Container for a Transform variable reference or constant value.
/// </summary>
[System.Serializable] [System.Serializable]
public struct TransformData public struct TransformData
{ {

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

@ -8,12 +8,18 @@ using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Vector2 variable type.
/// </summary>
[VariableInfo("Other", "Vector2")] [VariableInfo("Other", "Vector2")]
[AddComponentMenu("")] [AddComponentMenu("")]
[System.Serializable] [System.Serializable]
public class Vector2Variable : VariableBase<Vector2> public class Vector2Variable : VariableBase<Vector2>
{} {}
/// <summary>
/// Container for a Vector2 variable reference or constant value.
/// </summary>
[System.Serializable] [System.Serializable]
public struct Vector2Data public struct Vector2Data
{ {

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

@ -8,12 +8,18 @@ using System.Collections;
namespace Fungus namespace Fungus
{ {
/// <summary>
/// Vector3 variable type.
/// </summary>
[VariableInfo("Other", "Vector3")] [VariableInfo("Other", "Vector3")]
[AddComponentMenu("")] [AddComponentMenu("")]
[System.Serializable] [System.Serializable]
public class Vector3Variable : VariableBase<Vector3> public class Vector3Variable : VariableBase<Vector3>
{} {}
/// <summary>
/// Container for a Vector3 variable reference or constant value.
/// </summary>
[System.Serializable] [System.Serializable]
public struct Vector3Data public struct Vector3Data
{ {

Loading…
Cancel
Save