public override Pos ExpectedEnemyMove(int momentIndex, IPlayer player) { IPlayer enemy = player == Controller.Player1 ? Controller.Player2 : Controller.Player1; if (EnumerateDamageRange().Select(r => player.Gradiator.RelativePosToAbsolute(r)).Contains(enemy.Gradiator.Position)) { RelativePos relative = new RelativePos( enemy.Gradiator.Position.X - player.Gradiator.Position.X, enemy.Gradiator.Position.Y - player.Gradiator.Position.Y ); return(new Pos(enemy.Gradiator.Position.X + relative.X, enemy.Gradiator.Position.Y + relative.Y)); } else { return(enemy.Gradiator.Position); } }
/// <summary> /// /// |\ /// 对边(opposite) | \ 斜边(hypotenuse) /// ______________|__\ /// 邻边(adjacent) /// /// </summary> private void DrawPolylineArrow(DrawingContext dc, Point startPoint, Point endPoint, RelativePos relativePos, FlowDirection flowDirection) { if (ArrowType == ArrowType.None) return; double oppositeLength = ArrowLength * Math.Sin(Math.PI * ArrowAngle / 180); double adjacentLength = ArrowLength * Math.Cos(Math.PI * ArrowAngle / 180); switch (relativePos) { case RelativePos.SameRow: double endX = flowDirection == FlowDirection.Right ? endPoint.X - adjacentLength : endPoint.X + adjacentLength; dc.DrawLine(pen, endPoint, new Point(endX, endPoint.Y - oppositeLength)); dc.DrawLine(pen, endPoint, new Point(endX, endPoint.Y + oppositeLength)); if (ArrowType == ArrowType.OneWay) return; double startX = flowDirection == FlowDirection.Right ? startPoint.X + adjacentLength : startPoint.X - adjacentLength; dc.DrawLine(pen, startPoint, new Point(startX, startPoint.Y - oppositeLength)); dc.DrawLine(pen, startPoint, new Point(startX, startPoint.Y + oppositeLength)); break; case RelativePos.SameColumn: dc.DrawLine(pen, endPoint, new Point(endPoint.X + oppositeLength, endPoint.Y - adjacentLength)); dc.DrawLine(pen, endPoint, new Point(endPoint.X - oppositeLength, endPoint.Y - adjacentLength)); if (ArrowType == ArrowType.OneWay) return; dc.DrawLine(pen, startPoint, new Point(startPoint.X + oppositeLength, startPoint.Y + adjacentLength)); dc.DrawLine(pen, startPoint, new Point(startPoint.X - oppositeLength, startPoint.Y + adjacentLength)); break; } }
private void DrawPolyline(DrawingContext dc, Point startPoint, Point endPoint, RelativePos relativePos) { switch (relativePos) { case RelativePos.SameRow: if (startPoint.Y == endPoint.Y) dc.DrawLine(pen, startPoint, endPoint); else { Point startPolyPoint = new Point((startPoint.X + endPoint.X) / 2, startPoint.Y); Point endPolyPoint = new Point((startPoint.X + endPoint.X) / 2, endPoint.Y); dc.DrawLine(pen, startPoint, startPolyPoint); dc.DrawLine(pen, startPolyPoint, endPolyPoint); dc.DrawLine(pen, endPolyPoint, endPoint); } break; case RelativePos.SameColumn: if (startPoint.X == endPoint.X) dc.DrawLine(pen, startPoint, endPoint); else { Point startPolyPoint = new Point(startPoint.X, (startPoint.Y + endPoint.Y) / 2); Point endPolyPoint = new Point(endPoint.X, (startPoint.Y + endPoint.Y) / 2); dc.DrawLine(pen, startPoint, startPolyPoint); dc.DrawLine(pen, startPolyPoint, endPolyPoint); dc.DrawLine(pen, endPolyPoint, endPoint); } break; } }
private void DrawingLine(DrawingContext dc, Point startPoint, Point endPoint, RelativePos relativePos, FlowDirection flowDirection) { if (LineShapeType == LineShapeType.Polyline) { DrawPolyline(dc, startPoint, endPoint, relativePos); DrawPolylineArrow(dc, startPoint, endPoint, relativePos, flowDirection); } else { DrawStraightLine(dc, startPoint, endPoint); DrawArrow(dc, startPoint, endPoint); } }