Exemplo n.º 1
0
        // Draw
        public static void Draw(PlayerShip player1, PlayerShip player2, SkyBox skyBox, SpriteBatch spriteBatch)
        {
            // Draw skybox
            skyBox.Draw(camera.View, camera.Projection, ((ArcBallCamera)camera).Position);


            // Start spritebatch to draw menu components
            spriteBatch.Begin();

            // Draw transparent background
            spriteBatch.Draw(bg, new Rectangle(0, 0, 1920, 1080), Color.White);

            // Draw logo
            spriteBatch.Draw(logo, new Rectangle(483, 20, logo.Width, logo.Height), Color.White);

            // Draw a win text depending on who won
            if (player1.Kills >= Game1.WinLimit && player2.Kills >= Game1.WinLimit)
            {
                spriteBatch.DrawString(menuFont, "It's a tie!", new Vector2(540, 360), new Color(224, 96, 26));
            }
            else if (player1.Kills >= Game1.WinLimit)
            {
                spriteBatch.DrawString(menuFont, "Player 1 Wins", new Vector2(535, 360), new Color(224, 96, 26));
            }
            else if (player2.Kills >= Game1.WinLimit)
            {
                spriteBatch.DrawString(menuFont, "Player 2 Wins", new Vector2(535, 360), new Color(224, 96, 26));
            }


            // Draw game stats and scoreboard

            // Draw "titles" for each columb/row
            spriteBatch.DrawString(menuFont, "Stats:", new Vector2(420, 420), new Color(224, 96, 26));
            spriteBatch.DrawString(menuFont, "Kills", new Vector2(580, 420), new Color(224, 96, 26));
            spriteBatch.DrawString(menuFont, "Deaths", new Vector2(740, 420), new Color(224, 96, 26));

            spriteBatch.DrawString(menuFont, "Player 1", new Vector2(420, 480), new Color(224, 96, 26));
            spriteBatch.DrawString(menuFont, "Player 2", new Vector2(420, 540), new Color(224, 96, 26));

            // Draw actual stats (number of kills/deaths/etc)
            spriteBatch.DrawString(menuFont, player1.Kills.ToString(), new Vector2(610, 480), new Color(224, 96, 26));
            spriteBatch.DrawString(menuFont, player1.Deaths.ToString(), new Vector2(770, 480), new Color(224, 96, 26));

            spriteBatch.DrawString(menuFont, player2.Kills.ToString(), new Vector2(610, 540), new Color(224, 96, 26));
            spriteBatch.DrawString(menuFont, player2.Deaths.ToString(), new Vector2(770, 540), new Color(224, 96, 26));

            // Draw scoreboard texture
            spriteBatch.Draw(scoreboard, new Vector2(419, 420), Color.White);


            // Draw return to menu text
            spriteBatch.DrawString(menuFont, "Press A to return to main menu", new Vector2(400, 660), new Color(224, 96, 26));
            spriteBatch.End();
        }
Exemplo n.º 2
0
        // Draw
        public static void Draw(PlayerShip player1, PlayerShip player2, SkyBox skyBox, SpriteBatch spriteBatch)
        {
            // Draw skybox
            skyBox.Draw(camera.View, camera.Projection, ((ArcBallCamera)camera).Position);


            // Draw menu items
            spriteBatch.Begin();

            // Draw transparent background
            spriteBatch.Draw(bg, new Rectangle(0, 0, 1920, 1080), Color.White);

            // Draw controller texture
            spriteBatch.Draw(controller, new Rectangle(344, 50, controller.Width, controller.Height), Color.White);

            // Draw text explaining the game play
            spriteBatch.DrawString(menuFont, "Watch your shields and don't let your hull reach 0%", new Vector2(260, 450), new Color(224, 96, 26));

            spriteBatch.DrawString(menuFont, "Avoid collisions", new Vector2(510, 490), new Color(224, 96, 26));

            spriteBatch.DrawString(menuFont, "First player to gain " + Game1.WinLimit.ToString() + " kills wins", new Vector2(397, 530), new Color(224, 96, 26));

            spriteBatch.DrawString(menuFont, "Press F To toggle fullscreen", new Vector2(420, 570), new Color(224, 96, 26));

            // Draw what each button on the controller texture does
            spriteBatch.DrawString(menuFont, "Thrust/Strafe", new Vector2(120, 167), new Color(224, 96, 26));

            spriteBatch.DrawString(menuFont, "Ascend", new Vector2(235, 95), new Color(224, 96, 26));
            spriteBatch.DrawString(menuFont, "Descend", new Vector2(950, 95), new Color(224, 96, 26));

            spriteBatch.DrawString(menuFont, "Fire", new Vector2(950, 67), new Color(224, 96, 26));

            spriteBatch.DrawString(menuFont, "Brake", new Vector2(950, 167), new Color(224, 96, 26));

            spriteBatch.DrawString(menuFont, "Menu select", new Vector2(950, 197), new Color(224, 96, 26));

            spriteBatch.DrawString(menuFont, "Pitch/Yaw", new Vector2(950, 232), new Color(224, 96, 26));

            spriteBatch.DrawString(menuFont, "Return to main menu", new Vector2(950, 40), new Color(224, 96, 26));

            spriteBatch.DrawString(menuFont, "Menu up", new Vector2(217, 220), new Color(224, 96, 26));
            spriteBatch.DrawString(menuFont, "Menu down", new Vector2(190, 257), new Color(224, 96, 26));


            // Draw buttons
            buttonManager.Draw(spriteBatch);

            spriteBatch.End();
        }
Exemplo n.º 3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here

            // Render targets
            RenderTargetTop = new RenderTarget2D(
                GraphicsDevice,
                960,
                1080,
                false,
                GraphicsDevice.PresentationParameters.BackBufferFormat,
                DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents
                );
            RenderTargetBottom = new RenderTarget2D(
                GraphicsDevice,
                960,
                1080,
                false,
                GraphicsDevice.PresentationParameters.BackBufferFormat,
                DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents
                );
            RenderTargetFullscreen = new RenderTarget2D(
                GraphicsDevice,
                1920,
                1080,
                false,
                GraphicsDevice.PresentationParameters.BackBufferFormat,
                DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents
                );

            // Load lighting effect and set up material. Give material's color variables some values
            ShipMaterial = new LightningMaterial();
            ShipMaterial.AmbientColor = Color.Red.ToVector3() * .15f;
            ShipMaterial.LightColor   = Color.White.ToVector3() * .85f;
            SimpleEffect = Content.Load <Effect>("Effects/LightingEffect");

            // SkyBox
            skyBox = new SkyBox(Content, GraphicsDevice, Content.Load <TextureCube>("Models/clouds"));

            // Static class menus
            MainMenu.LoadContent(Content, GraphicsDevice);
            GameOver.LoadContent(Content, GraphicsDevice);
            Credits.LoadContent(Content, GraphicsDevice);
            Tutorial.LoadContent(Content, GraphicsDevice);

            // Load Ship models for both players
            CustomModel ship1 = new CustomModel(Content.Load <Model>("Models/Ship"), Vector3.Zero, Vector3.Zero, new Vector3(1f), Vector3.Zero, Vector3.Zero, GraphicsDevice);
            CustomModel ship2 = new CustomModel(Content.Load <Model>("Models/Ship"), Vector3.Zero, Vector3.Zero, new Vector3(1f), Vector3.Zero, Vector3.Zero, GraphicsDevice);
            // Load cockpit models for both players
            CustomModel cockpit1 = new CustomModel(Content.Load <Model>("Models/Cockpit"), Vector3.Zero, Vector3.Zero, new Vector3(1f), Vector3.Zero, Vector3.Zero, GraphicsDevice);
            CustomModel cockpit2 = new CustomModel(Content.Load <Model>("Models/Cockpit"), Vector3.Zero, Vector3.Zero, new Vector3(1f), Vector3.Zero, Vector3.Zero, GraphicsDevice);

            // Set models' effect
            ship1.SetModelEffect(SimpleEffect, true);
            ship2.SetModelEffect(SimpleEffect, true);

            // Set models' material
            ship1.Material = ShipMaterial;
            ship2.Material = ShipMaterial;

            // BulletManagers
            player1bulletManager = new BulletManager(Content.Load <Model>("Models/bullet"), 3000);
            player2bulletManager = new BulletManager(Content.Load <Model>("Models/bullet"), 3000);
            // Create player ships and assign controllers
            player1Ship = new PlayerShip(ship1, cockpit1, player1bulletManager, Content.Load <Texture2D>("Textures/crosshair"), Content.Load <Texture2D>("Textures/marker"), Content.Load <Texture2D>("Textures/centerMarker1"), Content.Load <Texture2D>("Textures/centerMarker1"), new Vector3(0, 0, -150), new Vector3(0, 0, 0), PlayerIndex.One);
            player2Ship = new PlayerShip(ship2, cockpit2, player2bulletManager, Content.Load <Texture2D>("Textures/crosshair"), Content.Load <Texture2D>("Textures/marker"), Content.Load <Texture2D>("Textures/centerMarker1"), Content.Load <Texture2D>("Textures/centerMarker1"), new Vector3(0, 30, 150), new Vector3(0, MathHelper.Pi, 0), PlayerIndex.Two);
            // Player's cameras
            cameraPlayer1 = new CockpitCamera(new Vector3(0, 3.1f, -10), new Vector3(0, 3, 0), Vector3.Zero, GraphicsDevice, 8 / 9f);
            cameraPlayer2 = new CockpitCamera(new Vector3(0, 3, -10), new Vector3(0, 3, 0), Vector3.Zero, GraphicsDevice, 8 / 9f);

            // Load asteroid field
            asteroidField = new AsteroidField(Content.Load <Model>("Models/asteroid"), 10);

            // CollisionsManager
            collisionsManager = new CollisionsManager(player1Ship, player2Ship, asteroidField);

            // Load font used for HUD
            HudFont = Content.Load <SpriteFont>("Fonts/digitaldream");

            // Get mouseState to prevent potential error with variable beeing null
            lastMouseState = Mouse.GetState();

            // Load sounds
            SoundManager.LoadContent(Content);

            // Update input manager once before game start to prevent possible gamepad state == null error
            InputManager.Update();
        }