示例#1
0
        /// <summary>
        /// Display the player's score after a defeat
        /// </summary>
        /// <param name="w">Instance of the lost screen</param>
        /// <param name="g">Graphics used to draw the item</param>
        public void DisplayScore(Lost l, Graphics g)
        {
            SizeF showOffScore = g.MeasureString("Your Score is " + score, Game.ethnocentric15);

            g.DrawString("Your Score is " + score, Game.ethnocentric15, blackBrush,
                         new PointF((float)(Game.game.gameSize.Width / 2 - showOffScore.Width / 2), (float)l.Position.y + l.imageHeight + 20));
        }
示例#2
0
        /// <summary>
        /// Draw the whole game
        /// </summary>
        /// <param name="g">Graphics to draw in</param>
        public void Draw(Graphics g)
        {
            if (currentState == GameState.Intro)
            {
                intro.Draw(g);
            }
            else if (currentState == GameState.Menu)
            {
                mainMenu.Draw(g);
                playerScore = new Score();
            }
            else if (currentState == GameState.Play)
            {
                if (playerShip != null)
                {
                    playerShip.Draw(g);

                    playerScore.Draw(g);

                    g.DrawString("Lives : " + playerShip.Lives, ethnocentric15, blackBrush, 2, 2);

                    if (playerBonus != null)
                    {
                        playerBonus.Draw(g, gameSize.Height - 20, gameSize.Width - 20);
                    }
                }
                if (playerMissile != null)
                {
                    playerMissile.Draw(g);
                }

                if (bunkers != null)
                {
                    foreach (Bunker b in bunkers)
                    {
                        b.Draw(g);
                    }
                }

                if (enemyBlock != null)
                {
                    enemyBlock.Draw(g);

                    foreach (Missile m in missiles)
                    {
                        m.Draw(g);
                    }
                }

                if (bonus.Count != 0)
                {
                    foreach (Bonus b in bonus)
                    {
                        b.Draw(g);
                    }
                }
            }
            else if (currentState == GameState.Pause)
            {
                g.DrawImage(space_invaders.Properties.Resources.pause,
                            gameSize.Width / 2 - space_invaders.Properties.Resources.pause.Width / 2,
                            gameSize.Height / 2 - space_invaders.Properties.Resources.pause.Height / 2);
            }
            else if (currentState == GameState.Lost)
            {
                if (lostScreen == null)
                {
                    lostScreen = new Lost();
                    lostScreen.Draw(g);
                }
                else
                {
                    lostScreen.Draw(g);

                    if ((lostScreen.Position.y + lostScreen.imageHeight / 2) > gameSize.Height / 2)
                    {
                        playerScore.DisplayScore(lostScreen, g);
                        lostScreen.Blink();
                        lostScreen.DisplayWinMenu(g);
                    }
                }
            }
            else if (currentState == GameState.Win)
            {
                if (winScreen == null)
                {
                    winScreen = new Win();
                    winScreen.Draw(g);
                }
                else
                {
                    winScreen.Draw(g);

                    if ((winScreen.Position.y + winScreen.imageHeight / 2) > Game.game.gameSize.Height / 2)
                    {
                        playerScore.DisplayScore(winScreen, g);
                        winScreen.Blink();
                        winScreen.DisplayWinMenu(g);
                    }
                }
            }
        }