Exemple #1
0
        private void MouseMoveCollisions(MouseEventArgs e, int RealX, int RealY)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (SelectionChoice == SelectionChoices.Move)
                {
                    LayerViewer.SelectedPolygonTriangle.Move(e.X - MouseEventOld.X, e.Y - MouseEventOld.Y);
                }
            }
            else
            {
                LayerViewer.SelectedPolygonTriangle = null;
                SelectionChoice = SelectionChoices.None;

                foreach (Polygon ActivePolygon in ActiveLayer.ListWorldCollisionPolygon)
                {
                    PolygonTriangle Result = ActivePolygon.PolygonCollisionWithMouse(RealX, RealY);

                    if (Result.ActivePolygon != null)
                    {
                        LayerViewer.SelectedPolygonTriangle = Result;
                        SelectionChoice = SelectionChoices.Move;
                        break;
                    }
                }

                if (Control.ModifierKeys == Keys.Control && LayerViewer.SelectedPolygonTriangle != null)
                {
                    LayerViewer.SelectedPolygonTriangle.SelectionType = PolygonTriangle.SelectionTypes.Polygon;
                }
            }
        }
        protected override void Initialize()
        {
            // Hook the idle event to constantly redraw our animation.
            Application.Idle += delegate { Invalidate(); };

            Mouse.WindowHandle = this.Handle;

            content = new ContentManager(Services, "Content");

            sprPixel = content.Load <Texture2D>("Pixel");
            OldWidth = OldHeight = 0;
            SelectedPolygonTriangle = new PolygonTriangle();
            DisplayOtherLayers      = true;

            sprRedTexture = content.Load <Texture2D>("Pixel");
            sprRedTexture.SetData <Color>(new Color[] { Color.FromNonPremultiplied(255, 0, 0, 120) });
            if (PolygonEffect == null)
            {
                PolygonEffect = new BasicEffect(GraphicsDevice);

                PolygonEffect.VertexColorEnabled = true;
                PolygonEffect.TextureEnabled     = true;

                PolygonEffect.World   = Matrix.Identity;
                PolygonEffect.View    = Matrix.Identity;
                PolygonEffect.Texture = sprRedTexture;
            }

            g = new CustomSpriteBatch(new SpriteBatch(GraphicsDevice));
        }
Exemple #3
0
        private void MouseGroundLevel(MouseEventArgs e, int RealX, int RealY)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (SelectionChoice == SelectionChoices.Move)
                {
                    LayerViewer.SelectedPolygonTriangle.Move(e.X - MouseEventOld.X, e.Y - MouseEventOld.Y);
                }
            }
            else
            {
                LayerViewer.SelectedPolygonTriangle = null;
                SelectionChoice = SelectionChoices.None;

                if (LayerViewer.SelectedPolygonTriangle == null)
                {
                    for (int V = 0; V < ActiveLayer.GroundLevelCollision.ArrayVertex.Length; V++)
                    {
                        if (RealX >= ActiveLayer.GroundLevelCollision.ArrayVertex[V].X - 2 && RealX <= ActiveLayer.GroundLevelCollision.ArrayVertex[V].X + 2 &&
                            RealY >= ActiveLayer.GroundLevelCollision.ArrayVertex[V].Y - 2 && RealY <= ActiveLayer.GroundLevelCollision.ArrayVertex[V].Y + 2)
                        {
                            LayerViewer.SelectedPolygonTriangle = PolygonTriangle.VertexSelection(ActiveLayer.GroundLevelCollision, V);
                            SelectionChoice = SelectionChoices.Move;
                            break;
                        }
                    }
                }
                if (Control.ModifierKeys == Keys.Control && LayerViewer.SelectedPolygonTriangle != null)
                {
                    LayerViewer.SelectedPolygonTriangle.SelectionType = PolygonTriangle.SelectionTypes.Polygon;
                }
            }
        }
        protected override void Initialize()
        {
            // Hook the idle event to constantly redraw our animation.
            Application.Idle += delegate { Invalidate(); };

            Mouse.WindowHandle = this.Handle;

            Camera   = new Rectangle(0, 0, Width, Height);
            content  = new ContentManager(Services, "Content");
            sprPixel = content.Load <Texture2D>("Pixel");
            SelectedPolygonTriangle = new PolygonTriangle();
            DisplayOtherLayers      = true;

            sprRedTexture = content.Load <Texture2D>("Pixel");
            sprRedTexture.SetData <Color>(new Color[] { Color.FromNonPremultiplied(255, 0, 0, 120) });
            if (PolygonEffect == null)
            {
                PolygonEffect = new BasicEffect(GraphicsDevice);

                PolygonEffect.VertexColorEnabled = true;
                PolygonEffect.TextureEnabled     = true;

                PolygonEffect.World   = Matrix.Identity;
                PolygonEffect.View    = Matrix.Identity;
                PolygonEffect.Texture = sprRedTexture;
            }

            g = new CustomSpriteBatch(new SpriteBatch(GraphicsDevice));

            Helper = new MapScriptGUIHelper();
            Helper.Load(content, g, GraphicsDevice);

            this.cmsScriptMenu   = new ContextMenuStrip();
            this.tsmDeleteScript = new ToolStripMenuItem();
            //
            // cmsScriptMenu
            //
            this.cmsScriptMenu.Items.AddRange(new ToolStripItem[] {
                this.tsmDeleteScript
            });
            this.cmsScriptMenu.Name = "cmsScriptMenu";
            this.cmsScriptMenu.Size = new System.Drawing.Size(141, 26);

            //
            // tsmDeleteScript
            //
            this.tsmDeleteScript.Name   = "tsmDeleteScript";
            this.tsmDeleteScript.Size   = new System.Drawing.Size(140, 22);
            this.tsmDeleteScript.Text   = "Delete Script";
            this.tsmDeleteScript.Click += tsmDeleteScript_Click;
        }
Exemple #5
0
        public void DrawPolygons(CustomSpriteBatch g)
        {
            if (ListSelectedPolygon.Count <= 0)
            {
                SelectedPolygonTriangle.Draw(g, GraphicsDevice, sprPixel);
                foreach (Polygon ActivePolygon in ListPolygon)
                {
                    if (SelectedPolygonTriangle.ActivePolygon != ActivePolygon)
                    {
                        PolygonTriangle.Draw(g, GraphicsDevice, sprPixel, new PolygonTriangle(PolygonTriangle.SelectionTypes.None, ActivePolygon, 0, 0));
                    }
                }

                SelectedPolygonTriangle.Draw(g, GraphicsDevice, sprPixel);
            }
        }
        /// <summary>
        /// Draws the control.
        /// </summary>
        protected override void Draw()
        {
            Update(new GameTime());

            // Clear to the default control background color.
            Color backColor = new Color(BackColor.R, BackColor.G, BackColor.B);

            GraphicsDevice.Clear(backColor);

            Matrix TransformationMatrix = Matrix.CreateTranslation(-ActiveFightingZone.Camera.X, -ActiveFightingZone.Camera.Y, 0);


            g.Begin(SpriteSortMode.Deferred, null, null, null, null, null, TransformationMatrix);

            foreach (Prop ActivePolygon in ActiveFightingZone.ListProp)
            {
                g.Draw(sprPixel, new Rectangle((int)ActivePolygon.Position.X + 13, (int)ActivePolygon.Position.Y, 6, 20), Color.Black);
                g.Draw(sprPixel, new Rectangle((int)ActivePolygon.Position.X + 13, (int)ActivePolygon.Position.Y + 24, 6, 6), Color.Black);
            }

            foreach (Polygon ActivePolygon in ActiveFightingZone.ListWorldCollisionPolygon)
            {
                PolygonTriangle.Draw(g, GraphicsDevice, sprPixel, new PolygonTriangle(PolygonTriangle.SelectionTypes.None, ActivePolygon, 0, 0));
            }

            if (SelectedAnimation != null)
            {
                Vector2 Position1 = SelectedAnimation.Position - SelectedAnimation.Origin;
                Vector2 Position2 = Position1 + new Vector2(SelectedAnimation.PositionRectangle.Width, 0);
                Vector2 Position3 = Position1 + new Vector2(0, SelectedAnimation.PositionRectangle.Height);
                Vector2 Position4 = Position1 + new Vector2(SelectedAnimation.PositionRectangle.Width, SelectedAnimation.PositionRectangle.Height);

                g.DrawLine(sprPixel, Position1, Position2, Color.Red);
                g.DrawLine(sprPixel, Position1, Position3, Color.Red);
                g.DrawLine(sprPixel, Position2, Position4, Color.Red);
                g.DrawLine(sprPixel, Position3, Position4, Color.Red);
            }

            if (SelectedProp != null)
            {
                Vector2 Position1 = SelectedProp.Position;
                Vector2 Position2 = Position1 + new Vector2(32, 0);
                Vector2 Position3 = Position1 + new Vector2(0, 32);
                Vector2 Position4 = Position1 + new Vector2(32, 32);

                g.DrawLine(sprPixel, Position1, Position2, Color.Red);
                g.DrawLine(sprPixel, Position1, Position3, Color.Red);
                g.DrawLine(sprPixel, Position2, Position4, Color.Red);
                g.DrawLine(sprPixel, Position3, Position4, Color.Red);
            }

            //Draw selected polygons.
            PolygonEffect.Texture = sprRedTexture;
            PolygonEffect.CurrentTechnique.Passes[0].Apply();
            GraphicsDevice.RasterizerState = RasterizerState.CullNone;

            if (SelectedPolygonTriangle != null)
            {
                SelectedPolygonTriangle.Draw(g, GraphicsDevice, sprPixel);
            }

            g.DrawLine(sprPixel, new Vector2(ActiveFightingZone.CameraBounds.X, ActiveFightingZone.CameraBounds.Y), new Vector2(ActiveFightingZone.CameraBounds.Right, ActiveFightingZone.CameraBounds.Y), Color.Red);
            g.DrawLine(sprPixel, new Vector2(ActiveFightingZone.CameraBounds.Right, ActiveFightingZone.CameraBounds.Y), new Vector2(ActiveFightingZone.CameraBounds.Right, ActiveFightingZone.CameraBounds.Bottom), Color.Red);
            g.DrawLine(sprPixel, new Vector2(ActiveFightingZone.CameraBounds.X, ActiveFightingZone.CameraBounds.Y), new Vector2(ActiveFightingZone.CameraBounds.X, ActiveFightingZone.CameraBounds.Bottom), Color.Red);
            g.DrawLine(sprPixel, new Vector2(ActiveFightingZone.CameraBounds.X, ActiveFightingZone.CameraBounds.Bottom), new Vector2(ActiveFightingZone.CameraBounds.Right, ActiveFightingZone.CameraBounds.Bottom), Color.Red);

            Thread.Sleep(15);

            g.End();
        }
Exemple #7
0
        private void PolygonCutterViewer_MouseDown(object sender, MouseEventArgs e)
        {
            MouseEventOld = e;
            int             RealX = MouseEventOld.X;
            int             RealY = MouseEventOld.Y;
            PolygonTriangle SelectedPolygonTriangle = PolygonCutterViewer.SelectedPolygonTriangle;

            switch (SelectionChoice)
            {
                #region None

            case SelectionChoices.None:
                if (PolygonCutterViewer.SelectedPolygonTriangle.SelectionType != PolygonTriangle.SelectionTypes.None)
                {
                    Polygon ActivePolygon = PolygonCutterViewer.SelectedPolygonTriangle.ActivePolygon;

                    if (e.Button == MouseButtons.Left)
                    {
                        SelectionChoice = SelectionChoices.Move;

                        if (SelectedPolygonTriangle.SelectionType == PolygonTriangle.SelectionTypes.Edge)
                        {
                            if (Control.ModifierKeys == Keys.Shift)
                            {
                                SelectedPolygonTriangle.VertexIndex = (short)ActivePolygon.ArrayVertex.Length;

                                ActivePolygon.AddVertexOnEdge(new Vector2(RealX, RealY), SelectedPolygonTriangle.EdgeIndex1, SelectedPolygonTriangle.EdgeIndex2);
                                ActivePolygon.UpdateWorldPosition(Vector2.Zero, 0f);
                            }
                            else if (Control.ModifierKeys == Keys.Alt)
                            {
                                SelectedPolygonTriangle.VertexIndex = (short)ActivePolygon.ArrayVertex.Length;

                                ActivePolygon.SplitEdge(new Vector2(RealX, RealY), SelectedPolygonTriangle.TriangleIndex, SelectedPolygonTriangle.EdgeIndex1, SelectedPolygonTriangle.EdgeIndex2);
                                ActivePolygon.UpdateWorldPosition(Vector2.Zero, 0f);
                            }
                        }
                        else if (SelectedPolygonTriangle.SelectionType == PolygonTriangle.SelectionTypes.Triangle)
                        {
                            if (Control.ModifierKeys == Keys.Shift)
                            {
                                ActivePolygon.SplitTriangle(new Vector2(e.X, e.Y), SelectedPolygonTriangle.TriangleIndex);
                                ActivePolygon.UpdateWorldPosition(Vector2.Zero, 0f);
                            }
                        }
                    }
                    else if (e.Button == MouseButtons.Right)
                    {
                        if (SelectedPolygonTriangle.SelectionType == PolygonTriangle.SelectionTypes.Vertex && SelectedPolygonTriangle.VertexIndex >= 0)    //Delete Vertex.
                        {
                            SelectedPolygonTriangle.ActivePolygon.RemoveVertex(SelectedPolygonTriangle.VertexIndex);
                        }
                        else if (SelectedPolygonTriangle.SelectionType == PolygonTriangle.SelectionTypes.Triangle && SelectedPolygonTriangle.TriangleIndex >= 0)    //Delete Triangle.
                        {
                        }
                    }
                }
                break;

                #endregion

            case SelectionChoices.SplitPolygon:
                PolygonCutterViewer.SplittingPoint1 = new Vector2(e.X, e.Y);
                break;
            }
        }
Exemple #8
0
        private void PolygonCutterViewer_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                Polygon ActivePolygon = null;

                PolygonTriangle SelectedPolygonTriangle = PolygonCutterViewer.SelectedPolygonTriangle;

                if (SelectedPolygonTriangle.SelectionType != PolygonTriangle.SelectionTypes.None)
                {
                    ActivePolygon = SelectedPolygonTriangle.ActivePolygon;
                }

                switch (SelectionChoice)
                {
                case SelectionChoices.Move:
                    if (Control.ModifierKeys == Keys.Alt && SelectedPolygonTriangle.VertexIndex >= 0 && ReplaceVertexIndex >= 0 &&
                        SelectedPolygonTriangle.SelectionType == PolygonTriangle.SelectionTypes.Vertex)
                    {
                        ActivePolygon.ReplaceVertex(SelectedPolygonTriangle.VertexIndex, (short)ReplaceVertexIndex);
                        ActivePolygon.UpdateWorldPosition(Vector2.Zero, 0f);
                    }

                    SelectionChoice = SelectionChoices.None;
                    break;

                case SelectionChoices.SplitPolygon:
                    List <Polygon> ListNewPolygons = new List <Polygon>();
                    for (int P = PolygonCutterViewer.ListPolygon.Count - 1; P >= 0; --P)
                    {
                        Polygon NewPolygon = PolygonCutterViewer.ListPolygon[P].SplitPolygon(PolygonCutterViewer.SplittingPoint1, PolygonCutterViewer.SplittingPoint2);
                        if (NewPolygon != null)
                        {
                            ListNewPolygons.Add(NewPolygon);
                        }
                    }

                    PolygonCutterViewer.ListPolygon.AddRange(ListNewPolygons);
                    for (int P = PolygonCutterViewer.ListPolygon.Count - 1; P >= 0; --P)
                    {
                        PolygonCutterViewer.ListPolygon[P].FuseOverlappingVertex();
                        PolygonCutterViewer.ListPolygon[P].UpdateWorldPosition(Vector2.Zero, 0f);
                    }
                    PolygonCutterViewer.SplittingPoint2 = PolygonCutterViewer.SplittingPoint1 = Vector2.Zero;
                    break;

                case SelectionChoices.SplitTriangle:
                    ActivePolygon.SplitTriangle(new Vector2(e.X, e.Y), SelectedPolygonTriangle.TriangleIndex);
                    break;

                case SelectionChoices.SelectPolygon:
                    if (Control.ModifierKeys != Keys.Shift)
                    {
                        PolygonCutterViewer.ListSelectedPolygon.Clear();
                        SelectionChoice = SelectionChoices.None;
                    }
                    SelectedPolygonTriangle.SelectionType = PolygonTriangle.SelectionTypes.Polygon;
                    PolygonCutterViewer.ListSelectedPolygon.Add(ActivePolygon);
                    break;
                }
            }

            if (PolygonCutterViewer.EditOrigin)
            {
                for (int P = PolygonCutterViewer.ListPolygon.Count - 1; P >= 0; --P)
                {
                    PolygonCutterViewer.ListPolygon[P].ComputeColorAndUVCoordinates(PolygonCutterViewer.sprSource.Width, PolygonCutterViewer.sprSource.Height);
                }
            }
        }
Exemple #9
0
        private void PolygonCutterViewer_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left && PolygonCutterViewer.SelectedPolygonTriangle.SelectionType != PolygonTriangle.SelectionTypes.None &&
                SelectionChoice == SelectionChoices.Move)
            {
                PolygonTriangle SelectedPolygonTriangle = PolygonCutterViewer.SelectedPolygonTriangle;

                #region Move

                Polygon ActivePolygon = SelectedPolygonTriangle.ActivePolygon;

                if (SelectedPolygonTriangle.SelectionType == PolygonTriangle.SelectionTypes.Vertex)// Move Vertex.
                {
                    ReplaceVertexIndex = -1;

                    if (Control.ModifierKeys == Keys.Alt)//Snap to closest vertex.
                    {
                        double MinDistanceToVertex = 5;
                        for (int V = 0; V < ActivePolygon.ArrayVertex.Length; V++)
                        {
                            if (V == SelectedPolygonTriangle.VertexIndex)
                            {
                                continue;
                            }

                            double DistanceToVertexX = e.X - ActivePolygon.ArrayVertex[V].X;
                            double DistanceToVertexY = e.Y - ActivePolygon.ArrayVertex[V].Y;
                            double DistanceToVertex  = Math.Sqrt(Math.Pow(DistanceToVertexX, 2) + Math.Pow(DistanceToVertexY, 2));

                            if (DistanceToVertex < MinDistanceToVertex)
                            {
                                MinDistanceToVertex = DistanceToVertex;
                                ReplaceVertexIndex  = V;
                            }
                        }
                    }
                    if (ReplaceVertexIndex >= 0)
                    {
                        ActivePolygon.ArrayVertex[SelectedPolygonTriangle.VertexIndex].X = ActivePolygon.ArrayVertex[ReplaceVertexIndex].X;
                        ActivePolygon.ArrayVertex[SelectedPolygonTriangle.VertexIndex].Y = ActivePolygon.ArrayVertex[ReplaceVertexIndex].Y;
                        ActivePolygon.UpdateWorldPosition(Vector2.Zero, 0f);
                    }
                    else
                    {
                        ActivePolygon.ArrayVertex[SelectedPolygonTriangle.VertexIndex].X = e.X;
                        ActivePolygon.ArrayVertex[SelectedPolygonTriangle.VertexIndex].Y = e.Y;
                        ActivePolygon.UpdateWorldPosition(Vector2.Zero, 0f);
                    }
                }
                else//Move Polygon
                {
                    SelectedPolygonTriangle.Move(e.X - MouseEventOld.X, e.Y - MouseEventOld.Y);
                }

                #endregion
            }
            else
            {
                PolygonCutterViewer.SelectedPolygonTriangle.SelectionType = PolygonTriangle.SelectionTypes.None;

                for (int P = PolygonCutterViewer.ListPolygon.Count - 1; P >= 0; --P)
                {
                    Polygon ActivePolygon = PolygonCutterViewer.ListPolygon[P];
                    Vector2 MousePosition = new Vector2(e.X, e.Y);

                    PolygonTriangle PolygonResult = ActivePolygon.PolygonCollisionWithMouse(e.X, e.Y);

                    if (PolygonResult.SelectionType != PolygonTriangle.SelectionTypes.None)
                    {
                        PolygonCutterViewer.SelectedPolygonTriangle = PolygonResult;
                    }
                }

                switch (SelectionChoice)
                {
                case SelectionChoices.SplitPolygon:
                    PolygonCutterViewer.SplittingPoint2 = new Vector2(e.X, e.Y);
                    break;
                }
            }

            if (Control.ModifierKeys == Keys.Control && PolygonCutterViewer.SelectedPolygonTriangle != null)
            {
                PolygonCutterViewer.SelectedPolygonTriangle.SelectionType = PolygonTriangle.SelectionTypes.Polygon;
            }
            MouseEventOld = e;
        }
        /// <summary>
        /// Draws the control.
        /// </summary>
        protected override void Draw()
        {
            // Clear to the default control background color.
            Color backColor = new Color(BackColor.R, BackColor.G, BackColor.B);

            GraphicsDevice.Clear(backColor);

            if (ShowScripts)
            {
                Helper.DrawScripts();
            }
            else
            {
                Update(new GameTime());

                Matrix TransformationMatrix = Matrix.CreateTranslation(-Camera.X, -Camera.Y, 0);

                g.Begin(SpriteSortMode.FrontToBack, null, null, null, null, null, TransformationMatrix);

                foreach (Layer ActiveLayer in ActiveFightingZone.ListLayer)
                {
                    foreach (Prop ActiveProp in ActiveLayer.ListProp)
                    {
                        ActiveProp.BeginDraw(g);
                    }
                }

                g.End();
                GraphicsDevice.SetRenderTarget(null);

                if (ActiveFightingZone.Background != null)
                {
                    ActiveFightingZone.Background.Draw(g, Width, Height);
                }

                g.Begin(SpriteSortMode.Deferred, null, null, null, null, null, TransformationMatrix);

                foreach (Layer ActiveLayer in ActiveFightingZone.ListLayer)
                {
                    if (!DisplayOtherLayers && SelectedLayer != ActiveLayer)
                    {
                        continue;
                    }

                    ActiveLayer.Draw(g);

                    foreach (Prop ActiveProp in ActiveLayer.ListProp)
                    {
                        g.Draw(sprPixel, new Rectangle((int)ActiveProp._Position.X + 13, (int)ActiveProp._Position.Y, 6, 20), Color.Black);
                        g.Draw(sprPixel, new Rectangle((int)ActiveProp._Position.X + 13, (int)ActiveProp._Position.Y + 24, 6, 6), Color.Black);
                    }

                    foreach (SpawnPoint ActiveSpawn in ActiveLayer.ListSpawnPointTeam)
                    {
                        g.Draw(sprPixel, new Rectangle((int)ActiveSpawn.SpawnLocation.X + 13, (int)ActiveSpawn.SpawnLocation.Y, 6, 20), Color.Black);
                        g.Draw(sprPixel, new Rectangle((int)ActiveSpawn.SpawnLocation.X + 13, (int)ActiveSpawn.SpawnLocation.Y + 24, 6, 6), Color.Black);
                    }

                    foreach (Polygon ActivePolygon in ActiveLayer.ListWorldCollisionPolygon)
                    {
                        PolygonTriangle.Draw(g, GraphicsDevice, sprPixel, new PolygonTriangle(PolygonTriangle.SelectionTypes.None, ActivePolygon, 0, 0));
                    }

                    if (SelectedAnimation != null)
                    {
                        Vector2 Position1 = SelectedAnimation.Position - SelectedAnimation.Origin;
                        Vector2 Position2 = Position1 + new Vector2(SelectedAnimation.PositionRectangle.Width, 0);
                        Vector2 Position3 = Position1 + new Vector2(0, SelectedAnimation.PositionRectangle.Height);
                        Vector2 Position4 = Position1 + new Vector2(SelectedAnimation.PositionRectangle.Width, SelectedAnimation.PositionRectangle.Height);

                        g.DrawLine(sprPixel, Position1, Position2, Color.Red);
                        g.DrawLine(sprPixel, Position1, Position3, Color.Red);
                        g.DrawLine(sprPixel, Position2, Position4, Color.Red);
                        g.DrawLine(sprPixel, Position3, Position4, Color.Red);
                    }

                    if (SelectedProp != null)
                    {
                        Vector2 Position1 = SelectedProp._Position;
                        Vector2 Position2 = Position1 + new Vector2(32, 0);
                        Vector2 Position3 = Position1 + new Vector2(0, 32);
                        Vector2 Position4 = Position1 + new Vector2(32, 32);

                        g.DrawLine(sprPixel, Position1, Position2, Color.Red);
                        g.DrawLine(sprPixel, Position1, Position3, Color.Red);
                        g.DrawLine(sprPixel, Position2, Position4, Color.Red);
                        g.DrawLine(sprPixel, Position3, Position4, Color.Red);
                    }

                    if (SelectedSpawn != null)
                    {
                        Vector2 Position1 = SelectedSpawn.SpawnLocation;
                        Vector2 Position2 = Position1 + new Vector2(32, 0);
                        Vector2 Position3 = Position1 + new Vector2(0, 32);
                        Vector2 Position4 = Position1 + new Vector2(32, 32);

                        g.DrawLine(sprPixel, Position1, Position2, Color.Red);
                        g.DrawLine(sprPixel, Position1, Position3, Color.Red);
                        g.DrawLine(sprPixel, Position2, Position4, Color.Red);
                        g.DrawLine(sprPixel, Position3, Position4, Color.Red);
                    }

                    //Draw selected polygons.
                    PolygonEffect.Texture = sprRedTexture;
                    PolygonEffect.CurrentTechnique.Passes[0].Apply();
                    GraphicsDevice.RasterizerState = RasterizerState.CullNone;

                    Polygon ActiveGroundPolygon;

                    for (int V = 0; V < ActiveLayer.GroundLevelCollision.ArrayVertex.Length - 1; V++)
                    {
                        ActiveGroundPolygon = ActiveLayer.GroundLevelCollision;

                        g.Draw(sprPixel, new Rectangle((int)ActiveGroundPolygon.ArrayVertex[V].X - 2, (int)ActiveGroundPolygon.ArrayVertex[V].Y - 2, 5, 5), Color.Red);
                        g.DrawLine(sprPixel, ActiveGroundPolygon.ArrayVertex[V], ActiveGroundPolygon.ArrayVertex[V + 1], Color.Red);
                    }

                    ActiveGroundPolygon = ActiveLayer.GroundLevelCollision;
                    g.Draw(sprPixel, new Rectangle((int)ActiveGroundPolygon.ArrayVertex[ActiveGroundPolygon.ArrayVertex.Length - 1].X - 2,
                                                   (int)ActiveGroundPolygon.ArrayVertex[ActiveGroundPolygon.ArrayVertex.Length - 1].Y - 2, 5, 5), Color.Red);
                }

                foreach (Layer ActiveLayer in ActiveFightingZone.ListLayer)
                {
                    foreach (Prop ActiveProp in ActiveLayer.ListProp)
                    {
                        ActiveProp.EndDraw(g);
                    }
                }

                if (SelectedPolygonTriangle != null)
                {
                    g.End();
                    g.Begin(SpriteSortMode.Deferred, null, null, null, null, null, TransformationMatrix);

                    PolygonEffect.Texture = sprRedTexture;
                    PolygonEffect.CurrentTechnique.Passes[0].Apply();
                    GraphicsDevice.RasterizerState = RasterizerState.CullNone;
                    SelectedPolygonTriangle.Draw(g, GraphicsDevice, sprPixel);
                    if (SelectedPolygonTriangle.ActivePolygon != null)
                    {
                        SelectedPolygonTriangle.ActivePolygon.Draw(GraphicsDevice);
                    }
                }

                g.DrawLine(sprPixel, new Vector2(ActiveFightingZone.CameraBounds.X, ActiveFightingZone.CameraBounds.Y), new Vector2(ActiveFightingZone.CameraBounds.Right, ActiveFightingZone.CameraBounds.Y), Color.Red);
                g.DrawLine(sprPixel, new Vector2(ActiveFightingZone.CameraBounds.Right, ActiveFightingZone.CameraBounds.Y), new Vector2(ActiveFightingZone.CameraBounds.Right, ActiveFightingZone.CameraBounds.Bottom), Color.Red);
                g.DrawLine(sprPixel, new Vector2(ActiveFightingZone.CameraBounds.X, ActiveFightingZone.CameraBounds.Y), new Vector2(ActiveFightingZone.CameraBounds.X, ActiveFightingZone.CameraBounds.Bottom), Color.Red);
                g.DrawLine(sprPixel, new Vector2(ActiveFightingZone.CameraBounds.X, ActiveFightingZone.CameraBounds.Bottom), new Vector2(ActiveFightingZone.CameraBounds.Right, ActiveFightingZone.CameraBounds.Bottom), Color.Red);

                Thread.Sleep(15);

                g.End();
            }
        }