16 changed files with 1378 additions and 5 deletions
@ -0,0 +1,9 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: c5af9b1dcfc3a4963add98929d9386c0 |
||||||
|
folderAsset: yes |
||||||
|
timeCreated: 1474968754 |
||||||
|
licenseType: Free |
||||||
|
DefaultImporter: |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,36 @@ |
|||||||
|
using Fungus.Utils; |
||||||
|
|
||||||
|
namespace Fungus |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Block event signalling system. |
||||||
|
/// You can use this to be notified about various events in the Block execution process. |
||||||
|
/// </summary> |
||||||
|
public static class BlockSignals |
||||||
|
{ |
||||||
|
#region Public members |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// BlockStart signal. Sent when the Block starts execution. |
||||||
|
/// </summary> |
||||||
|
public static event BlockStartHandler OnBlockStart; |
||||||
|
public delegate void BlockStartHandler(Block block); |
||||||
|
public static void DoBlockStart(Block block) { if (OnBlockStart != null) OnBlockStart(block); } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// BlockEnd signal. Sent when the Block ends execution. |
||||||
|
/// </summary> |
||||||
|
public static event BlockEndHandler OnBlockEnd; |
||||||
|
public delegate void BlockEndHandler(Block block); |
||||||
|
public static void DoBlockEnd(Block block) { if (OnBlockEnd != null) OnBlockEnd(block); } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// CommandExecute signal. Sent just before a Command in a Block executes. |
||||||
|
/// </summary> |
||||||
|
public static event CommandExecuteHandler OnCommandExecute; |
||||||
|
public delegate void CommandExecuteHandler(Block block, Command command, int commandIndex, int maxCommandIndex); |
||||||
|
public static void DoCommandExecute(Block block, Command command, int commandIndex, int maxCommandIndex) { if (OnCommandExecute != null) OnCommandExecute(block, command, commandIndex, maxCommandIndex); } |
||||||
|
|
||||||
|
#endregion |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 12109e10b0f034bbab8a7a5d700bc070 |
||||||
|
timeCreated: 1474988491 |
||||||
|
licenseType: Free |
||||||
|
MonoImporter: |
||||||
|
serializedVersion: 2 |
||||||
|
defaultReferences: [] |
||||||
|
executionOrder: 0 |
||||||
|
icon: {instanceID: 0} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,45 @@ |
|||||||
|
using UnityEngine; |
||||||
|
using System.Collections; |
||||||
|
using Fungus.Utils; |
||||||
|
|
||||||
|
namespace Fungus |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Writer event signalling system. |
||||||
|
/// You can use this to be notified about various events in the writing process. |
||||||
|
/// </summary> |
||||||
|
public static class WriterSignals |
||||||
|
{ |
||||||
|
#region Public members |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// TextTagToken signal. Sent for each unique token when writing text. |
||||||
|
/// </summary> |
||||||
|
public static event TextTagTokenHandler OnTextTagToken; |
||||||
|
public delegate void TextTagTokenHandler(Writer writer, TextTagToken token, int index, int maxIndex); |
||||||
|
public static void DoTextTagToken(Writer writer, TextTagToken token, int index, int maxIndex) { if(OnTextTagToken != null) OnTextTagToken(writer, token, index, maxIndex); } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// WriterState signal. Sent when the writer changes state. |
||||||
|
/// </summary> |
||||||
|
public static event WriterStateHandler OnWriterState; |
||||||
|
public delegate void WriterStateHandler(Writer writer, WriterState writerState); |
||||||
|
public static void DoWriterState(Writer writer, WriterState writerState) { if (OnWriterState != null) OnWriterState(writer, writerState); } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// WriterInput signal. Sent when the writer receives player input. |
||||||
|
/// </summary> |
||||||
|
public static event WriterInputHandler OnWriterInput; |
||||||
|
public delegate void WriterInputHandler(Writer writer); |
||||||
|
public static void DoWriterInput(Writer writer) { if (OnWriterInput != null) OnWriterInput(writer); } |
||||||
|
|
||||||
|
/// <summary> |
||||||
|
/// WriterGlyph signal. Sent when the writer writes out a glyph. |
||||||
|
/// </summary> |
||||||
|
public delegate void WriterGlyphHandler(Writer writer); |
||||||
|
public static event WriterGlyphHandler OnWriterGlyph; |
||||||
|
public static void DoWriterGlyph(Writer writer) { if (OnWriterGlyph != null) OnWriterGlyph(writer); } |
||||||
|
|
||||||
|
#endregion |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: d8d3d56bc3bd9488d8e6e30b9bf99fc4 |
||||||
|
timeCreated: 1474970135 |
||||||
|
licenseType: Free |
||||||
|
MonoImporter: |
||||||
|
serializedVersion: 2 |
||||||
|
defaultReferences: [] |
||||||
|
executionOrder: 0 |
||||||
|
icon: {instanceID: 0} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,9 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 2e1206d3bce424ca8a9b82f05c69335d |
||||||
|
folderAsset: yes |
||||||
|
timeCreated: 1474982411 |
||||||
|
licenseType: Free |
||||||
|
DefaultImporter: |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,53 @@ |
|||||||
|
using UnityEngine; |
||||||
|
using System.Collections; |
||||||
|
using Fungus.Commands; |
||||||
|
|
||||||
|
namespace Fungus |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Checks if Block signals are being sent correctly. |
||||||
|
/// </summary> |
||||||
|
[AddComponentMenu("")] |
||||||
|
public class BlockSignalsTester : MonoBehaviour |
||||||
|
{ |
||||||
|
bool started = false; |
||||||
|
bool commandExecuted = false; |
||||||
|
|
||||||
|
void OnEnable() |
||||||
|
{ |
||||||
|
BlockSignals.OnBlockStart += OnBlockStart; |
||||||
|
BlockSignals.OnBlockEnd += OnBlockEnd; |
||||||
|
BlockSignals.OnCommandExecute += OnCommandExecute; |
||||||
|
} |
||||||
|
|
||||||
|
void OnDisable() |
||||||
|
{ |
||||||
|
BlockSignals.OnBlockStart -= OnBlockStart; |
||||||
|
BlockSignals.OnBlockEnd -= OnBlockEnd; |
||||||
|
BlockSignals.OnCommandExecute -= OnCommandExecute; |
||||||
|
} |
||||||
|
|
||||||
|
void OnBlockStart(Block block) |
||||||
|
{ |
||||||
|
IntegrationTest.Assert(block.BlockName == "Start"); |
||||||
|
|
||||||
|
started = true; |
||||||
|
} |
||||||
|
|
||||||
|
void OnBlockEnd(Block block) |
||||||
|
{ |
||||||
|
IntegrationTest.Assert(started); |
||||||
|
IntegrationTest.Assert(commandExecuted); |
||||||
|
|
||||||
|
IntegrationTest.Pass(); |
||||||
|
} |
||||||
|
|
||||||
|
void OnCommandExecute(Block block, Command command, int commandIndex, int maxCommandIndex) |
||||||
|
{ |
||||||
|
IntegrationTest.Assert(commandIndex == 0); |
||||||
|
IntegrationTest.Assert(maxCommandIndex == 1); |
||||||
|
IntegrationTest.Assert(command.GetType() == typeof(Wait)); |
||||||
|
commandExecuted = true; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 5d396ca39a0454e2ca06d4aad7c5706c |
||||||
|
timeCreated: 1474988463 |
||||||
|
licenseType: Free |
||||||
|
MonoImporter: |
||||||
|
serializedVersion: 2 |
||||||
|
defaultReferences: [] |
||||||
|
executionOrder: 0 |
||||||
|
icon: {instanceID: 0} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: 8acd008952a224b138b2b02baae1f7ff |
||||||
|
timeCreated: 1474970336 |
||||||
|
licenseType: Free |
||||||
|
DefaultImporter: |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
@ -0,0 +1,97 @@ |
|||||||
|
using UnityEngine; |
||||||
|
using Fungus.Utils; |
||||||
|
|
||||||
|
namespace Fungus |
||||||
|
{ |
||||||
|
/// <summary> |
||||||
|
/// Checks if Writer signals are being sent correctly. |
||||||
|
/// </summary> |
||||||
|
[AddComponentMenu("")] |
||||||
|
public class WriterSignalsTester : MonoBehaviour |
||||||
|
{ |
||||||
|
int correctTagCount = 0; |
||||||
|
bool receivedInput = false; |
||||||
|
int glyphCount = 0; |
||||||
|
|
||||||
|
void OnEnable() |
||||||
|
{ |
||||||
|
WriterSignals.OnTextTagToken += OnTextTagToken; |
||||||
|
WriterSignals.OnWriterState += OnWriterState; |
||||||
|
WriterSignals.OnWriterInput += OnWriterInput; |
||||||
|
WriterSignals.OnWriterGlyph += OnWriterGlyph; |
||||||
|
} |
||||||
|
|
||||||
|
void OnDisable() |
||||||
|
{ |
||||||
|
WriterSignals.OnTextTagToken -= OnTextTagToken; |
||||||
|
WriterSignals.OnWriterState -= OnWriterState; |
||||||
|
WriterSignals.OnWriterInput -= OnWriterInput; |
||||||
|
WriterSignals.OnWriterGlyph -= OnWriterGlyph; |
||||||
|
} |
||||||
|
|
||||||
|
void OnTextTagToken(Writer writer, TextTagToken token, int index, int maxIndex) |
||||||
|
{ |
||||||
|
if (index == 0 && token.type == TokenType.BoldStart) |
||||||
|
{ |
||||||
|
correctTagCount++; |
||||||
|
} |
||||||
|
else if (index == 1 && token.type == TokenType.Wait) |
||||||
|
{ |
||||||
|
correctTagCount++; |
||||||
|
} |
||||||
|
else if (index == 2 && token.type == TokenType.Words) |
||||||
|
{ |
||||||
|
correctTagCount++; |
||||||
|
} |
||||||
|
else if (index == 3 && token.type == TokenType.BoldEnd) |
||||||
|
{ |
||||||
|
correctTagCount++; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void OnWriterState(Writer writer, WriterState writerState) |
||||||
|
{ |
||||||
|
if (writerState == WriterState.Start && correctTagCount != 0) |
||||||
|
{ |
||||||
|
IntegrationTest.Fail(); |
||||||
|
} |
||||||
|
if (writerState == WriterState.Pause && correctTagCount != 2) |
||||||
|
{ |
||||||
|
IntegrationTest.Fail(); |
||||||
|
} |
||||||
|
if (writerState == WriterState.Resume && correctTagCount != 2) |
||||||
|
{ |
||||||
|
IntegrationTest.Fail(); |
||||||
|
} |
||||||
|
else if (writerState == WriterState.End && correctTagCount != 4) |
||||||
|
{ |
||||||
|
IntegrationTest.Fail(); |
||||||
|
} |
||||||
|
|
||||||
|
if (writerState == WriterState.End) |
||||||
|
{ |
||||||
|
if (!receivedInput) |
||||||
|
{ |
||||||
|
IntegrationTest.Fail(); |
||||||
|
} |
||||||
|
|
||||||
|
if (glyphCount != 6) |
||||||
|
{ |
||||||
|
IntegrationTest.Fail(); |
||||||
|
} |
||||||
|
|
||||||
|
IntegrationTest.Pass(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void OnWriterInput(Writer writer) |
||||||
|
{ |
||||||
|
receivedInput = true; |
||||||
|
} |
||||||
|
|
||||||
|
void OnWriterGlyph(Writer writer) |
||||||
|
{ |
||||||
|
glyphCount++; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
fileFormatVersion: 2 |
||||||
|
guid: cb302fcb509f14caf93dea80411e90ac |
||||||
|
timeCreated: 1474968744 |
||||||
|
licenseType: Free |
||||||
|
MonoImporter: |
||||||
|
serializedVersion: 2 |
||||||
|
defaultReferences: [] |
||||||
|
executionOrder: 0 |
||||||
|
icon: {instanceID: 0} |
||||||
|
userData: |
||||||
|
assetBundleName: |
||||||
|
assetBundleVariant: |
Loading…
Reference in new issue