diff --git a/Assets/Examples/TheFacility/TheFacility.unity b/Assets/Examples/TheFacility/TheFacility.unity index 5269f246..86b4ec0a 100644 --- a/Assets/Examples/TheFacility/TheFacility.unity +++ b/Assets/Examples/TheFacility/TheFacility.unity @@ -1348,6 +1348,7 @@ GameObject: - 114: {fileID: 570845517} - 114: {fileID: 570845527} - 114: {fileID: 570845533} + - 114: {fileID: 570845522} m_Layer: 0 m_Name: StandingThere m_TagString: Untagged @@ -1371,9 +1372,10 @@ MonoBehaviour: x: 804.489258 y: -118.825607 width: 240 - height: 334 + height: 354 sequenceName: StandingThere commandList: + - {fileID: 570845522} - {fileID: 570845520} - {fileID: 570845519} - {fileID: 570845518} @@ -1553,6 +1555,26 @@ MonoBehaviour: optionText: Inspect the desk targetSequence: {fileID: 1680954148} hideOnSelected: 0 +--- !u!114 &570845522 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 570845513} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ec422cd568a9c4a31ad7c36d0572b9da, type: 3} + m_Name: + m_EditorClassIdentifier: + errorMessage: + indentLevel: 0 + storyText: You sit up gingerly and swing your legs off the bed. The jumpsuit includes + neat little slippers, and you don't feel any aches or pains. If anything, you're + incredibly well-rested.{wc} You stretch out your arms and stand up. + character: {fileID: 0} + sayDialog: {fileID: 0} + voiceOverClip: {fileID: 0} + showOnce: 0 --- !u!114 &570845526 MonoBehaviour: m_ObjectHideFlags: 2 @@ -2474,7 +2496,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 7a334fe2ffb574b3583ff3b18b4792d3, type: 3} m_Name: m_EditorClassIdentifier: - scrollPos: {x: -115.191772, y: 152.935455} + scrollPos: {x: -189.191772, y: 103.935455} zoom: 1 scrollViewRect: serializedVersion: 2 @@ -2482,13 +2504,13 @@ MonoBehaviour: y: -610.734985 width: 3261.20312 height: 2227.35059 - selectedSequence: {fileID: 948050620} + selectedSequence: {fileID: 570845514} selectedCommands: - - {fileID: 948050617} + - {fileID: 570845522} variables: - {fileID: 771014102} - {fileID: 771014103} - startSequence: {fileID: 904348472} + startSequence: {fileID: 1797174374} executeOnStart: 1 settings: runSlowInEditor: 1 @@ -5142,7 +5164,6 @@ GameObject: - 114: {fileID: 1797174384} - 114: {fileID: 1797174382} - 114: {fileID: 1797174376} - - 114: {fileID: 1797174380} m_Layer: 0 m_Name: Start m_TagString: Untagged @@ -5184,7 +5205,7 @@ MonoBehaviour: x: 501.703979 y: -117.210686 width: 240 - height: 234 + height: 214 sequenceName: Start commandList: - {fileID: 1797174373} @@ -5195,7 +5216,6 @@ MonoBehaviour: - {fileID: 1797174384} - {fileID: 1797174383} - {fileID: 1797174382} - - {fileID: 1797174380} - {fileID: 1797174376} --- !u!4 &1797174375 Transform: @@ -5305,26 +5325,6 @@ MonoBehaviour: optionText: Shout targetSequence: {fileID: 0} hideOnSelected: 0 ---- !u!114 &1797174380 -MonoBehaviour: - m_ObjectHideFlags: 2 - m_PrefabParentObject: {fileID: 0} - m_PrefabInternal: {fileID: 0} - m_GameObject: {fileID: 1797174372} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: ec422cd568a9c4a31ad7c36d0572b9da, type: 3} - m_Name: - m_EditorClassIdentifier: - errorMessage: - indentLevel: 0 - storyText: You sit up gingerly and swing your legs off the bed. The jumpsuit includes - neat little slippers, and you don't feel any aches or pains. If anything, you're - incredibly well-rested.{wc} You stretch out your arms and stand up. - character: {fileID: 0} - sayDialog: {fileID: 0} - voiceOverClip: {fileID: 0} - showOnce: 0 --- !u!114 &1797174381 MonoBehaviour: m_ObjectHideFlags: 2 @@ -5830,6 +5830,7 @@ GameObject: - 114: {fileID: 1925614670} - 114: {fileID: 1925614673} - 114: {fileID: 1925614674} + - 114: {fileID: 1925614672} m_Layer: 0 m_Name: FREEDOM! m_TagString: Untagged @@ -5853,10 +5854,11 @@ MonoBehaviour: x: 234.655121 y: 207.536453 width: 240 - height: 74 + height: 94 sequenceName: FREEDOM! commandList: - {fileID: 1925614673} + - {fileID: 1925614672} - {fileID: 1925614674} --- !u!4 &1925614671 Transform: @@ -5870,6 +5872,19 @@ Transform: m_Children: [] m_Father: {fileID: 771014101} m_RootOrder: 25 +--- !u!114 &1925614672 +MonoBehaviour: + m_ObjectHideFlags: 2 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1925614669} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0000066e72e484959b6a314a95d0dcd2, type: 3} + m_Name: + m_EditorClassIdentifier: + errorMessage: + indentLevel: 0 --- !u!114 &1925614673 MonoBehaviour: m_ObjectHideFlags: 2 diff --git a/Assets/Fungus/Dialog/Commands/AddOption.cs b/Assets/Fungus/Dialog/Commands/AddOption.cs index 1871aed0..c4ee0b46 100644 --- a/Assets/Fungus/Dialog/Commands/AddOption.cs +++ b/Assets/Fungus/Dialog/Commands/AddOption.cs @@ -66,6 +66,11 @@ namespace Fungus { return new Color32(184, 210, 235, 255); } + + public override void OnReset() + { + wasSelected = false; + } } } \ No newline at end of file diff --git a/Assets/Fungus/Dialog/Commands/Say.cs b/Assets/Fungus/Dialog/Commands/Say.cs index 1b03f45e..7888fd7a 100644 --- a/Assets/Fungus/Dialog/Commands/Say.cs +++ b/Assets/Fungus/Dialog/Commands/Say.cs @@ -124,6 +124,11 @@ namespace Fungus } } } + + public override void OnReset() + { + executionCount = 0; + } } } \ No newline at end of file diff --git a/Assets/Fungus/FungusScript/Commands/Reset.cs b/Assets/Fungus/FungusScript/Commands/Reset.cs new file mode 100644 index 00000000..fd5c7441 --- /dev/null +++ b/Assets/Fungus/FungusScript/Commands/Reset.cs @@ -0,0 +1,24 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; + +namespace Fungus +{ + [CommandInfo("Scripting", + "Reset", + "Resets state of all commands and variables in this Fungus Script.")] + public class Reset : Command + { + public override void OnEnter() + { + GetFungusScript().Reset(); + Continue(); + } + + public override Color GetButtonColor() + { + return new Color32(235, 191, 217, 255); + } + } + +} \ No newline at end of file diff --git a/Assets/Fungus/FungusScript/Commands/Reset.cs.meta b/Assets/Fungus/FungusScript/Commands/Reset.cs.meta new file mode 100644 index 00000000..f588609a --- /dev/null +++ b/Assets/Fungus/FungusScript/Commands/Reset.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0000066e72e484959b6a314a95d0dcd2 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Assets/Fungus/FungusScript/Scripts/BooleanVariable.cs b/Assets/Fungus/FungusScript/Scripts/BooleanVariable.cs index 8515cb1c..731a9aa4 100644 --- a/Assets/Fungus/FungusScript/Scripts/BooleanVariable.cs +++ b/Assets/Fungus/FungusScript/Scripts/BooleanVariable.cs @@ -14,6 +14,11 @@ namespace Fungus get { return (scope == VariableScope.Local) ? booleanVal : GlobalVariables.GetBoolean(key); } set { if (scope == VariableScope.Local) { booleanVal = value; } else { GlobalVariables.SetBoolean(key, value); } } } + + public override void OnReset() + { + Value = false; + } } [System.Serializable] diff --git a/Assets/Fungus/FungusScript/Scripts/Command.cs b/Assets/Fungus/FungusScript/Scripts/Command.cs index d2e4a01a..117b7e3f 100644 --- a/Assets/Fungus/FungusScript/Scripts/Command.cs +++ b/Assets/Fungus/FungusScript/Scripts/Command.cs @@ -112,6 +112,9 @@ namespace Fungus public virtual void OnExit() {} + public virtual void OnReset() + {} + public virtual void GetConnectedSequences(ref List connectedSequences) {} diff --git a/Assets/Fungus/FungusScript/Scripts/FloatVariable.cs b/Assets/Fungus/FungusScript/Scripts/FloatVariable.cs index 844fd59b..95070811 100644 --- a/Assets/Fungus/FungusScript/Scripts/FloatVariable.cs +++ b/Assets/Fungus/FungusScript/Scripts/FloatVariable.cs @@ -13,6 +13,11 @@ namespace Fungus get { return (scope == VariableScope.Local) ? floatVal : GlobalVariables.GetFloat(key); } set { if (scope == VariableScope.Local) { floatVal = value; } else { GlobalVariables.SetFloat(key, value); } } } + + public override void OnReset() + { + Value = 0; + } } [System.Serializable] diff --git a/Assets/Fungus/FungusScript/Scripts/FungusScript.cs b/Assets/Fungus/FungusScript/Scripts/FungusScript.cs index 786832bd..16d88595 100644 --- a/Assets/Fungus/FungusScript/Scripts/FungusScript.cs +++ b/Assets/Fungus/FungusScript/Scripts/FungusScript.cs @@ -408,6 +408,20 @@ namespace Fungus selectedCommands.Add(command); } } + + public virtual void Reset() + { + Command[] commands = GetComponentsInChildren(); + foreach (Command command in commands) + { + command.OnReset(); + } + + foreach (Variable variable in variables) + { + variable.OnReset(); + } + } } } \ No newline at end of file diff --git a/Assets/Fungus/FungusScript/Scripts/IntegerVariable.cs b/Assets/Fungus/FungusScript/Scripts/IntegerVariable.cs index f0849913..019962f6 100644 --- a/Assets/Fungus/FungusScript/Scripts/IntegerVariable.cs +++ b/Assets/Fungus/FungusScript/Scripts/IntegerVariable.cs @@ -13,6 +13,11 @@ namespace Fungus get { return (scope == VariableScope.Local) ? integerVal : GlobalVariables.GetInteger(key); } set { if (scope == VariableScope.Local) { integerVal = value; } else { GlobalVariables.SetInteger(key, value); } } } + + public override void OnReset() + { + Value = 0; + } } [System.Serializable] diff --git a/Assets/Fungus/FungusScript/Scripts/StringVariable.cs b/Assets/Fungus/FungusScript/Scripts/StringVariable.cs index 1265db31..5a5d34c0 100644 --- a/Assets/Fungus/FungusScript/Scripts/StringVariable.cs +++ b/Assets/Fungus/FungusScript/Scripts/StringVariable.cs @@ -13,6 +13,11 @@ namespace Fungus get { return (scope == VariableScope.Local) ? stringVal : GlobalVariables.GetString(key); } set { if (scope == VariableScope.Local) { stringVal = value; } else { GlobalVariables.SetString(key, value); } } } + + public override void OnReset() + { + Value = ""; + } } [System.Serializable] diff --git a/Assets/Fungus/FungusScript/Scripts/Variable.cs b/Assets/Fungus/FungusScript/Scripts/Variable.cs index 38e906cd..1ff50cfb 100644 --- a/Assets/Fungus/FungusScript/Scripts/Variable.cs +++ b/Assets/Fungus/FungusScript/Scripts/Variable.cs @@ -23,5 +23,8 @@ namespace Fungus { public VariableScope scope; public string key = ""; + + public virtual void OnReset() + {} } }