private void DrawMap()
        {
            GraphicsDevice.Clear(Color.Black);

            for (int S = ActiveMap.ListGameScreen.Count - 1; S >= 0; --S)
            {
                if (ActiveMap.Alive)
                {
                    ActiveMap.BeginDraw(g);
                }
            }

            GraphicsDevice.SetRenderTarget(null);
            g.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);

            if (ActiveMap.ListTileSet.Count > 0)
            {
                ActiveMap.Draw(g);
            }

            g.End();
            g.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);

            ActiveMap.EndDraw(g);
            g.End();
        }
Example #2
0
        private void DrawMap()
        {
            GraphicsDevice.Clear(Color.Black);

            for (int S = ActiveMap.ListGameScreen.Count - 1; S >= 0; --S)
            {
                if (ActiveMap.Alive)
                {
                    ActiveMap.BeginDraw(g);
                }
            }

            GraphicsDevice.SetRenderTarget(null);
            g.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);

            if (ActiveMap.ListTileSet.Count > 0)
            {
                ActiveMap.Draw(g);
            }

            g.End();
            g.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);

            for (int i = 0; i < ActiveMap.ListSingleplayerSpawns.Count; i++)
            {
                g.Draw(sprPixel, new Rectangle((int)(ActiveMap.ListSingleplayerSpawns[i].Position.X - ActiveMap.CameraPosition.X) * ActiveMap.TileSize.X,
                                               (int)(ActiveMap.ListSingleplayerSpawns[i].Position.Y - ActiveMap.CameraPosition.Y) * ActiveMap.TileSize.Y,
                                               ActiveMap.TileSize.X, ActiveMap.TileSize.Y),
                       BrushPlayer);

                g.DrawString(fntSpawnText, ActiveMap.ListSingleplayerSpawns[i].Tag,
                             new Vector2((ActiveMap.ListSingleplayerSpawns[i].Position.X - ActiveMap.CameraPosition.X) * ActiveMap.TileSize.X + 10,
                                         (ActiveMap.ListSingleplayerSpawns[i].Position.Y - ActiveMap.CameraPosition.Y) * ActiveMap.TileSize.Y + 10),
                             Color.Black);
            }

            for (int i = 0; i < ActiveMap.ListMultiplayerSpawns.Count; i++)
            {
                g.Draw(sprPixel, new Rectangle((int)(ActiveMap.ListMultiplayerSpawns[i].Position.X - ActiveMap.CameraPosition.X) * ActiveMap.TileSize.X,
                                               (int)(ActiveMap.ListMultiplayerSpawns[i].Position.Y - ActiveMap.CameraPosition.Y) * ActiveMap.TileSize.Y,
                                               ActiveMap.TileSize.X, ActiveMap.TileSize.Y),
                       BrushPlayer);

                g.DrawString(fntSpawnText, ActiveMap.ListMultiplayerSpawns[i].Tag,
                             new Vector2((ActiveMap.ListMultiplayerSpawns[i].Position.X - ActiveMap.CameraPosition.X) * ActiveMap.TileSize.X + 10,
                                         (ActiveMap.ListMultiplayerSpawns[i].Position.Y - ActiveMap.CameraPosition.Y) * ActiveMap.TileSize.Y + 10),
                             Color.Black);
            }

            for (int i = 0; i < ActiveMap.ListMapSwitchPoint.Count; i++)
            {
                g.Draw(sprPixel, new Rectangle((int)(ActiveMap.ListMapSwitchPoint[i].Position.X - ActiveMap.CameraPosition.X) * ActiveMap.TileSize.X,
                                               (int)(ActiveMap.ListMapSwitchPoint[i].Position.Y - ActiveMap.CameraPosition.Y) * ActiveMap.TileSize.Y,
                                               ActiveMap.TileSize.X, ActiveMap.TileSize.Y),
                       BrushMapSwitchEventPoint);

                g.DrawString(fntSpawnText, ActiveMap.ListMapSwitchPoint[i].Tag,
                             new Vector2((ActiveMap.ListMapSwitchPoint[i].Position.X - ActiveMap.CameraPosition.X) * ActiveMap.TileSize.X + 10,
                                         (ActiveMap.ListMapSwitchPoint[i].Position.Y - ActiveMap.CameraPosition.Y) * ActiveMap.TileSize.Y + 10),
                             Color.Black);
            }

            //Grid
            if (ShowGrid)
            {
                //Draw the vertical lines for the grid.
                for (int X = 0; X < ActiveMap.MapSize.X; X++)
                {
                    g.Draw(sprPixel, new Rectangle(X * ActiveMap.TileSize.X, 0,
                                                   1, ActiveMap.MapSize.Y * ActiveMap.TileSize.Y), Color.Black);
                }
                //Draw the horizontal lines for the grid.
                for (int Y = 0; Y < ActiveMap.MapSize.Y; Y++)
                {
                    g.Draw(sprPixel, new Rectangle(0, Y * ActiveMap.TileSize.Y,
                                                   ActiveMap.MapSize.X * ActiveMap.TileSize.X, 1), Color.Black);
                }
            }

            ActiveMap.EndDraw(g);
            g.End();
        }