Example #1
0
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Begin(SpriteSortMode.Deferred,
                              BlendState.AlphaBlend,
                              null,
                              null,
                              null,
                              null,
                              Camera.GetViewMatrix(Vector2.One));

            map.Draw(spriteBatch, Camera, drawNavMesh);

            exitSprite.Draw(gameTime, spriteBatch, new Vector2(exit.X, exit.Y), SpriteEffects.None, Color.White);

            //draw each of the enemies in the enemies list
            foreach (Enemy enemy in enemies)
            {
                enemy.Draw(gameTime, spriteBatch);
                ((Gun)enemy.Weapon).DrawBullets(gameTime, spriteBatch);
                if (enemy.IsAlive)
                {
                    //XnaDebugDrawer.DebugDrawer.DrawRectangle(spriteBatch, enemy.BoundingRectangle, Color.Red, 1);
                    spriteBatch.DrawString(Hud.hudFont, enemy.Health.ToString(), new Vector2(enemy.BoundingRectangle.X, enemy.BoundingRectangle.Y - 20), Color.Black);

                    //if (enemy.lineIntersectDistance != null)
                    //{
                    //    Vector2 direction = enemy.Target - enemy.Center;
                    //    direction.Normalize();
                    //    XnaDebugDrawer.DebugDrawer.DrawLineSegment(spriteBatch, enemy.Center,
                    //        new Vector2(enemy.Center.X + direction.X * (float)enemy.lineIntersectDistance, enemy.Center.Y + direction.Y * (float)enemy.lineIntersectDistance), Color.Red, 3);
                    //}

                    //if (enemy.Path != null)
                    //{
                    //    foreach (GraphNode<Platform> gNode in enemy.Path)
                    //    {
                    //        Vector2 center = new Vector2((gNode.Value.RightEdgeX + gNode.Value.LeftEdgeX) / 2, gNode.Value.Y);
                    //        XnaDebugDrawer.DebugDrawer.DrawCircle(spriteBatch, center, 8, Color.Red, 5);

                    //        foreach (GraphNode<Platform> neighbor in gNode.Neighbors)
                    //        {
                    //            Vector2 neighborCenter = new Vector2((neighbor.Value.RightEdgeX + neighbor.Value.LeftEdgeX) / 2, neighbor.Value.Y);
                    //            XnaDebugDrawer.DebugDrawer.DrawCircle(spriteBatch, neighborCenter, 8, Color.Red, 5);
                    //            XnaDebugDrawer.DebugDrawer.DrawLineSegment(spriteBatch, center, neighborCenter, Color.Red, 5);
                    //        }

                    //    }
                    //}
                }
            }


            //draw each consumable in the consumables array
            foreach (Consumable consumable in consumables)
            {
                consumable.Draw(gameTime, spriteBatch);
            }

            //draw the active hero
            ActiveHero.Draw(gameTime, spriteBatch);

            if (ActiveHero is HeroStrength)
            {
                ((Gun)Heroes[1].Weapon).DrawBullets(gameTime, spriteBatch);
                ((Gun)Heroes[2].Weapon).DrawBullets(gameTime, spriteBatch);
            }
            else if (ActiveHero is HeroSpeed)
            {
                ((Gun)Heroes[0].Weapon).DrawBullets(gameTime, spriteBatch);
                ((Gun)Heroes[2].Weapon).DrawBullets(gameTime, spriteBatch);
            }
            else
            {
                ((Gun)Heroes[0].Weapon).DrawBullets(gameTime, spriteBatch);
                ((Gun)Heroes[1].Weapon).DrawBullets(gameTime, spriteBatch);
            }
            //XnaDebugDrawer.DebugDrawer.DrawRectangle(spriteBatch, ActiveHero.BoundingRectangle, Color.Red, 1);

            //Collision.Draw(spriteBatch);
            //if (rayIntersectDistance != null)
            //{
            //    Vector2 direction = playersTarget - ActiveHero.Center;
            //    direction.Normalize();
            //    XnaDebugDrawer.DebugDrawer.DrawLineSegment(spriteBatch, ActiveHero.Center,
            //        new Vector2(ActiveHero.Center.X + direction.X * (float)rayIntersectDistance, ActiveHero.Center.Y + direction.Y * (float)rayIntersectDistance), Color.Red, 3);
            //}


            spriteBatch.End();
        }//end Draw method