Beispiel #1
0
        // Methods
        public void Draw(SpriteBatch spriteBatch)
        {
            // Draw interactif game objects
            foreach (interactifGameObject GO in InteractifGO)
            {
                GO.Draw(spriteBatch);
            }

            // Draw rigid game objects
            foreach (rigidGameObject GO in RigidGO)
            {
                GO.Draw(spriteBatch);
            }
        }
Beispiel #2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            spriteBatch.Begin();
            // Draw the background (and clear the screen)
            spriteBatch.Draw(background, Global.screenRect, Color.White);

            // Draw the game objects
            foreach (GameObject GO in gameObjects)
            {
                GO.Draw();
            }
            spriteBatch.End();
            base.Draw(gameTime);
        }
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin(SpriteSortMode.Deferred,
                              BlendState.AlphaBlend, null, null, null, null, camera.Transform);

            NumberOfgameObejts = Effects.Count;
            foreach (GameObject GO in Effects)
            {
                GO.Draw(spriteBatch);
#if DEBUG
                DrawCollisionBox(GO);
#endif
            }

            foreach (GameObject GO in solidObejts)
            {
                GO.Draw(spriteBatch);
#if DEBUG
                DrawCollisionBox(GO);
#endif
            }

            foreach (GameObject go in gameObjects)
            {
                go.Draw(spriteBatch);
#if DEBUG
                DrawCollisionBox(go);
#endif
            }
            spriteBatch.End();
            spriteBatch.Begin();
            // load lvl 1
            if (levels == 1)
            {
                gameObjects.Clear();
                Effects.Clear();
                switch (cutScenemanager)
                {
                case 1:    // startscreen
                    spriteBatch.Draw(CutScene[5], new Rectangle(0, 0, 1280, 720), Color.White);
                    if (Keyboard.GetState().IsKeyDown(Keys.Enter) && timer > 1)
                    {
                        cutScenemanager += 1;
                        timer            = 0;
                    }
                    break;

                case 2:
                    spriteBatch.Draw(CutScene[0], new Rectangle(0, 0, 1280, 720), Color.White);
                    if (Keyboard.GetState().IsKeyDown(Keys.Enter) && timer > 1)
                    {
                        timer           = 0;
                        cutScenemanager = 0;
                        level1          = true;
                    }
                    break;

                default:
                    break;
                }
                if (Keyboard.GetState().IsKeyDown(Keys.Enter) && level1 == true)
                {
                    levels = 100;
                    level1 = true;
                    level  = new LevelManager(Content, 1);
                    gameObjects.Add(player = new Player(Content));
                    gameObjects.Add(sighte = new sighte(Content));
                    healthHold             = player.Health;
                    IsPlayer   = true;
                    healthHold = 1000;
                }
            }
            // load lvl 2

            if (levels == 2)
            {
                gameObjects.Clear();
                Effects.Clear();
                switch (cutScenemanager)
                {
                case 1:
                    spriteBatch.Draw(CutScene[1], new Rectangle(0, 0, 1280, 720), Color.White);
                    if (Keyboard.GetState().IsKeyDown(Keys.Enter) && timer > 1)
                    {
                        cutScenemanager += 1;
                        timer            = 0;
                    }
                    break;

                case 2:
                    spriteBatch.Draw(CutScene[2], new Rectangle(0, 0, 1280, 720), Color.White);

                    if (Keyboard.GetState().IsKeyDown(Keys.Enter) && timer > 1)
                    {
                        timer           = 0;
                        cutScenemanager = 0;
                        level2          = true;
                    }
                    break;

                default:
                    break;
                }
                if (Keyboard.GetState().IsKeyDown(Keys.Enter) && level2 == true)
                {
                    level = new LevelManager(Content, 2);
                    gameObjects.Add(player = new Player(Content, HavsMachinGun, HaveShotGun));
                    gameObjects.Add(sighte = new sighte(Content));
                    gametimer = new GameTimer();


                    healthHold = 1000;
                    levels     = 100;
                }
            }

            // load lvl 3
            if (levels == 3)
            {
                gameObjects.Clear();
                Effects.Clear();
                switch (cutScenemanager)
                {
                case 1:
                    spriteBatch.Draw(CutScene[3], new Rectangle(0, 0, 1280, 720), Color.White);
                    if (Keyboard.GetState().IsKeyDown(Keys.Enter) && timer > 1)
                    {
                        cutScenemanager += 1;
                        timer            = 0;
                    }
                    break;

                case 2:
                    spriteBatch.Draw(CutScene[4], new Rectangle(0, 0, 1280, 720), Color.White);

                    if (Keyboard.GetState().IsKeyDown(Keys.Enter) && timer > 1)
                    {
                        timer           = 0;
                        cutScenemanager = 0;
                        level3          = true;
                    }
                    break;

                default:
                    break;
                }
                if (Keyboard.GetState().IsKeyDown(Keys.Enter) && level3 == true)
                {
                    gameObjects.Clear();
                    Effects.Clear();
                    level = new LevelManager(Content, 3);
                    gameObjects.Add(sighte = new sighte(Content));
                    gameObjects.Add(player = new Player(Content, HavsMachinGun, HaveShotGun));
                    gametimer  = new GameTimer();
                    healthHold = 1000;

                    levels = 100;
                }
            }

            /// load lvl 4
            if (levels == 4)
            {
                gameObjects.Clear();
                Effects.Clear();
                switch (cutScenemanager)
                {
                case 1:
                    spriteBatch.Draw(CutScene[5], new Rectangle(0, 0, 1280, 720), Color.White);
                    if (Keyboard.GetState().IsKeyDown(Keys.Enter) && timer > 1)
                    {
                        cutScenemanager += 1;
                        timer            = 0;
                    }
                    break;

                case 2:
                    spriteBatch.Draw(CutScene[6], new Rectangle(0, 0, 1280, 720), Color.White);
                    if (Keyboard.GetState().IsKeyDown(Keys.Enter) && timer > 1)
                    {
                        timer           = 0;
                        cutScenemanager = 0;
                        level4          = true;
                    }
                    break;

                default:
                    break;
                }
                if (Keyboard.GetState().IsKeyDown(Keys.Enter) && level4 == true)
                {
                    gameObjects.Clear();
                    Effects.Clear();
                    level = new LevelManager(Content, 4);
                    gameObjects.Add(sighte = new sighte(Content));
                    gameObjects.Add(player = new Player(Content, HavsMachinGun, HaveShotGun));
                    gametimer = new GameTimer();

                    healthHold = 1000;
                    levels     = 100;
                }
            }


            // første slutning
            if (GameEnding1 == true)
            {
                gameObjects.Clear();
                Effects.Clear();
                switch (cutScenemanager)
                {
                case 1:
                    spriteBatch.Draw(CutScene[7], new Rectangle(0, 0, 1280, 720), Color.White);
                    if (Keyboard.GetState().IsKeyDown(Keys.Enter) && timer > 1)
                    {
                        cutScenemanager += 1;
                        timer            = 0;
                    }
                    break;

                case 2:
                    spriteBatch.Draw(CutScene[10], new Rectangle(0, 0, 1280, 720), Color.White);
                    if (Keyboard.GetState().IsKeyDown(Keys.Enter) && timer > 1)
                    {
                        timer = 0;

                        levels          = 1;
                        GameEnding1     = false;
                        cutScenemanager = 1;
                    }
                    break;

                default:
                    break;
                }
            }
            // anden spil slutning
            if (GameEnding2 == true)
            {
                gameObjects.Clear();
                Effects.Clear();
                switch (cutScenemanager)
                {
                case 1:
                    spriteBatch.Draw(CutScene[8], new Rectangle(0, 0, 1280, 720), Color.White);
                    if (Keyboard.GetState().IsKeyDown(Keys.Enter) && timer > 1)
                    {
                        cutScenemanager += 1;
                        timer            = 0;
                    }
                    break;

                case 2:
                    spriteBatch.Draw(CutScene[9], new Rectangle(0, 0, 1280, 720), Color.White);
                    if (Keyboard.GetState().IsKeyDown(Keys.Enter) && timer > 1)
                    {
                        timer = 0;

                        levels          = 1;
                        cutScenemanager = 1;
                        GameEnding2     = false;
                        HaveShotGun     = false;
                        HaveShotGun     = false;
                    }
                    break;

                default:
                    break;
                }
            }

            if (levels >= 1)
            {
                spriteBatch.DrawString(mag, $"Magasin:{player.Mag} and PlayerPosition X {player.playerPosition.X} and Y {player.playerPosition.Y}    ", new Vector2(90, 5), Color.Blue);
                spriteBatch.DrawString(WaveTimer, $"Health:{player.Health}", new Vector2(5, 5), Color.Blue);
                spriteBatch.DrawString(KillCount, $"KilleCount:{Kills}", new Vector2(1160, 5), Color.Red);
            }
            if (Player.IsAlive == false)
            {
                gameObjects.Clear();
                Effects.Clear();
                spriteBatch.Draw(backgroundImgEnd, new Rectangle(0, 0, 1280, 720), Color.White);
                if (Keyboard.GetState().IsKeyDown(Keys.Enter))
                {
                    timer           = 0;
                    cutScenemanager = 0;
                    levels          = 1;
                    cutScenemanager = 1;

                    healthHold     = 1000;
                    Player.IsAlive = true;
                    HaveShotGun    = false;
                    HaveShotGun    = false;
                }
            }



            spriteBatch.End();
            base.Draw(gameTime);
        }