Ejemplo n.º 1
0
        /*  public void ChangeGameState(GameState state)
         * {
         *
         *
         * }
         * public enum GameState { START, PLAY, END }*/

        /// <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)
        {
            Matrix camera1 = camera.GetTransform();

            GraphicsDevice.Clear(Color.CornflowerBlue);
            screenScale = camera.GetScreenScale(graphicsDevice);
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, null, null, null, camera1 * Matrix.CreateScale(screenScale));

            spikesTrap.Draw(spriteBatch);
            spriteBatch.Draw(ecirBarLife, ecir.BarLifeEcir(), Color.Red);
            if (zombie != null)
            {
                spriteBatch.Draw(zombieBarLife, zombie.ZombieBarLife(), zombie.ColorBar());           //se o zombie não for destruido desanha a bar life
            }
            terrain1.Draw(spriteBatch);
            spikesTrap.Draw(spriteBatch);
            hollowKnight.Draw(spriteBatch);
            stairs.Draw(spriteBatch);
            ogre.Draw(spriteBatch);
            if (!ecir.EcirDestroy())
            {
                spriteBatch.Draw(ecir.Texture, ecir.Rectangle, ecir.EcirColor());
            }
            //  if(zombie!=null)if (!zombie.DestroyZombie()) spriteBatch.Draw(zombie.Texture, zombie.Rectangle, zombie.ZombieColor()); else { zombie = null; }// se o zombie não for destruido e levar dano muda de cor quando a vida chagar a 0 é destruido
            if (zombie != null)
            {
                if (!zombie.DestroyZombie())
                {
                    spriteBatch.Draw(zombie.Texture, zombie.Rectangle, null, zombie.ZombieColor(), 0, new Vector2(zombie.Rectangle.Width / 2, zombie.Rectangle.Height / 2), zombie.SpriteEffect, 0f);
                }
            }
            skeleton.Draw(spriteBatch);
            fireBall.Draw(spriteBatch);
            if (pause == true)
            {
                MenuPause.Draw(spriteBatch);
            }

            spriteBatch.End();

            // TODO: Add your drawing code here

            base.Draw(gameTime);
        }
Ejemplo n.º 2
0
        public void Draw(SpriteBatch spriteBatch, NetworkManager networkManager)
        {
            spriteBatch.Draw(AssetManager.stoneTiles, Vector2.Zero, Color.White);
            lava.Draw(spriteBatch);

            foreach (Obstacle obstacle in obstacles)
            {
                obstacle.Draw(spriteBatch);
            }
            foreach (var player in networkManager.Players)
            {
                if (player.Username != networkManager.Username && player != null)
                {
                    Rectangle source = new Rectangle(player.Animation.XRecPos, player.Animation.YRecPos, player.Animation.Width, player.Animation.Height);


                    if (player.Health > 0)
                    {
                        SpriteEffects spritEffect;

                        if (player.OrbiterRotation >= 1.53269 || player.OrbiterRotation <= -1.547545)
                        {
                            spritEffect = SpriteEffects.FlipHorizontally;
                        }
                        else
                        {
                            spritEffect = SpriteEffects.None;
                        }

                        switch (player.Type)
                        {
                        case Library.Player.ClassType.Wizard:
                            spriteBatch.Draw(AssetManager.WizardSpriteSheet, new Vector2(player.XPosition, player.YPosition), source,
                                             Color.White, 0f, Vector2.Zero, Game1.SCALE, spritEffect, 1.0f);
                            break;

                        case Library.Player.ClassType.Ogre:
                            spriteBatch.Draw(AssetManager.ogreSpriteSheet, new Vector2(player.XPosition, player.YPosition), source,
                                             Color.White, 0f, Vector2.Zero, Game1.SCALE, spritEffect, 1.0f);
                            break;

                        case Library.Player.ClassType.Huntress:
                            spriteBatch.Draw(AssetManager.HuntressSpriteSheet, new Vector2(player.XPosition, player.YPosition), source,
                                             Color.White, 0f, Vector2.Zero, Game1.SCALE, spritEffect, 1.0f);
                            break;

                        case Library.Player.ClassType.TimeTraveler:
                            spriteBatch.Draw(AssetManager.TimeTravelerSpriteSheet, new Vector2(player.XPosition, player.YPosition), source,
                                             Color.White, 0f, Vector2.Zero, Game1.SCALE, spritEffect, 1.0f);
                            break;

                        case Library.Player.ClassType.Knight:
                            spriteBatch.Draw(AssetManager.KnightSpriteSheet, new Vector2(player.XPosition, player.YPosition), source,
                                             Color.White, 0f, Vector2.Zero, Game1.SCALE, spritEffect, 1.0f);
                            break;
                        }

                        spriteBatch.DrawString(AssetManager.CooldownFont, $"{player.Username}", new Vector2(player.XPosition, player.YPosition - 5), Color.White);
                        spriteBatch.DrawString(AssetManager.CooldownFont, $"{player.Health}", new Vector2(player.XPosition, player.YPosition - 20), Color.White);
                    }


                    //spriteBatch.DrawString(font, player.Username, new Vector2(player.XPosition - 10, player.YPosition - 10), Color.Black);
                }
                else
                {
                    if (player.Health > 0)
                    {
                        if (this.player is Wizard)
                        {
                            Wizard tempPlayer = (Wizard)this.player;
                            tempPlayer.Draw(spriteBatch);
                        }
                        else if (this.player is Ogre)
                        {
                            Ogre tempPlayer = (Ogre)this.player;
                            tempPlayer.Draw(spriteBatch);
                        }
                        else if (this.player is Huntress)
                        {
                            Huntress tempPlayer = (Huntress)this.player;
                            tempPlayer.Draw(spriteBatch);
                        }
                        else if (this.player is Knight)
                        {
                            Knight tempPlayer = (Knight)this.player;
                            tempPlayer.Draw(spriteBatch);
                        }
                        else if (this.player is TimeTraveler)
                        {
                            TimeTraveler tempPlayer = (TimeTraveler)this.player;
                            tempPlayer.Draw(spriteBatch);
                        }

                        spriteBatch.DrawString(AssetManager.CooldownFont, $"{networkManager.Username}", new Vector2(player.XPosition, player.YPosition - 5), Color.White);
                        spriteBatch.DrawString(AssetManager.CooldownFont, $"{this.player.Health}", new Vector2(player.XPosition, player.YPosition - 20), Color.White);
                    }
                }
            }
        }