/// <summary>
        /// Starts the scene elements
        /// </summary>
        /// <param name="game">Game manager</param>
        public void Start(Game game)
        {
            // Sets the game frame rate to 60
            game.DesiredFrameRate = 60;
            // Changes the title of the game
            Console.Title = "Tamagottagettemall";

            // Loads the ASCII art from a file
            _TitleArt = Utils.StringReadFile("Title.txt");

            // Sets the current step of the scene to 0
            _Step = 0;

            // This first animation handles the ASCII title animation that goes from right to left
            // This animation will represent the X-coordinate of the art position
            // It goes from 32 (right limit) and goes all the way to -360 (the text is 360 characters wide, so -360 would be the left limit)
            // The animation will take 8000 milliseconds and it will start slow, go through fast and arrives slow
            _Animation = new SimpleAnimation(32, -360, 8000, Smoothness.StartArrival, () =>
            {
                // When it's done, goes to the next step of the scene
                ++_Step;

                // Another animation happens now
                // This animation represents the fade in of the small title from the title screen
                // It goes from 0 (totally transparent) to 1 (totally opaque)
                // It takes 500 milliseconds and starts fast, goes through fast and arrives slow
                _Animation.Reset(0.0f, 1.0f, 500, Smoothness.Arrival, () =>
                {
                    // When it's done, goes to the next step of the scene
                    ++_Step;

                    // We will set up the "PRESS START" animation now
                    // As it's gonna flash, we have to make a show animation and a hide animation
                    Action hideAction = null;
                    Action showAction = null;

                    // The show animation will make the "PRESS START" visible for 500 milliseconds
                    // This animation goes from 1 to 1 because the text is meant to be totally opaque this whole time
                    // No need for smoothness, because the values are not varying
                    showAction = () =>
                    {
                        // And when the animation is done, calls the hide animation
                        _Animation.Reset(1.0f, 1.0f, 500, Smoothness.None, hideAction);
                    };

                    // The hide animation will make the "PRESS START" invisible for 1000 milliseconds
                    // This animation goes from 0 to 0 because the text is meant to be totally transparent this whole time
                    // No need for smoothness, because the values are not varying
                    hideAction = () =>
                    {
                        // And when the animation is done, calls the show animation
                        // You may notice by now that the animation calls another after it's done - that's how it loops
                        _Animation.Reset(0.0f, 0.0f, 1000, Smoothness.None, showAction);
                    };

                    // First it starts with the show animation
                    showAction();
                });

            });
        }
Example #2
0
        /// <summary>
        /// Handles the logical part of the scene
        /// </summary>
        /// <param name="game">Game manager</param>
        public void Update(Game game)
        {
            // Updates the animation flow
            _Animation.Update(game.DeltaMilliseconds);

            // Gets if any keyboard key was just 'pressed'
            KeyboardKey keyboardKey = game.KeyboardManager.AnyTriggered;

            // If no key was pressed
            if (keyboardKey == null)
                // Then does nothing
                return;

            // If Escape was pressed
            if (keyboardKey.Key == Key.Escape)
                // Moves back to the title scene
                game.SceneManager.NextScene = new SceneTitle();

            // Checks at what scene step it is
            switch (_Step)
            {
                // This step is when you're selecting what action you're taking
                case 1:
                    bool actionChanged = false;

                    switch (keyboardKey.Key)
                    {
                        // If the Left Arrow was pressed
                        case Key.Left:
                            // Moves to the left option
                            --_ActionSelected;
                            actionChanged = true;
                            break;
                        // If Right Arrow was pressed
                        case Key.Right:
                            // Moves to the right option
                            ++_ActionSelected;
                            actionChanged = true;
                            break;
                        // If Enter was pressed
                        case Key.Enter:
                            // Runs the action
                            switch (_ActionSelected)
                            {
                                case 0:
                                    GameGlobals.Pet.Eat();
                                    break;
                                case 1:
                                    GameGlobals.Pet.Sleep();
                                    break;
                                case 2:
                                    GameGlobals.Pet.Exercise();
                                    break;
                                default:
                                    GameGlobals.Pet.Play();
                                    break;
                            }

                            // If the pet is fine
                            if (
                                (GameGlobals.Pet.Hunger    <  1.0f) &&
                                (GameGlobals.Pet.Energy    > -1.0f) &&
                                (GameGlobals.Pet.Fat       <  1.0f) &&
                                (GameGlobals.Pet.Happiness > -1.0f)
                            )
                            {
                                // Subtracts one from the actions left
                                --_ActionsLeft;
                                // Moves to the feedback screen
                                ++_Step;
                            }
                            // If anything about the pet is too critical
                            else
                            {
                                // Fades out to the gameover scene
                                _Animation = new SimpleAnimation(1.0f, 0.0f, 500, Smoothness.Start, () =>
                                {
                                    game.SceneManager.NextScene = new SceneGameover();
                                });
                                _Step = 4;
                            }

                            break;
                    }

                    // If you moved to a different action
                    if (actionChanged)
                    {
                        _ActionSelected %= 4;

                        while (_ActionSelected < 0)
                            _ActionSelected += 4;

                        // Do a scrolling animation to the right item
                        _Animation.Reset(
                            _Animation.Value,
                            _ActionSelected,
                            250,
                            Smoothness.StartArrival
                        );
                    }

                    break;
                // This is the feedback part
                case 2:
                    // If there's still an action left
                    if (_ActionsLeft == 1)
                        // Goes back to action selection part
                        --_Step;
                    // Otherwise
                    else
                    {
                        // Fades out to the report scene
                        _Animation.Reset(1.0f, 0.0f, 500, Smoothness.Start, () => game.SceneManager.NextScene = new SceneReport());
                        ++_Step;
                    }
                    break;
            }
        }
Example #3
0
        /// <summary>
        /// Handles the logical part of the scene
        /// </summary>
        /// <param name="game">Game manager</param>
        public void Update(Game game)
        {
            // Updates the animation flow
            _Animation.Update(game.DeltaMilliseconds);

            // Gets if any keyboard key was just 'pressed'
            KeyboardKey keyboardKey = game.KeyboardManager.AnyTriggered;

            // If no key was pressed
            if (keyboardKey == null)
            {
                // Then does nothing
                return;
            }

            // If Escape was pressed
            if (keyboardKey.Key == Key.Escape)
            {
                // Moves back to the title scene
                game.SceneManager.NextScene = new SceneTitle();
            }

            // Checks at what scene step it is
            switch (_Step)
            {
            // This step is when you're selecting what action you're taking
            case 1:
                bool actionChanged = false;

                switch (keyboardKey.Key)
                {
                // If the Left Arrow was pressed
                case Key.Left:
                    // Moves to the left option
                    --_ActionSelected;
                    actionChanged = true;
                    break;

                // If Right Arrow was pressed
                case Key.Right:
                    // Moves to the right option
                    ++_ActionSelected;
                    actionChanged = true;
                    break;

                // If Enter was pressed
                case Key.Enter:
                    // Runs the action
                    switch (_ActionSelected)
                    {
                    case 0:
                        GameGlobals.Pet.Eat();
                        break;

                    case 1:
                        GameGlobals.Pet.Sleep();
                        break;

                    case 2:
                        GameGlobals.Pet.Exercise();
                        break;

                    default:
                        GameGlobals.Pet.Play();
                        break;
                    }

                    // If the pet is fine
                    if (
                        (GameGlobals.Pet.Hunger < 1.0f) &&
                        (GameGlobals.Pet.Energy > -1.0f) &&
                        (GameGlobals.Pet.Fat < 1.0f) &&
                        (GameGlobals.Pet.Happiness > -1.0f)
                        )
                    {
                        // Subtracts one from the actions left
                        --_ActionsLeft;
                        // Moves to the feedback screen
                        ++_Step;
                    }
                    // If anything about the pet is too critical
                    else
                    {
                        // Fades out to the gameover scene
                        _Animation = new SimpleAnimation(1.0f, 0.0f, 500, Smoothness.Start, () =>
                        {
                            game.SceneManager.NextScene = new SceneGameover();
                        });
                        _Step = 4;
                    }


                    break;
                }

                // If you moved to a different action
                if (actionChanged)
                {
                    _ActionSelected %= 4;

                    while (_ActionSelected < 0)
                    {
                        _ActionSelected += 4;
                    }

                    // Do a scrolling animation to the right item
                    _Animation.Reset(
                        _Animation.Value,
                        _ActionSelected,
                        250,
                        Smoothness.StartArrival
                        );
                }

                break;

            // This is the feedback part
            case 2:
                // If there's still an action left
                if (_ActionsLeft == 1)
                {
                    // Goes back to action selection part
                    --_Step;
                }
                // Otherwise
                else
                {
                    // Fades out to the report scene
                    _Animation.Reset(1.0f, 0.0f, 500, Smoothness.Start, () => game.SceneManager.NextScene = new SceneReport());
                    ++_Step;
                }
                break;
            }
        }
Example #4
0
 /// <summary>
 /// Starts the scene elements
 /// </summary>
 /// <param name="game">Game manager</param>
 public void Start(Game game)
 {
     // Loads the pet art from a file
     _PetArt = Utils.StringReadFile("Pet.txt");
     // Sets the selected action to the first one
     _ActionSelected = 0;
     // This first animation is the "Day #" fadein
     // It goes from 0 (totally transparent) and goes to 1 (totally opaque)
     // It takes 500 milliseconds to complete the animation and starts fast, goes through fast and arrives slow
     _Animation = new SimpleAnimation(0.0f, 1.0f, 500, Smoothness.Arrival, () =>
     {
         // When its done, it waits for 1000 milliseconds
         _Animation.Reset(1.0f, 1.0f, 1000, Smoothness.None, () =>
         {
             // Then it fades out in 500 milliseconds
             _Animation.Reset(1.0f, 0.0f, 500, Smoothness.Start, () =>
             {
                 // When it's done it goes to the next step
                 ++_Step;
             });
         });
     });
     // Sets the amount of actions left to 2
     _ActionsLeft = 2;
 }