本文整理汇总了C#中Microsoft.Xna.Framework.Rectangle.Side方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Side方法的具体用法?C# Rectangle.Side怎么用?C# Rectangle.Side使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Rectangle
的用法示例。
在下文中一共展示了Rectangle.Side方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestMapStickyCollision
CollisionInfo? TestMapStickyCollision(Map map, Rectangle rectangle,
TileInfo.SideType direction, BitArray maybeGroundTile)
{
List<CollisionTile> tiles = map.GetCollidingTiles(rectangle, direction);
for (int i = 0; i < tiles.Count; i++)
{
TileInfo.SideType side = TileInfo.OppositeSide(direction);
GameUnit perpendicularPosition;
if (TileInfo.Vertical(side))
{
perpendicularPosition = rectangle.Center.X;
}
else
{
perpendicularPosition = rectangle.Center.Y;
}
GameUnit leadingPosition = rectangle.Side(direction);
bool shouldTestSlopes = TileInfo.Vertical(side);
TestCollisionInfo testInfo = tiles[i].TestCollision(side, perpendicularPosition,
leadingPosition, shouldTestSlopes);
if (testInfo.isColliding)
{
CollisionInfo info = new CollisionInfo(testInfo.position, tiles[i].Position, tiles[i].TileType);
return info;
}
else if (maybeGroundTile != null && direction == TileInfo.SideType.BottomSide)
{
BitArray tallSlope = TileInfo.CreateTileType();
tallSlope.Set((int)TileInfo.TileFlag.Slope, true);
tallSlope.Set((int)TileInfo.TileFlag.TallSlope, true);
if ((maybeGroundTile[(int)TileInfo.TileFlag.Slope] && tiles[i].TileType[(int)TileInfo.TileFlag.Slope]) ||
(maybeGroundTile[(int)TileInfo.TileFlag.Wall] &&
(tallSlope.And(tiles[i].TileType).Equals(tallSlope))))
{
CollisionInfo info = new CollisionInfo(testInfo.position, tiles[i].Position, tiles[i].TileType);
return info;
}
}
}
return null;
}
示例2: TestMapBouncingCollision
CollisionInfo? TestMapBouncingCollision(Map map, Rectangle rectangle,
TileInfo.SideType direction, BitArray maybeGroundTile)
{
List<CollisionTile> tiles = map.GetCollidingTiles(rectangle, direction);
CollisionInfo? result = null;
for (int i = 0; i < tiles.Count; i++)
{
TileInfo.SideType side = TileInfo.OppositeSide(direction);
GameUnit perpendicularPosition;
if (TileInfo.Vertical(side))
{
perpendicularPosition = rectangle.Center.X;
}
else
{
perpendicularPosition = rectangle.Center.Y;
}
GameUnit leadingPosition = rectangle.Side(direction);
bool shouldTestSlopes = TileInfo.Vertical(side);
TestCollisionInfo testInfo = tiles[i].TestCollision(side, perpendicularPosition,
leadingPosition, shouldTestSlopes);
if (testInfo.isColliding)
{
bool shouldReplaceResult = true;
if (result.HasValue)
{
shouldReplaceResult = TileInfo.IsMin(side) ?
testInfo.position < result.Value.position :
testInfo.position > result.Value.position;
}
if (shouldReplaceResult)
{
CollisionInfo info = new CollisionInfo(testInfo.position, tiles[i].Position, tiles[i].TileType);
result = info;
}
}
}
return result;
}
示例3: GetCollidingTiles
public List<CollisionTile> GetCollidingTiles(Rectangle rectangle, TileInfo.SideType direction)
{
TileUnit firstPrimary = Units.GameToTile(rectangle.Side(TileInfo.OppositeSide(direction)));
TileUnit lastPrimary = Units.GameToTile(rectangle.Side(direction));
int primaryIncr = TileInfo.IsMax(direction) ? 1 : -1;
bool horizontal = TileInfo.Horizontal(direction);
TileUnit sMin = Units.GameToTile(horizontal ? rectangle.Top : rectangle.Left);
TileUnit sMid = Units.GameToTile(horizontal ? rectangle.Center.Y : rectangle.Center.X);
TileUnit sMax = Units.GameToTile(horizontal ? rectangle.Bottom : rectangle.Right);
bool sPositive = sMid - sMin < sMax - sMid;
int secondaryIncr = sPositive ? 1 : -1;
TileUnit firstSecondary = sPositive ? sMin : sMax;
TileUnit lastSecondary = sPositive ? sMin : sMax;
List<CollisionTile> collisionTiles = new List<CollisionTile>();
for (TileUnit primary = firstPrimary; primary != lastPrimary + primaryIncr; primary = Convert.ToUInt32(Convert.ToInt32(primary) + primaryIncr))
{
for (TileUnit secondary = firstSecondary; secondary != lastSecondary + secondaryIncr; secondary = Convert.ToUInt32(Convert.ToInt32(secondary) + secondaryIncr))
{
TileUnit row = !horizontal ? primary : secondary;
TileUnit col = horizontal ? primary : secondary;
collisionTiles.Add(new CollisionTile(row, col, tiles[Convert.ToInt32(row)][Convert.ToInt32(col)].tileType));
}
}
return collisionTiles;
}