Beispiel #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);


            // 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();
        }
Beispiel #2
0
        // Draw
        public static void Draw(SkyBox skyBox, SpriteBatch spriteBatch, GraphicsDevice graphics)
        {
            // Draw skybox
            skyBox.Draw(camera.View, camera.Projection, ((ArcBallCamera)camera).Position);

            // Start SpriteBatch to draw 2D 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);

            // Check if player1's controller is connected and draw text accordingly
            if (GamePad.GetState(PlayerIndex.One).IsConnected)
            {
                spriteBatch.DrawString(menuFont, " Controller 1 Conmnected", new Vector2(450, 640), new Color(224, 96, 26));
            }
            else
            {
                spriteBatch.DrawString(menuFont, "Controller 1 Disconnected", new Vector2(440, 640), new Color(224, 30, 00));
            }

            // Check if player2's controller is connected and draw text accordingly
            if (GamePad.GetState(PlayerIndex.Two).IsConnected)
            {
                spriteBatch.DrawString(menuFont, " Controller 2 Conmnected ", new Vector2(450, 680), new Color(224, 96, 26));
            }
            else
            {
                spriteBatch.DrawString(menuFont, "Controller 2 Disconnected", new Vector2(440, 680), new Color(224, 30, 00));
            }


            // Draw buttons
            buttonManager.Draw(spriteBatch);

            spriteBatch.End();

            // Reset states changed by spritebatch to draw 3D correctly again
            graphics.BlendState        = BlendState.Opaque;
            graphics.DepthStencilState = DepthStencilState.Default;

            // Draw ship
            ship.Draw(camera.View, camera.Projection, ((ArcBallCamera)camera).Position);
        }
Beispiel #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();
        }