public override void Execute(CommandQueue commandQueue, Action onComplete)
 {
     if (callAction != null)
     {
         callAction();
     }
     onComplete();
 }
 public override void Execute(CommandQueue commandQueue, Action onComplete)
 {
     Page page = Game.GetInstance().activePage;
     if (page == null)
     {
         Debug.LogError("Active page must not be null");
     }
     else
     {
         page.AddOption(optionText, optionAction);
     }
     if (onComplete != null)
     {
         onComplete();
     }
 }
Example #3
0
        void OnMouseUpAsButton()
        {
            SpriteRenderer spriteRenderer = renderer as SpriteRenderer;

            // Ignore button press if sprite is not fully visible or
            // if the game is not in an idle state
            if (spriteRenderer.color.a != 1f ||
                !Game.GetInstance().GetShowAutoButtons())
            {
                return;
            }

            // Sound effect
            Game.GetInstance().PlayButtonClick();

            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.CallCommandMethod(buttonAction);
        }
        public override void Execute(CommandQueue commandQueue, Action onComplete)
        {
            commandQueue.cameraController.PanToView(view, duration, delegate {

                Game game = Game.GetInstance();
                game.activeView = view;

                // Try to find a page that is a child of the active view.
                // If there are multiple child pages then it is the client's responsibility
                // to set the correct active page in the room script.
                Page defaultPage = view.gameObject.GetComponentInChildren<Page>();
                if (defaultPage)
                {
                    game.activePage = defaultPage;
                }

                if (onComplete != null)
                {
                    onComplete();
                }
            });
        }
Example #5
0
        /**
         * Call a delegate method provided by the client.
         * Used to queue the execution of arbitrary code as part of a command sequeunce.
         * This method returns immediately but it queues an asynchronous command for later execution.
         * @param callAction The Action delegate method to be called when the command executes.
         */
        public static void Call(Action callAction)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.Call(callAction));
        }
 public override void Execute(CommandQueue commandQueue, Action onComplete)
 {
     spriteController.SlideFade(targetAlpha, fadeDuration, slideOffset);
     if (onComplete != null)
     {
         onComplete();
     }
 }
Example #7
0
        /**
         * Plays game music using an audio clip.
         * One music clip may be played at a time.
         * @param audioClip The music clip to play
         */
        public static void PlayMusic(AudioClip audioClip)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.PlayMusic(audioClip));
        }
Example #8
0
        /**
         * Fades the game music volume to required level over a period of time.
         * @param musicVolume The new music volume value [0..1]
         * @param duration The length of time in seconds needed to complete the volume change.
         */
        public static void SetMusicVolume(float musicVolume, float duration)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.SetMusicVolume(musicVolume, duration));
        }
 public abstract void Execute(CommandQueue commandQueue, Action onComplete);
Example #10
0
        /**
         * Hides the button sprite and makes it stop behaving as a clickable button.
         * This method returns immediately but it queues an asynchronous command for later execution.
         * @param spriteRenderer The sprite to be made non-clickable
         */
        public static void HideButton(Button button)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.ShowButton(button, false, null));
        }
Example #11
0
        /**
         * Executes the commadns in the command queue.
         */
        public static void Execute()
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.Execute();
        }
Example #12
0
        /**
         * Sets the active style for displaying the Page.
         * This method returns immediately but it queues an asynchronous command for later execution.
         * @param pageStyle The style object to make active
         */
        public static void SetPageStyle(PageStyle pageStyle)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.SetPageStyle(pageStyle));
        }
Example #13
0
        /**
         * Sets the screen space rectangle used to display the story text using a Page object.
         * Page objects can be edited visually in the Unity editor which is useful for accurate placement.
         * The actual screen space rect used is based on both the Page bounds and the camera transform at the time the command is executed.
         * This method returns immediately but it queues an asynchronous command for later execution.
         * @param page A Page object which defines the screen rect to use when rendering story text.
         */
        public static void SetPage(Page page, PageController.Layout pageLayout = PageController.Layout.FullSize)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.SetPage(page, pageLayout));
        }
Example #14
0
        /**
         * Sets the screen space rectangle used to display the story text using a ScreenRect object.
         * This method returns immediately but it queues an asynchronous command for later execution.
         * @param screenRect A ScreenRect object which defines a rect in normalized screen space coordinates.
         */
        public static void SetPageRect(PageController.ScreenRect screenRect, PageController.Layout pageLayout = PageController.Layout.FullSize)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.SetPageRect(screenRect, pageLayout));
        }
Example #15
0
        /**
         * Moves camera from the current position to a previously stored view over a period of time.
         * @param duration Time needed for pan to complete.
         * @param viewName Name of a camera view that was previously stored using StoreView().
         */
        public static void PanToStoredView(float duration, string viewName = "")
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.PanToStoredView(viewName, duration));
        }
Example #16
0
        /**
         * Stores the current camera view using a name.
         * You can later use PanToStoredView() to pan back to this stored position by name.
         * This method returns immediately but it queues an asynchronous command for later execution.
         * @param viewName Name to associate with the stored camera view.
         */
        public static void StoreView(string viewName = "")
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.StoreView(viewName));
        }
Example #17
0
        /**
         * Activates swipe panning mode.
         * The camera first pans to the nearest point between the two views over a period of time.
         * The player can then pan around the rectangular area defined between viewA & viewB.
         * Swipe panning remains active until a StopSwipePan, SetView, PanToView, FadeToPath or FadeToView command is executed.
         * This method returns immediately but it queues an asynchronous command for later execution.
         * @param viewA View object which defines one extreme of the pan area.
         * @param viewB View object which defines the other extreme of the pan area.
         */
        public static void StartSwipePan(View viewA, View viewB, float duration = 1f)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.StartSwipePan(viewA, viewB, duration));
        }
Example #18
0
        /**
         * Clears the command queue.
         */
        public static void Clear()
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.Clear();
        }
Example #19
0
        /**
         * Sets the header text displayed at the top of the page.
         * The header text is only displayed when there is some story text or options to be shown.
         * This method returns immediately but it queues an asynchronous command for later execution.
         * @param footerText The text to display as the header of the Page.
         */
        public static void SetHeader(string headerText)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.SetHeader(headerText));
        }
Example #20
0
        /**
         * Pans the camera through a sequence of target Views over a period of time.
         * The pan starts at the current camera position and performs a smooth pan through all Views in the list.
         * Command execution blocks until the pan completes.
         * If more control is required over the camera path then you should instead use an Animator component to precisely control the Camera path.
         * This method returns immediately but it queues an asynchronous command for later execution.
         * @param duration The length of time in seconds needed to complete the pan.
         * @param targetViews A parameter list of views to visit during the pan.
         */
        public static void PanToPath(float duration, params View[] targetViews)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.PanToPath(targetViews, duration));
        }
Example #21
0
        /**
         * Sets the footer text displayed at the top of the page.
         * The footer text is only displayed when there is some story text or options to be shown.
         * This method returns immediately but it queues an asynchronous command for later execution.
         * @param footerText The text to display as the footer of the Page.
         */
        public static void SetFooter(string footerText)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.SetFooter(footerText));
        }
Example #22
0
        /**
         * Pans the camera to the target position and size over a period of time.
         * The pan starts at the current camera position and performs a smoothed linear pan to the target.
         * Command execution blocks until the pan completes.
         * This method returns immediately but it queues an asynchronous command for later execution.
         * @param targetView The View to pan the camera to.
         * @param duration The length of time in seconds needed to complete the pan.
         */
        public static void PanToPosition(Vector3 targetPosition, float targetSize, float duration)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.PanToPosition(targetPosition, targetSize, duration));
        }
Example #23
0
        /**
         * Transitions from the current Room to another Room.
         * This method returns immediately but it queues an asynchronous command for later execution.
         * @param room The Room to transition to.
         */
        public static void MoveToRoom(Room room)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.MoveToRoom(room));
        }
Example #24
0
        /**
         * Sets an animator trigger to change the animation state for an animated sprite.
         * This is the primary method of controlling Unity animations from a Fungus command sequence.
         * This method returns immediately but it queues an asynchronous command for later execution.
         * @param animator The sprite to be made non-clickable
         * @param triggerName Name of a trigger parameter in the animator controller
         */
        public static void SetAnimatorTrigger(Animator animator, string triggerName)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.SetAnimatorTrigger(animator, triggerName));
        }
Example #25
0
        /**
         * Writes story text to the page.
         * A 'continue' button is displayed when the text has fully appeared.
         * Command execution halts until the user chooses to continue.
         * This method returns immediately but it queues an asynchronous command for later execution.
         * @param storyText The text to be written to the page.
         */
        public static void Say(string storyText)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.Say(storyText));
        }
Example #26
0
        /**
         * Stops playing game music.
         */
        public static void StopMusic()
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.StopMusic());
        }
Example #27
0
        /**
         * Adds an option to the current list of player options.
         * Use the Choose() method to display previously added options.
         * This method returns immediately but it queues an asynchronous command for later execution.
         * @param optionText The text to be displayed for this option
         * @param optionAction The Action delegate method to be called when the player selects the option
         */
        public static void AddOption(string optionText, Action optionAction)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.AddOption(optionText, optionAction));
        }
Example #28
0
        /**
         * Plays a sound effect once, at the specified volume.
         * Multiple sound effects can be played at the same time.
         * @param audioClip The sound effect clip to play
         * @param volume The volume level of the sound effect
         */
        public static void PlaySound(AudioClip audioClip, float volume)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.PlaySound(audioClip, volume));
        }
 public override void Execute(CommandQueue commandQueue, Action onComplete)
 {
     spriteController.PlayAnimation(animationName);
     if (onComplete != null)
     {
         onComplete();
     }
 }
 public override void Execute(CommandQueue commandQueue, Action onComplete)
 {
     Page page = Game.GetInstance().activePage;
     if (page == null)
     {
         Debug.LogError("Active page must not be null");
     }
     else
     {
         page.Choose(chooseText);
     }
     // Choose always clears commandQueue, so no need to call onComplete()
 }
 public override void Execute(CommandQueue commandQueue, Action onComplete)
 {
     Game.GetInstance().SetInventory(key, value);
     if (onComplete != null)
     {
         onComplete();
     }
 }
        public override void Execute(CommandQueue commandQueue, Action onComplete)
        {
            Game.GetInstance().MoveToRoom(room);

            // MoveToRoom always resets the command queue so no need to call onComplete
        }
        public override void Execute(CommandQueue commandQueue, Action onComplete)
        {
            commandQueue.cameraController.SnapToView(view);
            Game.GetInstance().activeView = view;

            // Set the first page component found (if any) as the active page
            Page page = view.gameObject.GetComponentInChildren<Page>();
            if (page != null)
            {
                Game.GetInstance().activePage = page;
            }

            if (onComplete != null)
            {
                onComplete();
            }
        }
Example #34
0
        /**
         * Adds an option with no action to the current list of player options.
         * This method returns immediately but it queues an asynchronous command for later execution.
         * @param optionText The text to be displayed for this option
         * @param optionAction The Action delegate method to be called when the player selects the option
         */
        public static void AddOption(string optionText)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.AddOption(optionText, delegate {}));
        }
Example #35
0
        /**
         * Fades out the current camera View, and fades in again using the target View.
         * This method returns immediately but it queues an asynchronous command for later execution.
         * @param targetView The View object to fade to.
         * @param duration The length of time in seconds needed to complete the pan.
         */
        public static void FadeToView(View targetView, float duration)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.FadeToView(targetView, duration));
        }
 public override void Execute(CommandQueue commandQueue, Action onComplete)
 {
     Page page = Game.GetInstance().activePage;
     if (page == null)
     {
         Debug.LogError("Active page must not be null");
     }
     else
     {
         page.Say(storyText, onComplete);
     }
 }
Example #37
0
        /**
         * Displays a story text prompt, followed by all previously added options.
         * This method returns immediately but it queues an asynchronous command for later execution.
         * @param chooseText The story text to be written above the list of options
         */
        public static void Choose(string chooseText)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.Choose(chooseText));
        }
 public override void Execute(CommandQueue commandQueue, Action onComplete)
 {
     Game.GetInstance().activePage = page;
     if (onComplete != null)
     {
         onComplete();
     }
 }
Example #39
0
        /**
         * Sets a globally accessible string value.
         * This method returns immediately but it queues an asynchronous command for later execution.
         * @param key The name of the value to set
         * @param value The string value to set
         */
        public static void SetString(string key, string value)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.SetString(key, value));
        }
 public override void Execute(CommandQueue commandQueue, Action onComplete)
 {
     commandQueue.StartCoroutine(WaitCoroutine(duration, onComplete));
 }
Example #41
0
        /**
         * Wait for a period of time before executing the next command.
         * This method returns immediately but it queues an asynchronous command for later execution.
         * @param duration The wait duration in seconds
         */
        public static void Wait(float duration)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.Wait(duration));
        }
 void Awake()
 {
     game = Game.GetInstance();
     cameraController = game.gameObject.GetComponent<CameraController>();
     commandQueue = game.gameObject.GetComponent<CommandQueue>();
 }
Example #43
0
        /**
         * Displays a button sprite object and sets the action callback method for the button.
         * If no Collider2D already exists on the object, then a BoxCollider2D is automatically added.
         * Use HideButton() to make the sprite invisible and non-clickable again.
         * This method returns immediately but it queues an asynchronous command for later execution.
         * @param button The button component of the sprite object to be shown.
         * @param buttonAction The Action delegate method to be called when the player clicks on the button
         */
        public static void ShowButton(Button button, Action buttonAction)
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.ShowButton(button, true, buttonAction));
        }
        public virtual void Start()
        {
            cameraController = GetComponent<CameraController>();
            commandQueue = GetComponent<CommandQueue>();

            if (activeRoom == null)
            {
                // Pick first room found if none is specified
                activeRoom = GameObject.FindObjectOfType(typeof(Room)) as Room;
            }

            if (activeRoom != null)
            {
                MoveToRoom(activeRoom);
            }
        }
Example #45
0
        /**
         * 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 static void WaitForInput()
        {
            CommandQueue commandQueue = Game.GetInstance().commandQueue;

            commandQueue.AddCommand(new Command.WaitForInput());
        }