public LevelMenuState()
        {
            SpriteGameObject levelMenu = new SpriteGameObject("Sprites/spr_background_levelselect");

            gameObjects.AddChild(levelMenu);

            backButton          = new Button("Sprites/UI/spr_button_back");
            backButton.Position = new Vector2(415, 720);
            gameObjects.AddChild(backButton);

            int numberOfLevels = PenguinPairs.NumberOfLevels;

            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 < numberOfLevels; i++)
            {
                LevelButton levelButton = new LevelButton(i + 1, PenguinPairs.GetLevelStatus(i + 1));

                int row    = i / buttonsPerRow;
                int column = i % buttonsPerRow;
                levelButton.Position = gridOffset + new Vector2(
                    column * (levelButton.Width + spaceBetweenColumns),
                    row * (levelButton.Height + spaceBetweenRows));

                gameObjects.AddChild(levelButton);
                levelButtons[i] = levelButton;
            }
        }
Example #2
0
        public override void HandleInput(InputHelper inputHelper)
        {
            base.HandleInput(inputHelper);

            if (completedOverlay.Visible)
            {
                if (inputHelper.MouseLeftButtonPressed())
                {
                    PenguinPairs.GoToNextLevel(level.LevelIndex);
                }
            }
            else
            {
                if (quitButton.Pressed)
                {
                    ExtendedGame.GameStateManager.SwitchTo(PenguinPairs.StateName_LevelMenu);
                }

                if (level != null)
                {
                    level.HandleInput(inputHelper);
                }

                if (hintButton.Pressed)
                {
                    level.ShowHint();
                }

                if (retryButton.Pressed)
                {
                    level.Reset();
                }
            }
        }
Example #3
0
        public void LevelCompleted(int levelIndex)
        {
            completedOverlay.Visible = true;
            level.Visible            = false;

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

            PenguinPairs.MarkLevelAsSolved(levelIndex);
        }
 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);
         }
     }
 }
        private static void Main()
        {
            PenguinPairs game = new PenguinPairs();

            game.Run();
        }