diff --git a/Assets/Fungus/Audio.meta b/Assets/Fungus/Audio.meta new file mode 100644 index 00000000..e8e429c6 --- /dev/null +++ b/Assets/Fungus/Audio.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: d9780867e1f2c456a9bd67af4ed5e2e4 +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/Fungus/Audio/Click.wav b/Assets/Fungus/Audio/Click.wav new file mode 100644 index 00000000..c20f06b1 Binary files /dev/null and b/Assets/Fungus/Audio/Click.wav differ diff --git a/Assets/FungusExample/Audio/click.wav.meta b/Assets/Fungus/Audio/Click.wav.meta similarity index 65% rename from Assets/FungusExample/Audio/click.wav.meta rename to Assets/Fungus/Audio/Click.wav.meta index 19c2b336..c8b9390f 100644 --- a/Assets/FungusExample/Audio/click.wav.meta +++ b/Assets/Fungus/Audio/Click.wav.meta @@ -1,9 +1,9 @@ fileFormatVersion: 2 -guid: 05266cba5e04d4b13abd1e60df58cea9 +guid: c18ae2c530c264a6880266d5e0a71337 AudioImporter: serializedVersion: 4 - format: 0 - quality: .5 + format: -1 + quality: -.280000001 stream: 1 3D: 0 forceToMono: 0 diff --git a/Assets/Fungus/Prefabs/Game.prefab b/Assets/Fungus/Prefabs/Game.prefab index cb86b59f..0749709b 100644 Binary files a/Assets/Fungus/Prefabs/Game.prefab and b/Assets/Fungus/Prefabs/Game.prefab differ diff --git a/Assets/Fungus/Scripts/ButtonController.cs b/Assets/Fungus/Scripts/ButtonController.cs index 1d566487..3e8553f4 100644 --- a/Assets/Fungus/Scripts/ButtonController.cs +++ b/Assets/Fungus/Scripts/ButtonController.cs @@ -13,7 +13,8 @@ namespace Fungus bool showAutoButtons = false; Page page = Game.GetInstance().activePage; if (page != null && - page.mode == Page.Mode.Idle) + page.mode == Page.Mode.Idle && + !Game.GetInstance().waiting) { showAutoButtons = true; } diff --git a/Assets/Fungus/Scripts/Commands.cs b/Assets/Fungus/Scripts/Commands.cs index 32cd945d..a022124e 100644 --- a/Assets/Fungus/Scripts/Commands.cs +++ b/Assets/Fungus/Scripts/Commands.cs @@ -55,6 +55,7 @@ namespace Fungus public override void Execute(CommandQueue commandQueue, Action onComplete) { + Game.GetInstance().waiting = true; commandQueue.StartCoroutine(WaitCoroutine(duration, onComplete)); } @@ -63,6 +64,37 @@ namespace Fungus yield return new WaitForSeconds(duration); if (onComplete != null) { + Game.GetInstance().waiting = false; + onComplete(); + } + } + } + + /** + * Wait for a player tap/click/key press + */ + public class WaitForInputCommand : CommandQueue.Command + { + public override void Execute(CommandQueue commandQueue, Action onComplete) + { + Game.GetInstance().waiting = true; + commandQueue.StartCoroutine(WaitCoroutine(onComplete)); + } + + IEnumerator WaitCoroutine(Action onComplete) + { + while (true) + { + if (Input.GetMouseButtonDown(0) || Input.anyKeyDown) + { + break; + } + yield return null; + } + + if (onComplete != null) + { + Game.GetInstance().waiting = false; onComplete(); } } diff --git a/Assets/Fungus/Scripts/Game.cs b/Assets/Fungus/Scripts/Game.cs index 91302f60..203310ac 100644 --- a/Assets/Fungus/Scripts/Game.cs +++ b/Assets/Fungus/Scripts/Game.cs @@ -93,6 +93,12 @@ namespace Fungus [HideInInspector] public ButtonController buttonController; + /** + * True when executing a Wait() or WaitForTap() command + */ + [HideInInspector] + public bool waiting; + static Game instance; public static Game GetInstance() diff --git a/Assets/Fungus/Scripts/GameController.cs b/Assets/Fungus/Scripts/GameController.cs index 056f30bd..79ac104c 100644 --- a/Assets/Fungus/Scripts/GameController.cs +++ b/Assets/Fungus/Scripts/GameController.cs @@ -32,7 +32,17 @@ namespace Fungus CommandQueue commandQueue = Game.GetInstance().commandQueue; commandQueue.AddCommand(new Command.WaitCommand(duration)); } - + + /** + * Wait until player taps, clicks or presses a key before executing the next command. + * This method returns immediately but it queues an asynchronous command for later execution. + */ + public void WaitForInput() + { + CommandQueue commandQueue = Game.GetInstance().commandQueue; + commandQueue.AddCommand(new Command.WaitForInputCommand()); + } + /** * Call a delegate method provided by the client. * Used to queue the execution of arbitrary code as part of a command sequeunce. diff --git a/Assets/FungusExample/Audio/click.wav b/Assets/FungusExample/Audio/click.wav deleted file mode 100644 index 1b056a99..00000000 Binary files a/Assets/FungusExample/Audio/click.wav and /dev/null differ diff --git a/Assets/FungusExample/Scenes/Example.unity b/Assets/FungusExample/Scenes/Example.unity index ec136c77..4a15969e 100644 Binary files a/Assets/FungusExample/Scenes/Example.unity and b/Assets/FungusExample/Scenes/Example.unity differ diff --git a/Assets/FungusExample/Scripts/ButtonRoom.cs b/Assets/FungusExample/Scripts/ButtonRoom.cs index 4054ff9e..1c376965 100644 --- a/Assets/FungusExample/Scripts/ButtonRoom.cs +++ b/Assets/FungusExample/Scripts/ButtonRoom.cs @@ -26,6 +26,9 @@ public class ButtonRoom : Room Say("The Mushroom read his book with great interest."); Say("After turning the last page, he considered his options."); + // Uncomment this line to make the player tap the screen before showing the buttons + // WaitForInput(); + // Once the last Say command executes the page will dissappear because there's no more content to show. // At that point, the game will automatically fade in all Auto Buttons in the room }