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(); }
/// <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(); } }