Ejemplo n.º 1
0
        // draw 2D gui
        public override void Draw2D(GraphicsDevice gd, FontManager font)
        {
            if (gd == null)
            {
                throw new ArgumentNullException("gd");
            }

            Rectangle rect = new Rectangle(0, 0, 0, 0);

            int screenSizeX = gd.Viewport.Width;
            int screenSizeY = gd.Viewport.Height;

            // draw continue message
            rect.Width = textureContinue.Width;
            rect.Height = textureContinue.Height;
            rect.Y = screenSizeY - rect.Height - 60;
            rect.X = screenSizeX / 2 - rect.Width / 2;
            screenManager.DrawTexture(textureContinue, rect,
                Color.White, BlendState.AlphaBlend);

            // deaw winning player number
            rect.Width = texturePlayerWin.Width;
            rect.Height = texturePlayerWin.Height;
            rect.Y = 20;
            rect.X = screenSizeX / 2 - rect.Width / 2;
            screenManager.DrawTexture(texturePlayerWin, rect,
                Color.White, BlendState.AlphaBlend);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Load your graphics content.
        /// </summary>
        protected override void LoadContent()
        {
            font = new FontManager(graphics.GraphicsDevice);
            screen = new ScreenManager(this, font, game);

            font.LoadContent(Content);
            game.LoadContent(graphics.GraphicsDevice, Content);
            screen.LoadContent(graphics.GraphicsDevice, Content);
        }
Ejemplo n.º 3
0
        // draw 2D gui
        public override void Draw2D(GraphicsDevice gd, FontManager font)
        {
            if (gd == null)
            {
                throw new ArgumentNullException("gd");
            }

            // screen rect
            Rectangle rect = new Rectangle(gd.Viewport.X, gd.Viewport.Y,
                            gd.Viewport.Width, gd.Viewport.Height);

            // draw lens flare texture
            screenManager.DrawTexture(textureLens, rect,
                Color.White, BlendState.Additive);

            // draw logo texture
            screenManager.DrawTexture(textureLogo, rect,
                Color.White, BlendState.AlphaBlend);

            // draw menu itens
            int Y = rect.Height - 200;
            for (int i = 0; i < NumberMenuItems; i++)
            {
                // if item selected
                if (i == menuSelection)
                {
                    rect.X = 540;
                    rect.Y = Y;
                    rect.Width = textureMenuHover[i].Width;
                    rect.Height = textureMenuHover[i].Height;
                    screenManager.DrawTexture(textureMenuHover[i], rect,
                        Color.White, BlendState.AlphaBlend);

                    // draw cursor left of selected item
                    DrawCursor(rect.X - 60, rect.Y + 19);

                    Y += 50;
                }
                else // item not selected
                {
                    rect.X = 540;
                    rect.Y = Y;
                    rect.Width = textureMenu[i].Width;
                    rect.Height = textureMenu[i].Height;

                    screenManager.DrawTexture(textureMenu[i], rect,
                        Color.White, BlendState.AlphaBlend);

                    Y += 40;
                }
            }
        }
Ejemplo n.º 4
0
        float backgroundTime = 0.0f;  // time for background animation used on menus

        // constructor
        public ScreenManager(ShipGameGame shipGame, FontManager font, GameManager game)
        {
            this.shipGame = shipGame;
            gameManager = game;
            fontManager = font;

            screens = new List<Screen>();
            inputManager = new InputManager();

            // add all screens
            screens.Add(new ScreenIntro(this, game));
            screens.Add(new ScreenHelp(this, game));
            screens.Add(new ScreenPlayer(this, game));
            screens.Add(new ScreenLevel(this, game));
            screens.Add(new ScreenGame(this, game));
            screens.Add(new ScreenEnd(this, game));

            // fade in to intro screen
            SetNextScreen(ScreenType.ScreenIntro,
                GameOptions.FadeColor, GameOptions.FadeTime);
            fade = fadeTime * 0.5f;
        }
Ejemplo n.º 5
0
        public override void Draw2D(GraphicsDevice gd, FontManager font)
        {
            if (gd == null)
            {
                throw new ArgumentNullException("gd");
            }

            int screenSizeX = gd.Viewport.Width;
            int screenSizeY = gd.Viewport.Height;

            Rectangle rect = new Rectangle(0, 0, 0, 0);

            // draw level screen shot
            rect.Width = levelShots[selection].Width;
            rect.Height = levelShots[selection].Height;
            rect.X = (screenSizeX - rect.Width) / 2;
            rect.Y = (screenSizeY - rect.Height) / 2 + 30;
            screenManager.DrawTexture(levelShots[selection], rect,
                Color.White, BlendState.AlphaBlend);

            // draw back and select buttons
            rect.Width = selectBack.Width;
            rect.Height = selectBack.Height;
            rect.X = (screenSizeX - rect.Width) / 2;
            rect.Y = 30;
            screenManager.DrawTexture(selectBack, rect,
                Color.White, BlendState.AlphaBlend);

            // draw change level text
            rect.Width = changeLevel.Width;
            rect.Height = changeLevel.Height;
            rect.X = (screenSizeX - rect.Width) / 2;
            rect.Y = screenSizeY - rect.Height - 30;
            screenManager.DrawTexture(changeLevel, rect,
                Color.White, BlendState.AlphaBlend);
        }
Ejemplo n.º 6
0
        // draw 2D gui
        public override void Draw2D(GraphicsDevice gd, FontManager font)
        {
            if (gd == null)
            {
                throw new ArgumentNullException("gd");
            }

            Rectangle rect = new Rectangle(0, 0, 0, 0);

            int screenSizeX = gd.Viewport.Width;
            int screenSizeY = gd.Viewport.Height;

            // draw controlls text aligned to top of screen
            rect.Width = textureControls.Width;
            rect.Height = textureControls.Height;
            rect.X = screenSizeX / 2 - rect.Width / 2;
            rect.Y = 40;
            screenManager.DrawTexture(textureControls, rect,
                Color.White, BlendState.AlphaBlend);

            // draw controller texture centered in screen
            rect.Width = textureDisplay.Width;
            rect.Height = textureDisplay.Height;
            rect.X = screenSizeX / 2 - rect.Width / 2;
            rect.Y = screenSizeY / 2 - rect.Height / 2 + 10;
            screenManager.DrawTexture(textureDisplay, rect,
                Color.White, BlendState.AlphaBlend);

            // draw continue message aligned to bottom of screen
            rect.Width = textureContinue.Width;
            rect.Height = textureContinue.Height;
            rect.X = screenSizeX / 2 - rect.Width / 2;
            rect.Y = screenSizeY - rect.Height - 60;
            screenManager.DrawTexture(textureContinue, rect,
                Color.White, BlendState.AlphaBlend);
        }
Ejemplo n.º 7
0
        public override void Draw2D(GraphicsDevice gd, FontManager font)
        {
            if (gd == null)
            {
                throw new ArgumentNullException("gd");
            }

            Rectangle rect = new Rectangle(0, 0, 0, 0);

            int screenSizeX = gd.Viewport.Width;
            int screenSizeY = gd.Viewport.Height;

            // if single player mode
            if (gameManager.GameMode == GameMode.SinglePlayer)
            {
                rect.Width = textureSelectBack.Width;
                rect.Height = textureSelectBack.Height;
                rect.X = screenSizeX / 2 - rect.Width / 2;
                rect.Y = 50;
                if (confirmed[0])
                {
                    rect.Width = textureSelectCancel.Width;
                    rect.Height = textureSelectCancel.Height;
                    screenManager.DrawTexture(textureSelectCancel, rect,
                        Color.White, BlendState.AlphaBlend);
                }
                else
                    screenManager.DrawTexture(textureSelectBack, rect,
                        Color.White, BlendState.AlphaBlend);

                rect.Width = textureInvertYCheck.Width;
                rect.Height = textureInvertYCheck.Height;
                rect.Y = screenSizeY - rect.Height - 30;
                rect.X = screenSizeX / 2 - rect.Width / 2;
                if ((invertY & 1) == 0)
                    screenManager.DrawTexture(textureInvertYUncheck, rect,
                        Color.White, BlendState.AlphaBlend);
                else
                    screenManager.DrawTexture(textureInvertYCheck, rect,
                        Color.White, BlendState.AlphaBlend);

                rect.Width = textureChangeShip.Width;
                rect.Height = textureChangeShip.Height;
                rect.X = screenSizeX / 5 - rect.Width / 2;
                rect.Y = 60;
                screenManager.DrawTexture(textureChangeShip, rect,
                    Color.White, BlendState.AlphaBlend);

                rect.Width = textureRotateShip.Width;
                rect.Height = textureRotateShip.Height;
                rect.X = screenSizeX * 4 / 5 - rect.Width / 2;
                rect.Y = 60;
                screenManager.DrawTexture(textureRotateShip, rect,
                    Color.White, BlendState.AlphaBlend);
            }
            else // if multi player mode
            {
                rect.Width = textureChangeShip.Width;
                rect.Height = textureChangeShip.Height;
                rect.X = (screenSizeX - rect.Width) / 2;
                rect.Y = 40;
                screenManager.DrawTexture(textureChangeShip, rect,
                    Color.White, BlendState.AlphaBlend);

                rect.Width = textureRotateShip.Width;
                rect.Height = textureRotateShip.Height;
                rect.X = (screenSizeX - rect.Width) / 2;
                rect.Y = 40 + textureChangeShip.Height;
                screenManager.DrawTexture(textureRotateShip, rect,
                    Color.White, BlendState.AlphaBlend);

                rect.Width = textureInvertYCheck.Width;
                rect.Height = textureInvertYCheck.Height;
                rect.Y = screenSizeY - rect.Height - 30;
                rect.X = screenSizeX / 4 - rect.Width / 2;
                if ((invertY & 1) == 0)
                    screenManager.DrawTexture(textureInvertYUncheck, rect,
                        Color.White, BlendState.AlphaBlend);
                else
                    screenManager.DrawTexture(textureInvertYCheck, rect,
                        Color.White, BlendState.AlphaBlend);
                rect.X = screenSizeX * 3 / 4 - rect.Width / 2;
                if ((invertY & 2) == 0)
                    screenManager.DrawTexture(textureInvertYUncheck, rect,
                        Color.White, BlendState.AlphaBlend);
                else
                    screenManager.DrawTexture(textureInvertYCheck, rect,
                        Color.White, BlendState.AlphaBlend);

                rect.Width = textureSelectBack.Width;
                rect.Height = textureSelectBack.Height;
                rect.X = screenSizeX / 8 - rect.Width / 2;
                rect.Y = 40;
                if (confirmed[0])
                {
                    rect.Width = textureSelectCancel.Width;
                    rect.Height = textureSelectCancel.Height;
                    screenManager.DrawTexture(textureSelectCancel, rect,
                        Color.White, BlendState.AlphaBlend);
                }
                else
                    screenManager.DrawTexture(textureSelectBack, rect,
                        Color.White, BlendState.AlphaBlend);
                rect.Width = textureSelectBack.Width;
                rect.Height = textureSelectBack.Height;
                rect.X = screenSizeX * 7 / 8 - rect.Width / 2;
                rect.Y = 40;
                if (confirmed[1])
                {
                    rect.Width = textureSelectCancel.Width;
                    rect.Height = textureSelectCancel.Height;
                    screenManager.DrawTexture(textureSelectCancel, rect,
                        Color.White, BlendState.AlphaBlend);
                }
                else
                    screenManager.DrawTexture(textureSelectBack, rect,
                        Color.White, BlendState.AlphaBlend);
            }
        }
Ejemplo n.º 8
0
 // draw 2D gui
 public override void Draw2D(GraphicsDevice gd, FontManager font)
 {
     // draw 2D game gui
     gameManager.Draw2D(font);
 }
Ejemplo n.º 9
0
 // draw 2D gui
 public override void Draw2D(GraphicsDevice gd, FontManager font)
 {
     // draw 2D game gui
     gameManager.Draw2D(font);
 }
Ejemplo n.º 10
0
 // called to draw the 2D info text and hud
 public abstract void Draw2D(GraphicsDevice gd, FontManager font);
Ejemplo n.º 11
0
        public override void Draw2D(GraphicsDevice gd, FontManager font)
        {
            if (gd == null)
            {
                throw new ArgumentNullException("gd");
            }

            Rectangle rect = new Rectangle(0, 0, 0, 0);

            int screenSizeX = gd.Viewport.Width;
            int screenSizeY = gd.Viewport.Height;

            // if single player mode
            if (gameManager.GameMode == GameMode.SinglePlayer)
            {
                rect.Width  = textureSelectBack.Width;
                rect.Height = textureSelectBack.Height;
                rect.X      = screenSizeX / 2 - rect.Width / 2;
                rect.Y      = 50;
                if (confirmed[0])
                {
                    rect.Width  = textureSelectCancel.Width;
                    rect.Height = textureSelectCancel.Height;
                    screenManager.DrawTexture(textureSelectCancel, rect,
                                              Color.White, BlendState.AlphaBlend);
                }
                else
                {
                    screenManager.DrawTexture(textureSelectBack, rect,
                                              Color.White, BlendState.AlphaBlend);
                }

                rect.Width  = textureInvertYCheck.Width;
                rect.Height = textureInvertYCheck.Height;
                rect.Y      = screenSizeY - rect.Height - 30;
                rect.X      = screenSizeX / 2 - rect.Width / 2;
                if ((invertY & 1) == 0)
                {
                    screenManager.DrawTexture(textureInvertYUncheck, rect,
                                              Color.White, BlendState.AlphaBlend);
                }
                else
                {
                    screenManager.DrawTexture(textureInvertYCheck, rect,
                                              Color.White, BlendState.AlphaBlend);
                }

                rect.Width  = textureChangeShip.Width;
                rect.Height = textureChangeShip.Height;
                rect.X      = screenSizeX / 5 - rect.Width / 2;
                rect.Y      = 60;
                screenManager.DrawTexture(textureChangeShip, rect,
                                          Color.White, BlendState.AlphaBlend);

                rect.Width  = textureRotateShip.Width;
                rect.Height = textureRotateShip.Height;
                rect.X      = screenSizeX * 4 / 5 - rect.Width / 2;
                rect.Y      = 60;
                screenManager.DrawTexture(textureRotateShip, rect,
                                          Color.White, BlendState.AlphaBlend);
            }
            else // if multi player mode
            {
                rect.Width  = textureChangeShip.Width;
                rect.Height = textureChangeShip.Height;
                rect.X      = (screenSizeX - rect.Width) / 2;
                rect.Y      = 40;
                screenManager.DrawTexture(textureChangeShip, rect,
                                          Color.White, BlendState.AlphaBlend);

                rect.Width  = textureRotateShip.Width;
                rect.Height = textureRotateShip.Height;
                rect.X      = (screenSizeX - rect.Width) / 2;
                rect.Y      = 40 + textureChangeShip.Height;
                screenManager.DrawTexture(textureRotateShip, rect,
                                          Color.White, BlendState.AlphaBlend);

                rect.Width  = textureInvertYCheck.Width;
                rect.Height = textureInvertYCheck.Height;
                rect.Y      = screenSizeY - rect.Height - 30;
                rect.X      = screenSizeX / 4 - rect.Width / 2;
                if ((invertY & 1) == 0)
                {
                    screenManager.DrawTexture(textureInvertYUncheck, rect,
                                              Color.White, BlendState.AlphaBlend);
                }
                else
                {
                    screenManager.DrawTexture(textureInvertYCheck, rect,
                                              Color.White, BlendState.AlphaBlend);
                }
                rect.X = screenSizeX * 3 / 4 - rect.Width / 2;
                if ((invertY & 2) == 0)
                {
                    screenManager.DrawTexture(textureInvertYUncheck, rect,
                                              Color.White, BlendState.AlphaBlend);
                }
                else
                {
                    screenManager.DrawTexture(textureInvertYCheck, rect,
                                              Color.White, BlendState.AlphaBlend);
                }

                rect.Width  = textureSelectBack.Width;
                rect.Height = textureSelectBack.Height;
                rect.X      = screenSizeX / 8 - rect.Width / 2;
                rect.Y      = 40;
                if (confirmed[0])
                {
                    rect.Width  = textureSelectCancel.Width;
                    rect.Height = textureSelectCancel.Height;
                    screenManager.DrawTexture(textureSelectCancel, rect,
                                              Color.White, BlendState.AlphaBlend);
                }
                else
                {
                    screenManager.DrawTexture(textureSelectBack, rect,
                                              Color.White, BlendState.AlphaBlend);
                }
                rect.Width  = textureSelectBack.Width;
                rect.Height = textureSelectBack.Height;
                rect.X      = screenSizeX * 7 / 8 - rect.Width / 2;
                rect.Y      = 40;
                if (confirmed[1])
                {
                    rect.Width  = textureSelectCancel.Width;
                    rect.Height = textureSelectCancel.Height;
                    screenManager.DrawTexture(textureSelectCancel, rect,
                                              Color.White, BlendState.AlphaBlend);
                }
                else
                {
                    screenManager.DrawTexture(textureSelectBack, rect,
                                              Color.White, BlendState.AlphaBlend);
                }
            }
        }
Ejemplo n.º 12
0
 // called to draw the 2D info text and hud
 public abstract void Draw2D(GraphicsDevice gd, FontManager font);
Ejemplo n.º 13
0
        /// <summary>
        /// Draw the 2D game screen
        /// </summary>
        public void Draw2D(FontManager font)
        {
            if (font == null)
            {
                throw new ArgumentNullException("font");
            }

            Rectangle rect = font.ScreenRectangle;

            // if in single player mode
            if (gameMode == GameMode.SinglePlayer)
            {
                if (players[0].IsAlive)
                {
                    // draw hud 
                    DrawHud(font, rect, players[0].Bars, 70, 120,
                        players[0].Camera3rdPerson == false);

                    // draw missile count
                    font.DrawText(FontType.ArialMedium,
                        players[0].MissileCount.ToString(),
                        new Vector2(rect.Right - 138, rect.Bottom - 120),
                        Color.LightCyan);
                }

                // draw damage indicator
                Color DamageColor = players[0].DamageColor;
                if (DamageColor.A > 0)
                    font.DrawTexture(damageTexture, rect,
                        DamageColor, BlendState.AlphaBlend);
            }
            else
            {
                // multiplayer half horizontal screen
                rect.Width /= 2;

                // if player is alive
                if (players[0].IsAlive)
                {
                    // draw hud 
                    DrawHud(font, rect, players[0].Bars, 80, 100,
                        players[0].Camera3rdPerson == false);

                    // draw missile count
                    font.DrawText(FontType.ArialMedium,
                        players[0].MissileCount.ToString(),
                        new Vector2(rect.Right - 138, rect.Bottom - 125),
                        Color.LightCyan);
                }

                // draw damage indicator
                Color damageColor = players[0].DamageColor;
                if (damageColor.A > 0)
                    font.DrawTexture(damageTexture, rect,
                        damageColor, BlendState.AlphaBlend);

                // second player on second horizontal half
                rect.X += rect.Width;

                // if player is alive
                if (players[1].IsAlive)
                {
                    // draw hud
                    DrawHud(font, rect, players[1].Bars, 80, 100,
                        players[1].Camera3rdPerson == false);

                    // draw missile count
                    font.DrawText(FontType.ArialMedium,
                        players[1].MissileCount.ToString(),
                        new Vector2(rect.Right - 138, rect.Bottom - 125),
                        Color.LightCyan);
                }

                // draw damage indicator
                damageColor = players[1].DamageColor;
                if (damageColor.A > 0)
                    font.DrawTexture(damageTexture, rect,
                        damageColor, BlendState.AlphaBlend);

                // draw score
                font.DrawText(FontType.ArialLarge,
                    players[0].Score.ToString(),
                    new Vector2(rect.Width / 2 - 20, 20),
                    Color.LightCyan);
                font.DrawText(FontType.ArialLarge,
                    players[1].Score.ToString(),
                    new Vector2(rect.Width * 3 / 2 - 20, 20),
                    Color.LightCyan);
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Draw the HUD interface
        /// </summary>
        void DrawHud(FontManager font, Rectangle rect, Vector3 bars,
            int barsLeft, int barsWidth, bool crosshair)
        {
            Rectangle r = new Rectangle(0, 0, 0, 0);

            // if crosshair enabled
            if (crosshair)
            {
                // draw crosshair hud texture
                r.X = rect.X + (rect.Width - hudCrosshair.Width) / 2;
                r.Y = rect.Y + (rect.Height - hudCrosshair.Height) / 2;
                r.Width = hudCrosshair.Width;
                r.Height = hudCrosshair.Height;
                font.DrawTexture(hudCrosshair, r,
                    Color.White, BlendState.AlphaBlend);
            }

            // draw score hud texture
            r.X = rect.X + (rect.Width - hudScore.Width) / 2;
            r.Y = rect.Y;
            r.Width = hudScore.Width;
            r.Height = hudScore.Height;
            font.DrawTexture(hudScore, r, Color.White, BlendState.AlphaBlend);

            // draw missile hud texture
            r.X = rect.X + rect.Width - hudMissile.Width;
            r.Y = rect.Y + rect.Height - hudMissile.Height;
            r.Width = hudMissile.Width;
            r.Height = hudMissile.Height;
            font.DrawTexture(hudMissile, r, Color.White, BlendState.AlphaBlend);

            // draw energy hud texture
            r.X = rect.X;
            r.Y = rect.Y + rect.Height - hudEnergy.Height;
            r.Width = hudEnergy.Width;
            r.Height = hudEnergy.Height;
            font.DrawTexture(hudEnergy, r, Color.White, BlendState.AlphaBlend);

            // get hud bars
            Rectangle s = new Rectangle(0, 0, hudBars.Width, hudBars.Height);

            // draw the energy bar
            r.Width = s.Width = barsLeft + (int)(barsWidth * bars.X);
            font.DrawTexture(hudBars, r, s, Color.Red, BlendState.Additive);

            // draw the shield bar
            r.Width = s.Width = barsLeft + (int)(barsWidth * bars.Y);
            font.DrawTexture(hudBars, r, s, Color.Green, BlendState.Additive);

            // draw the boost bar
            r.Width = s.Width = barsLeft + (int)(barsWidth * bars.Z);
            font.DrawTexture(hudBars, r, s, Color.Blue, BlendState.Additive);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Unload your graphics content.
        /// </summary>
        protected override void UnloadContent()
        {
            screen.UnloadContent();
            game.UnloadContent();
            font.UnloadContent();

            screen = null;
            font = null;
        }