本文整理汇总了C#中RectangleF.GetSideSegment方法的典型用法代码示例。如果您正苦于以下问题:C# RectangleF.GetSideSegment方法的具体用法?C# RectangleF.GetSideSegment怎么用?C# RectangleF.GetSideSegment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RectangleF
的用法示例。
在下文中一共展示了RectangleF.GetSideSegment方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetArrowScreenBorderPosition
private Vector2 GetArrowScreenBorderPosition(GraphicsContext graphicsContext, Vector2 entityPosition)
{
Vector2 direction = entityPosition - CCamera2D.Active.Position;
Ray2D ray = new Ray2D(graphicsContext.ScreenSize / 2f, Vector2.Normalize(direction)); // ray from screen center to the direction of the drop
if (!Check.IsValid(ray))
{
return -Vector2.One * 10000; // invalid number
}
RectangleF screenArea = new RectangleF(graphicsContext.ScreenArea).Inflate(-16);
Vector2 hitPosition;
if (ray.Intersects(screenArea.GetSideSegment(Direction2D.Left), out hitPosition) || ray.Intersects(screenArea.GetSideSegment(Direction2D.Right), out hitPosition) ||
ray.Intersects(screenArea.GetSideSegment(Direction2D.Up), out hitPosition) || ray.Intersects(screenArea.GetSideSegment(Direction2D.Down), out hitPosition))
{
return hitPosition;
}
throw new InvalidOperationException("");
}