Browse Source

Added Reset command to reset variables and command state

master
chrisgregan 10 years ago
parent
commit
7693241f48
  1. 73
      Assets/Examples/TheFacility/TheFacility.unity
  2. 5
      Assets/Fungus/Dialog/Commands/AddOption.cs
  3. 5
      Assets/Fungus/Dialog/Commands/Say.cs
  4. 24
      Assets/Fungus/FungusScript/Commands/Reset.cs
  5. 8
      Assets/Fungus/FungusScript/Commands/Reset.cs.meta
  6. 5
      Assets/Fungus/FungusScript/Scripts/BooleanVariable.cs
  7. 3
      Assets/Fungus/FungusScript/Scripts/Command.cs
  8. 5
      Assets/Fungus/FungusScript/Scripts/FloatVariable.cs
  9. 14
      Assets/Fungus/FungusScript/Scripts/FungusScript.cs
  10. 5
      Assets/Fungus/FungusScript/Scripts/IntegerVariable.cs
  11. 5
      Assets/Fungus/FungusScript/Scripts/StringVariable.cs
  12. 3
      Assets/Fungus/FungusScript/Scripts/Variable.cs

73
Assets/Examples/TheFacility/TheFacility.unity

@ -1348,6 +1348,7 @@ GameObject:
- 114: {fileID: 570845517} - 114: {fileID: 570845517}
- 114: {fileID: 570845527} - 114: {fileID: 570845527}
- 114: {fileID: 570845533} - 114: {fileID: 570845533}
- 114: {fileID: 570845522}
m_Layer: 0 m_Layer: 0
m_Name: StandingThere m_Name: StandingThere
m_TagString: Untagged m_TagString: Untagged
@ -1371,9 +1372,10 @@ MonoBehaviour:
x: 804.489258 x: 804.489258
y: -118.825607 y: -118.825607
width: 240 width: 240
height: 334 height: 354
sequenceName: StandingThere sequenceName: StandingThere
commandList: commandList:
- {fileID: 570845522}
- {fileID: 570845520} - {fileID: 570845520}
- {fileID: 570845519} - {fileID: 570845519}
- {fileID: 570845518} - {fileID: 570845518}
@ -1553,6 +1555,26 @@ MonoBehaviour:
optionText: Inspect the desk optionText: Inspect the desk
targetSequence: {fileID: 1680954148} targetSequence: {fileID: 1680954148}
hideOnSelected: 0 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 --- !u!114 &570845526
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 2 m_ObjectHideFlags: 2
@ -2474,7 +2496,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7a334fe2ffb574b3583ff3b18b4792d3, type: 3} m_Script: {fileID: 11500000, guid: 7a334fe2ffb574b3583ff3b18b4792d3, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
scrollPos: {x: -115.191772, y: 152.935455} scrollPos: {x: -189.191772, y: 103.935455}
zoom: 1 zoom: 1
scrollViewRect: scrollViewRect:
serializedVersion: 2 serializedVersion: 2
@ -2482,13 +2504,13 @@ MonoBehaviour:
y: -610.734985 y: -610.734985
width: 3261.20312 width: 3261.20312
height: 2227.35059 height: 2227.35059
selectedSequence: {fileID: 948050620} selectedSequence: {fileID: 570845514}
selectedCommands: selectedCommands:
- {fileID: 948050617} - {fileID: 570845522}
variables: variables:
- {fileID: 771014102} - {fileID: 771014102}
- {fileID: 771014103} - {fileID: 771014103}
startSequence: {fileID: 904348472} startSequence: {fileID: 1797174374}
executeOnStart: 1 executeOnStart: 1
settings: settings:
runSlowInEditor: 1 runSlowInEditor: 1
@ -5142,7 +5164,6 @@ GameObject:
- 114: {fileID: 1797174384} - 114: {fileID: 1797174384}
- 114: {fileID: 1797174382} - 114: {fileID: 1797174382}
- 114: {fileID: 1797174376} - 114: {fileID: 1797174376}
- 114: {fileID: 1797174380}
m_Layer: 0 m_Layer: 0
m_Name: Start m_Name: Start
m_TagString: Untagged m_TagString: Untagged
@ -5184,7 +5205,7 @@ MonoBehaviour:
x: 501.703979 x: 501.703979
y: -117.210686 y: -117.210686
width: 240 width: 240
height: 234 height: 214
sequenceName: Start sequenceName: Start
commandList: commandList:
- {fileID: 1797174373} - {fileID: 1797174373}
@ -5195,7 +5216,6 @@ MonoBehaviour:
- {fileID: 1797174384} - {fileID: 1797174384}
- {fileID: 1797174383} - {fileID: 1797174383}
- {fileID: 1797174382} - {fileID: 1797174382}
- {fileID: 1797174380}
- {fileID: 1797174376} - {fileID: 1797174376}
--- !u!4 &1797174375 --- !u!4 &1797174375
Transform: Transform:
@ -5305,26 +5325,6 @@ MonoBehaviour:
optionText: Shout optionText: Shout
targetSequence: {fileID: 0} targetSequence: {fileID: 0}
hideOnSelected: 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 --- !u!114 &1797174381
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 2 m_ObjectHideFlags: 2
@ -5830,6 +5830,7 @@ GameObject:
- 114: {fileID: 1925614670} - 114: {fileID: 1925614670}
- 114: {fileID: 1925614673} - 114: {fileID: 1925614673}
- 114: {fileID: 1925614674} - 114: {fileID: 1925614674}
- 114: {fileID: 1925614672}
m_Layer: 0 m_Layer: 0
m_Name: FREEDOM! m_Name: FREEDOM!
m_TagString: Untagged m_TagString: Untagged
@ -5853,10 +5854,11 @@ MonoBehaviour:
x: 234.655121 x: 234.655121
y: 207.536453 y: 207.536453
width: 240 width: 240
height: 74 height: 94
sequenceName: FREEDOM! sequenceName: FREEDOM!
commandList: commandList:
- {fileID: 1925614673} - {fileID: 1925614673}
- {fileID: 1925614672}
- {fileID: 1925614674} - {fileID: 1925614674}
--- !u!4 &1925614671 --- !u!4 &1925614671
Transform: Transform:
@ -5870,6 +5872,19 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 771014101} m_Father: {fileID: 771014101}
m_RootOrder: 25 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 --- !u!114 &1925614673
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 2 m_ObjectHideFlags: 2

5
Assets/Fungus/Dialog/Commands/AddOption.cs

@ -66,6 +66,11 @@ namespace Fungus
{ {
return new Color32(184, 210, 235, 255); return new Color32(184, 210, 235, 255);
} }
public override void OnReset()
{
wasSelected = false;
}
} }
} }

5
Assets/Fungus/Dialog/Commands/Say.cs

@ -124,6 +124,11 @@ namespace Fungus
} }
} }
} }
public override void OnReset()
{
executionCount = 0;
}
} }
} }

24
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);
}
}
}

8
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:

5
Assets/Fungus/FungusScript/Scripts/BooleanVariable.cs

@ -14,6 +14,11 @@ namespace Fungus
get { return (scope == VariableScope.Local) ? booleanVal : GlobalVariables.GetBoolean(key); } get { return (scope == VariableScope.Local) ? booleanVal : GlobalVariables.GetBoolean(key); }
set { if (scope == VariableScope.Local) { booleanVal = value; } else { GlobalVariables.SetBoolean(key, value); } } set { if (scope == VariableScope.Local) { booleanVal = value; } else { GlobalVariables.SetBoolean(key, value); } }
} }
public override void OnReset()
{
Value = false;
}
} }
[System.Serializable] [System.Serializable]

3
Assets/Fungus/FungusScript/Scripts/Command.cs

@ -112,6 +112,9 @@ namespace Fungus
public virtual void OnExit() public virtual void OnExit()
{} {}
public virtual void OnReset()
{}
public virtual void GetConnectedSequences(ref List<Sequence> connectedSequences) public virtual void GetConnectedSequences(ref List<Sequence> connectedSequences)
{} {}

5
Assets/Fungus/FungusScript/Scripts/FloatVariable.cs

@ -13,6 +13,11 @@ namespace Fungus
get { return (scope == VariableScope.Local) ? floatVal : GlobalVariables.GetFloat(key); } get { return (scope == VariableScope.Local) ? floatVal : GlobalVariables.GetFloat(key); }
set { if (scope == VariableScope.Local) { floatVal = value; } else { GlobalVariables.SetFloat(key, value); } } set { if (scope == VariableScope.Local) { floatVal = value; } else { GlobalVariables.SetFloat(key, value); } }
} }
public override void OnReset()
{
Value = 0;
}
} }
[System.Serializable] [System.Serializable]

14
Assets/Fungus/FungusScript/Scripts/FungusScript.cs

@ -408,6 +408,20 @@ namespace Fungus
selectedCommands.Add(command); selectedCommands.Add(command);
} }
} }
public virtual void Reset()
{
Command[] commands = GetComponentsInChildren<Command>();
foreach (Command command in commands)
{
command.OnReset();
}
foreach (Variable variable in variables)
{
variable.OnReset();
}
}
} }
} }

5
Assets/Fungus/FungusScript/Scripts/IntegerVariable.cs

@ -13,6 +13,11 @@ namespace Fungus
get { return (scope == VariableScope.Local) ? integerVal : GlobalVariables.GetInteger(key); } get { return (scope == VariableScope.Local) ? integerVal : GlobalVariables.GetInteger(key); }
set { if (scope == VariableScope.Local) { integerVal = value; } else { GlobalVariables.SetInteger(key, value); } } set { if (scope == VariableScope.Local) { integerVal = value; } else { GlobalVariables.SetInteger(key, value); } }
} }
public override void OnReset()
{
Value = 0;
}
} }
[System.Serializable] [System.Serializable]

5
Assets/Fungus/FungusScript/Scripts/StringVariable.cs

@ -13,6 +13,11 @@ namespace Fungus
get { return (scope == VariableScope.Local) ? stringVal : GlobalVariables.GetString(key); } get { return (scope == VariableScope.Local) ? stringVal : GlobalVariables.GetString(key); }
set { if (scope == VariableScope.Local) { stringVal = value; } else { GlobalVariables.SetString(key, value); } } set { if (scope == VariableScope.Local) { stringVal = value; } else { GlobalVariables.SetString(key, value); } }
} }
public override void OnReset()
{
Value = "";
}
} }
[System.Serializable] [System.Serializable]

3
Assets/Fungus/FungusScript/Scripts/Variable.cs

@ -23,5 +23,8 @@ namespace Fungus
{ {
public VariableScope scope; public VariableScope scope;
public string key = ""; public string key = "";
public virtual void OnReset()
{}
} }
} }

Loading…
Cancel
Save