本文整理汇总了C#中IPoint2D类的典型用法代码示例。如果您正苦于以下问题:C# IPoint2D类的具体用法?C# IPoint2D怎么用?C# IPoint2D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IPoint2D类属于命名空间,在下文中一共展示了IPoint2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DistanceSqrt
public static double DistanceSqrt( IPoint2D from, IPoint2D to )
{
float xDelta = Math.Abs( from.X - to.X );
float yDelta = Math.Abs( from.Y - to.Y );
return Math.Sqrt( xDelta*xDelta + yDelta*yDelta );
}
示例2: Distance
public static int Distance( IPoint2D from, IPoint2D to )
{
int xDelta = Math.Abs( from.X - to.X );
int yDelta = Math.Abs( from.Y - to.Y );
return ( xDelta > yDelta ? xDelta : yDelta );
}
示例3: Find
public static NestArea Find(IPoint2D p)
{
foreach (NestArea area in m_Areas)
{
if (area.Contains(p))
return area;
}
return null;
}
示例4: Contains
public bool Contains(IPoint2D p)
{
foreach (Rectangle2D rect in this.m_Rects)
{
if (rect.Contains(p))
return true;
}
return false;
}
示例5: Contains
public bool Contains(IPoint2D p)
{
foreach (var rect in m_Rects)
{
if (rect.Contains(p))
return true;
}
return false;
}
示例6: DistanceBetween
/// <summary>
/// Calculates the distance between two points
/// </summary>
/// <param name="origin">the starting point</param>
/// <param name="target">the ending point</param>
/// <returns>an integer of the distance between the origin and target</returns>
public static int DistanceBetween( IPoint2D origin, IPoint2D target )
{
if( origin.X == target.X )
return Math.Abs((origin.Y - target.Y));
if( origin.Y == target.Y )
return Math.Abs((origin.Y - target.Y));
//pythagorean theorem... dist = sqrt of (x2-x1)^2 + (y2-y1)^2
return (int)Math.Sqrt(Math.Pow(Math.Abs(target.X - origin.X), 2) + Math.Pow(Math.Abs(target.Y - origin.Y), 2));
}
示例7: FindBoatAt
public static BaseBoat FindBoatAt( IPoint2D loc, Map map )
{
Sector sector = map.GetSector( loc );
for ( int i = 0; i < sector.Multis.Count; i++ )
{
BaseBoat boat = sector.Multis[i] as BaseBoat;
if ( boat != null && boat.Contains( loc.X, loc.Y ) )
return boat;
}
return null;
}
示例8: ConsumeJumpStamina
private static bool ConsumeJumpStamina( Player pm, IPoint2D start, IPoint2D end )
{
double weightRatio = (pm.TotalWeight / pm.MaxWeight);
int weightInducedLoss = (int)(5 * weightRatio);
int dist = Util.DistanceBetween(start, end);
int toConsume = (int)(dist * 5);
toConsume += weightInducedLoss;
if( (pm.Stam - toConsume) <= 0 )
return false;
pm.Stam -= toConsume;
return true;
}
示例9: FindMultiAt
public static BaseMulti FindMultiAt(IPoint2D loc, Map map)
{
Sector sector = map.GetSector(loc);
for (int i = 0; i < sector.Multis.Count; i++)
{
BaseMulti multi = sector.Multis[i];
if (multi != null && multi.Contains(loc.X, loc.Y))
{
return multi;
}
}
return null;
}
示例10: Contains
public static bool Contains(IPoint2D p, IPoint2D a, IPoint2D b, IPoint2D c)
{
var x = p.X - a.X;
var y = p.Y - a.Y;
var delta = (b.X - a.X) * y - (b.Y - a.Y) * x > 0;
if ((c.X - a.X) * y - (c.Y - a.Y) * x > 0 == delta)
{
return false;
}
if ((c.X - b.X) * (p.Y - b.Y) - (c.Y - b.Y) * (p.X - b.X) > 0 != delta)
{
return false;
}
return true;
}
示例11: GetLine2D
/// <summary>
/// Gets a Point2D collection representing all locations between 'start' and 'end', including 'start' and 'end', on the given 'map'.
/// </summary>
public static Point2D[] GetLine2D(this IPoint2D start, IPoint2D end, Map map)
{
var path = new List<Point2D>();
Geometry.Line2D(ToPoint3D(start), ToPoint3D(end), map, (p, m) => path.Add(ToPoint2D(p)));
var arr = path.OrderBy(p => GetDistance(start, p)).ToArray();
path.Clear();
path.TrimExcess();
return arr;
}
示例12: InSquareRange
public bool InSquareRange(IPoint2D p, int xyRange)
{
return ((((this.m_X >= (p.X - xyRange)) && (this.m_X <= (p.X + xyRange))) && (this.m_Y >= (p.Y - xyRange))) && (this.m_Y <= (p.Y + xyRange)));
}
示例13: Rectangle2D
public Rectangle2D(IPoint2D start, IPoint2D end)
: this(start.X, start.Y, end.X, end.Y) {
}
示例14: GetStaticTiles
public static StaticTile[] GetStaticTiles(this Map map, IPoint2D p)
{
return map.Tiles.GetStaticTiles(p.X, p.Y);
}
示例15: HasLand
public static bool HasLand(this Map map, IPoint2D p)
{
return !GetLandTile(map, p).Ignored;
}