Browse Source

Merge pull request #449 from snozbot/stop-block

Added StopBlock command
master
Chris Gregan 9 years ago
parent
commit
602450efe4
  1. 53
      Assets/Fungus/Flowchart/Scripts/Commands/StopBlock.cs
  2. 12
      Assets/Fungus/Flowchart/Scripts/Commands/StopBlock.cs.meta
  3. 419
      Assets/Tests/Scripting/Scripting.unity

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

@ -0,0 +1,53 @@
using UnityEngine;
using System.Collections;
namespace Fungus
{
[CommandInfo("Flow",
"Stop Block",
"Stops executing the named Block")]
public class StopBlock : Command
{
[Tooltip("Flowchart containing the Block. If none is specified, the parent Flowchart is used.")]
public Flowchart flowchart;
[Tooltip("Name of the Block to stop")]
public StringData blockName = new StringData("");
public override void OnEnter()
{
if (blockName.Value == "")
{
Continue();
}
if (flowchart == null)
{
flowchart = GetFlowchart();
}
Block block = flowchart.FindBlock(blockName.Value);
if (block == null ||
!block.IsExecuting())
{
Continue();
}
block.Stop();
Continue();
}
public override string GetSummary()
{
return blockName;
}
public override Color GetButtonColor()
{
return new Color32(253, 253, 150, 255);
}
}
}

12
Assets/Fungus/Flowchart/Scripts/Commands/StopBlock.cs.meta

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 0d52ce2dfbc0b4dc4aa04334fc76695e
timeCreated: 1460500129
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

419
Assets/Tests/Scripting/Scripting.unity

@ -217,6 +217,7 @@ MonoBehaviour:
hideComponents: 1 hideComponents: 1
saveSelection: 1 saveSelection: 1
localizationId: localizationId:
showLineNumbers: 0
hideCommands: [] hideCommands: []
--- !u!1 &169310208 --- !u!1 &169310208
GameObject: GameObject:
@ -353,6 +354,365 @@ MonoBehaviour:
hideComponents: 1 hideComponents: 1
saveSelection: 1 saveSelection: 1
localizationId: localizationId:
showLineNumbers: 0
hideCommands: []
--- !u!1 &265055365
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 142980, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, type: 2}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 265055366}
- 114: {fileID: 265055382}
- 114: {fileID: 265055381}
- 114: {fileID: 265055380}
- 114: {fileID: 265055379}
- 114: {fileID: 265055378}
- 114: {fileID: 265055377}
- 114: {fileID: 265055376}
- 114: {fileID: 265055375}
- 114: {fileID: 265055374}
- 114: {fileID: 265055373}
- 114: {fileID: 265055372}
- 114: {fileID: 265055371}
- 114: {fileID: 265055370}
- 114: {fileID: 265055369}
- 114: {fileID: 265055368}
- 114: {fileID: 265055367}
m_Layer: 0
m_Name: Flowchart
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &265055366
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 467082, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a, type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 265055365}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1595430751}
m_RootOrder: 0
--- !u!114 &265055367
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 265055365}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2dcb71131f45b47fead560a97ef55f1c, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 12
errorMessage:
indentLevel: 1
failMessage:
--- !u!114 &265055368
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 265055365}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 93cb9773f2ca04e2bbf7a68ccfc23267, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 11
errorMessage:
indentLevel: 0
--- !u!114 &265055369
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 265055365}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3fa968f01a7f9496bb50e13dfe16760d, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 9
errorMessage:
indentLevel: 0
--- !u!114 &265055370
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 265055365}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4920f47cde1a84b11ad07b7317568494, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 8
errorMessage:
indentLevel: 1
--- !u!114 &265055371
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 265055365}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 70c5622b8a80845c980954170295f292, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 7
errorMessage:
indentLevel: 0
compareOperator: 0
variable: {fileID: 265055376}
booleanData:
booleanRef: {fileID: 0}
booleanVal: 1
integerData:
integerRef: {fileID: 0}
integerVal: 0
floatData:
floatRef: {fileID: 0}
floatVal: 0
stringData:
stringRef: {fileID: 0}
stringVal:
--- !u!114 &265055372
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 265055365}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3315ad2ebb85443909a1203d56d9344e, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 6
errorMessage:
indentLevel: 0
_duration:
floatRef: {fileID: 0}
floatVal: 1
durationOLD: 0
--- !u!114 &265055373
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 265055365}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0d52ce2dfbc0b4dc4aa04334fc76695e, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 5
errorMessage:
indentLevel: 0
flowchart: {fileID: 0}
blockName:
stringRef: {fileID: 0}
stringVal: BlockA
--- !u!114 &265055374
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 265055365}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3315ad2ebb85443909a1203d56d9344e, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 4
errorMessage:
indentLevel: 0
_duration:
floatRef: {fileID: 0}
floatVal: 0.5
durationOLD: 0
--- !u!114 &265055375
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 265055365}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fb77d0ce495044f6e9feb91b31798e8c, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 3
errorMessage:
indentLevel: 0
variable: {fileID: 265055376}
setOperator: 0
booleanData:
booleanRef: {fileID: 0}
booleanVal: 1
integerData:
integerRef: {fileID: 0}
integerVal: 0
floatData:
floatRef: {fileID: 0}
floatVal: 0
stringData:
stringRef: {fileID: 0}
stringVal:
--- !u!114 &265055376
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 265055365}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5d02d9822eec54c98afe95bb497211b3, type: 3}
m_Name:
m_EditorClassIdentifier:
scope: 0
key: BlockACompleted
value: 0
--- !u!114 &265055377
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 265055365}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3315ad2ebb85443909a1203d56d9344e, type: 3}
m_Name:
m_EditorClassIdentifier:
itemId: 2
errorMessage:
indentLevel: 0
_duration:
floatRef: {fileID: 0}
floatVal: 1
durationOLD: 0
--- !u!114 &265055378
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 265055365}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d2f6487d21a03404cb21b245f0242e79, type: 3}
m_Name:
m_EditorClassIdentifier:
parentBlock: {fileID: 265055379}
--- !u!114 &265055379
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 265055365}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3d3d73aef2cfc4f51abf34ac00241f60, type: 3}
m_Name:
m_EditorClassIdentifier:
nodeRect:
serializedVersion: 2
x: 222
y: 70
width: 120
height: 40
itemId: 1
blockName: BlockB
description: The block that does the stopping
eventHandler: {fileID: 265055378}
commandList:
- {fileID: 265055374}
- {fileID: 265055373}
- {fileID: 265055372}
- {fileID: 265055371}
- {fileID: 265055367}
- {fileID: 265055369}
- {fileID: 265055370}
- {fileID: 265055368}
--- !u!114 &265055380
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 11462346, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 265055365}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d2f6487d21a03404cb21b245f0242e79, type: 3}
m_Name:
m_EditorClassIdentifier:
parentBlock: {fileID: 265055381}
--- !u!114 &265055381
MonoBehaviour:
m_ObjectHideFlags: 2
m_PrefabParentObject: {fileID: 11433304, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 265055365}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 3d3d73aef2cfc4f51abf34ac00241f60, type: 3}
m_Name:
m_EditorClassIdentifier:
nodeRect:
serializedVersion: 2
x: 66
y: 70
width: 120
height: 40
itemId: 0
blockName: BlockA
description: The block to be stopped
eventHandler: {fileID: 265055380}
commandList:
- {fileID: 265055377}
- {fileID: 265055375}
--- !u!114 &265055382
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 11430050, guid: 5e7fbc8d4eb714b279eeeef2262c1e1a,
type: 2}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 265055365}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7a334fe2ffb574b3583ff3b18b4792d3, type: 3}
m_Name:
m_EditorClassIdentifier:
version: 1
scrollPos: {x: 0, y: 0}
variablesScrollPos: {x: 0, y: 0}
variablesExpanded: 1
blockViewHeight: 400
zoom: 1
scrollViewRect:
serializedVersion: 2
x: -350
y: -350
width: 1121
height: 869
selectedBlock: {fileID: 265055379}
selectedCommands: []
variables:
- {fileID: 265055376}
description: Test stopping an executing Block using the StopBlock command.
stepPause: 0
colorCommands: 1
hideComponents: 1
saveSelection: 1
localizationId:
showLineNumbers: 0
hideCommands: [] hideCommands: []
--- !u!1 &338809961 --- !u!1 &338809961
GameObject: GameObject:
@ -459,6 +819,7 @@ MonoBehaviour:
hideComponents: 1 hideComponents: 1
saveSelection: 1 saveSelection: 1
localizationId: localizationId:
showLineNumbers: 0
hideCommands: [] hideCommands: []
--- !u!114 &396492927 --- !u!114 &396492927
MonoBehaviour: MonoBehaviour:
@ -993,6 +1354,7 @@ MonoBehaviour:
hideComponents: 1 hideComponents: 1
saveSelection: 1 saveSelection: 1
localizationId: localizationId:
showLineNumbers: 0
hideCommands: [] hideCommands: []
--- !u!1 &575909998 --- !u!1 &575909998
GameObject: GameObject:
@ -1212,6 +1574,7 @@ MonoBehaviour:
hideComponents: 1 hideComponents: 1
saveSelection: 1 saveSelection: 1
localizationId: localizationId:
showLineNumbers: 0
hideCommands: [] hideCommands: []
--- !u!1 &590474771 --- !u!1 &590474771
GameObject: GameObject:
@ -1429,6 +1792,7 @@ MonoBehaviour:
hideComponents: 1 hideComponents: 1
saveSelection: 1 saveSelection: 1
localizationId: localizationId:
showLineNumbers: 0
hideCommands: [] hideCommands: []
--- !u!114 &590474782 --- !u!114 &590474782
MonoBehaviour: MonoBehaviour:
@ -1561,6 +1925,7 @@ MonoBehaviour:
hideComponents: 1 hideComponents: 1
saveSelection: 1 saveSelection: 1
localizationId: localizationId:
showLineNumbers: 0
hideCommands: [] hideCommands: []
--- !u!4 &636123609 --- !u!4 &636123609
Transform: Transform:
@ -1720,7 +2085,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 61dddfdc5e0e44ca298d8f46f7f5a915, type: 3} m_Script: {fileID: 11500000, guid: 61dddfdc5e0e44ca298d8f46f7f5a915, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
selectedFlowchart: {fileID: 1618689129} selectedFlowchart: {fileID: 265055382}
--- !u!4 &646902075 --- !u!4 &646902075
Transform: Transform:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
@ -2282,6 +2647,56 @@ MonoBehaviour:
platformsToIgnore: [] platformsToIgnore: []
dynamic: 0 dynamic: 0
dynamicTypeName: dynamicTypeName:
--- !u!1 &1595430749
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 4: {fileID: 1595430751}
- 114: {fileID: 1595430750}
m_Layer: 0
m_Name: StopBlockTest
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1595430750
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1595430749}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b1dba0b27b0864740a8720e920aa88c0, type: 3}
m_Name:
m_EditorClassIdentifier:
timeout: 5
ignored: 0
succeedAfterAllAssertionsAreExecuted: 0
expectException: 0
expectedExceptionList:
succeedWhenExceptionIsThrown: 0
includedPlatforms: -1
platformsToIgnore: []
dynamic: 0
dynamicTypeName:
--- !u!4 &1595430751
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1595430749}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 265055366}
m_Father: {fileID: 0}
m_RootOrder: 10
--- !u!1 &1618689128 --- !u!1 &1618689128
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -2358,6 +2773,7 @@ MonoBehaviour:
hideComponents: 1 hideComponents: 1
saveSelection: 1 saveSelection: 1
localizationId: localizationId:
showLineNumbers: 0
hideCommands: [] hideCommands: []
--- !u!114 &1618689130 --- !u!114 &1618689130
MonoBehaviour: MonoBehaviour:
@ -3476,6 +3892,7 @@ MonoBehaviour:
hideComponents: 1 hideComponents: 1
saveSelection: 1 saveSelection: 1
localizationId: localizationId:
showLineNumbers: 0
hideCommands: [] hideCommands: []
--- !u!114 &1982550315 --- !u!114 &1982550315
MonoBehaviour: MonoBehaviour:

Loading…
Cancel
Save