public override void Draw(SpriteBatch spriteBatch) { DotCamera.DotCameraBegin(spriteBatch, Camera, SpriteSortMode.Immediate); foreach (Point location in dungeon.CellLocations) { Cell cell = dungeon[location]; LineExt.DrawFullRectangle(spriteBatch, new Rectangle(TopLeft(location).X, TopLeft(location).Y, xStep, yStep), GetWallCount(cell) == 4 ? Color.Black : Color.Transparent); //g.FillRectangle(GetWallCount(cell) == 4 ? Brushes.Black : Brushes.Transparent, TopLeft(location).X, TopLeft(location).Y, xStep, yStep); Color pen = GetSidePen(cell.NorthSide); LineExt.DrawLine(spriteBatch, TopLeft(location).ToVector2(), TopRight(location).ToVector2(), pen); //g.DrawLine(pen, TopLeft(location), TopRight(location)); if (cell.NorthSide == SideType.Door) { LineExt.DrawFullRectangle(spriteBatch, new Rectangle(TopLeft(location).X + 1 + (xStep - 2) / 4, TopLeft(location).Y - 3, (xStep / 2) - 1, 6), pen); } //if (cell.NorthSide == SideType.Door) g.DrawRectangle(pen, TopLeft(location).X + 1 + (xStep - 2) / 4, TopLeft(location).Y - 3, (xStep / 2) - 1, 6); pen = GetSidePen(cell.WestSide); LineExt.DrawLine(spriteBatch, TopLeft(location).ToVector2(), BottomLeft(location).ToVector2(), pen); //g.DrawLine(pen, TopLeft(location), BottomLeft(location)); if (cell.WestSide == SideType.Door) { LineExt.DrawFullRectangle(spriteBatch, new Rectangle(TopLeft(location).X - 3, TopLeft(location).Y + 1 + (yStep - 2) / 4, 6, (xStep / 2) - 1), pen); } //if (cell.WestSide == SideType.Door) g.DrawRectangle(pen, TopLeft(location).X - 3, TopLeft(location).Y + 1 + (yStep - 2) / 4, 6, (xStep / 2) - 1); LineExt.DrawLine(spriteBatch, BottomLeft(location).ToVector2(), BottomRight(location).ToVector2(), GetSidePen(cell.SouthSide)); //g.DrawLine(GetSidePen(cell.SouthSide), BottomLeft(location), BottomRight(location)); LineExt.DrawLine(spriteBatch, TopRight(location).ToVector2(), BottomRight(location).ToVector2(), GetSidePen(cell.EastSide)); //g.DrawLine(GetSidePen(cell.EastSide), TopRight(location), BottomRight(location)); } SpritesDraw(spriteBatch); spriteBatch.End(); DotCamera.DotCameraBegin(spriteBatch, Camera); Items.DrawCustome(spriteBatch); Unit.DrawCustome(spriteBatch); spriteBatch.End(); DotCamera.DotCameraBegin(spriteBatch, Camera); Physics.DrawDebugView(Camera); spriteBatch.End(); }
/// <summary> /// compute the angle between two lines. /// </summary> /// <param name="Line1"></param> /// <param name="Line2"></param> /// <returns></returns> public static double AngleBetween(LineCoordinates Line1, LineCoordinates Line2) { // the start point of each line is the common point between the two lines. var commonPoint = LineCoordinates.CommonEndPoint(Line1, Line2); // the end points of each line. var end1 = Line1.OtherPoint(commonPoint); var end2 = Line2.OtherPoint(commonPoint); // the 360 degree angles of each line. var angle1 = LineExt.GetAngle(commonPoint, end1); var angle2 = LineExt.GetAngle(commonPoint, end2); // the angle between is the diff between the 360 degree angles of the 2 lines. var angleBet = Angle360.Subtract(angle1, angle2); if (angleBet.Value > 180) { angleBet = Angle360.Subtract(angle2, angle1); } return(angleBet.Value); }
public override void DrawUI(SpriteBatch spriteBatch) { LineExt.DrawFullRectangle(spriteBatch, _barBackgroudRect, _backgroundBarColor * 0.7f); LineExt.DrawFullRectangle(spriteBatch, _barCurrentRect, _currentBarColor * 0.75f); }
public override void Draw(SpriteBatch spriteBatch) { LineExt.DrawFullRectangle(spriteBatch, _BoxRect, _boxColor); base.Draw(spriteBatch); }