Ejemplo n.º 1
0
    public override void HandleInput(InputHelper inputHelper)
    {
        base.HandleInput(inputHelper);

        if (level != null)
        {
            // if the "completed" overlay is visible, pressing the spacebar should send the player to the next level
            if (completedOverlay.Visible)
            {
                if (inputHelper.MouseLeftButtonPressed())
                {
                    PenguinPairs.GoToNextLevel(level.LevelIndex);
                }
            }

            // otherwise, update the level itself, and check for button presses
            else
            {
                level.HandleInput(inputHelper);

                if (hintButton.Pressed)
                {
                    level.ShowHint();
                }
                else if (retryButton.Pressed)
                {
                    level.Reset();
                }
                if (quitButton.Pressed)
                {
                    ExtendedGame.GameStateManager.SwitchTo(PenguinPairs.StateName_LevelSelect);
                }
            }
        }
    }
Ejemplo n.º 2
0
    public void LevelCompleted(int levelIndex)
    {
        completedOverlay.Visible = true;
        level.Visible            = false;

        ExtendedGame.AssetManager.PlaySoundEffect("Sounds/snd_won");

        PenguinPairs.MarkLevelAsSolved(levelIndex);
    }
Ejemplo n.º 3
0
 public override void Update(GameTime gameTime)
 {
     base.Update(gameTime);
     foreach (LevelButton button in levelButtons)
     {
         if (button.Status != PenguinPairs.GetLevelStatus(button.LevelIndex))
         {
             button.Status = PenguinPairs.GetLevelStatus(button.LevelIndex);
         }
     }
 }
Ejemplo n.º 4
0
    public void LevelCompleted(int levelIndex)
    {
        // show an overlay image
        completedOverlay.Visible = true;
        level.Visible            = false;

        // play a sound
        ExtendedGame.AssetManager.PlaySoundEffect("Sounds/snd_won");

        // mark the level as solved, and unlock the next level
        PenguinPairs.MarkLevelAsSolved(levelIndex);
    }
Ejemplo n.º 5
0
    public LevelMenuState()
    {
        // add a background
        SpriteGameObject background = new SpriteGameObject("Sprites/spr_background_levelselect");

        gameObjects.AddChild(background);

        // add a back button
        backButton = new Button("Sprites/UI/spr_button_back");
        backButton.LocalPosition = new Vector2(415, 720);
        gameObjects.AddChild(backButton);

        // Add a level button for each level.
        // For now, let's pretend that there are 12 levels, without actually loading them yet.
        int numberOfLevels = 12;

        levelButtons = new LevelButton[numberOfLevels];

        Vector2   gridOffset          = new Vector2(155, 230);
        const int buttonsPerRow       = 5;
        const int spaceBetweenColumns = 30;
        const int spaceBetweenRows    = 5;

        for (int i = 0; i < PenguinPairs.NumberOfLevels; i++)
        {
            // create the button
            LevelButton levelButton = new LevelButton(i + 1, PenguinPairs.GetLevelStatus(i + 1));

            // give it the correct position
            int row    = i / buttonsPerRow;
            int column = i % buttonsPerRow;

            levelButton.LocalPosition = gridOffset + new Vector2(
                column * (levelButton.Width + spaceBetweenColumns),
                row * (levelButton.Height + spaceBetweenRows)
                );

            // add the button as a child object
            gameObjects.AddChild(levelButton);
            // also store it in the array of level buttons
            levelButtons[i] = levelButton;
        }
    }
Ejemplo n.º 6
0
    public override void HandleInput(InputHelper inputHelper)
    {
        base.HandleInput(inputHelper);

        if (completedOverlay.Visible)
        {
            // go to the next level?
            if (inputHelper.MouseLeftButtonPressed())
            {
                PenguinPairs.GoToNextLevel(level.LevelIndex);
            }
        }
        else
        {
            // if the "quit" button is pressed, return to the level selection screen
            if (quitButton.Pressed)
            {
                ExtendedGame.GameStateManager.SwitchTo(PenguinPairs.StateName_LevelSelect);
            }

            // if the "hint" button is pressed, show the hint arrow
            if (hintButton.Pressed)
            {
                level.ShowHint();
            }

            // if the "retry" button is pressed, reset the level
            if (retryButton.Pressed)
            {
                level.Reset();
            }

            if (level != null)
            {
                level.HandleInput(inputHelper);
            }
        }
    }
Ejemplo n.º 7
0
    static void Main()
    {
        PenguinPairs game = new PenguinPairs();

        game.Run();
    }