Ejemplo n.º 1
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)
        {
            GraphicsDevice.Clear(Color.Black);

            // TODO: Add your drawing code here


            spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, cameraMatrix);
            foreach (var p in mapLevel1)
            {
                spriteBatch.Draw(p.textureTuile, p.Position, Color.White);
            }
            //foreach (var w in waterTiles)
            //{
            //    spriteBatch.Draw(w.textureTuile, w.Position, Color.White);
            //}

            if (player.Active == true)
            {
                player.Draw(spriteBatch);
                if (kstate.IsKeyDown(Keys.Up))
                {
                    player.PlayerTexture = playerTextureback;
                }
                if (kstate.IsKeyDown(Keys.Down))
                {
                    player.PlayerTexture = playerTexturefront;
                }
                if (kstate.IsKeyDown(Keys.Left))
                {
                    player.PlayerTexture = playerTextureleft;
                }
                if (kstate.IsKeyDown(Keys.Right))
                {
                    player.PlayerTexture = playerTextureright;
                }

                for (int i = 0; i < ennemis.Count; i++)
                {
                    ennemis[i].Draw(spriteBatch);
                }

                foreach (var t in objets)
                {
                    t.Draw(spriteBatch);
                }

                foreach (var proj in projectiles)
                {
                    proj.Draw(spriteBatch);
                }
            }
            spriteBatch.End();

            spriteBatch.Begin();
            spriteBatch.Draw(inventaireTexture, new Rectangle(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Height - 128, GraphicsDevice.Viewport.TitleSafeArea.Width, 128), Color.Brown);
            foreach (var o in objetsInventaire)
            {
                spriteBatch.Draw(o.ObjetTexture, o.ObjetRectangle, Color.White);
                if (o.isVictory == true)
                {
                    spriteBatch.DrawString(victoryFont, "VICTOIRE ! un bon repas vous attend !", new Vector2(GraphicsDevice.Viewport.TitleSafeArea.Width / 2, GraphicsDevice.Viewport.TitleSafeArea.Height - 64), Color.Black);
                    player.Active = false;
                }
            }
            spriteBatch.DrawString(victoryFont, "Nourriture : " + nombreItems.ToString() + "/" + objets[0].maxObjet.ToString(), new Vector2(GraphicsDevice.Viewport.TitleSafeArea.Width - 160, GraphicsDevice.Viewport.TitleSafeArea.Height - 64), Color.Black);
            spriteBatch.DrawString(victoryFont, "HP : " + player.Health.ToString(), new Vector2(GraphicsDevice.Viewport.TitleSafeArea.Width - 160, GraphicsDevice.Viewport.TitleSafeArea.Height - 120), Color.ForestGreen);
            if (isDefeat == true)
            {
                spriteBatch.DrawString(victoryFont, "DEFAITE ! Va falloir recommencer !", new Vector2(GraphicsDevice.Viewport.TitleSafeArea.Width / 2, GraphicsDevice.Viewport.TitleSafeArea.Height - 64), Color.Black);
            }
            spriteBatch.End();
            base.Draw(gameTime);
        }