本文整理汇总了C#中Levels.getAdjacentBlocks方法的典型用法代码示例。如果您正苦于以下问题:C# Levels.getAdjacentBlocks方法的具体用法?C# Levels.getAdjacentBlocks怎么用?C# Levels.getAdjacentBlocks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Levels
的用法示例。
在下文中一共展示了Levels.getAdjacentBlocks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: collision
public override void collision(Levels.Level level)
{
foreach (Block b in level.Blocks)
{
if (Position.Intersects(b.Position))
{
Block final = b;
foreach (Block n in level.getAdjacentBlocks(b))
{
if (Rectangle.Intersect(Position, n.Position).Width * Rectangle.Intersect(Position, n.Position).Height > Rectangle.Intersect(Position, final.Position).Width * Rectangle.Intersect(Position, final.Position).Height)
final = n;
}
if (Rectangle.Intersect(Position, final.Position).Width >= Rectangle.Intersect(Position, final.Position).Height)
{
if (Rectangle.Intersect(Position, final.Position).Top == final.Position.Top)
{
Position = new Rectangle(Position.X, final.Position.Top - Position.Height, Position.Width, Position.Height);
Velocity = new Vector2(Velocity.X, - 6);
}
else if (Rectangle.Intersect(Position, final.Position).Bottom == final.Position.Bottom)
{
Position = new Rectangle(Position.X, final.Position.Bottom, Position.Width, Position.Height);
Velocity = new Vector2(Velocity.X, Velocity.Y * -1); ;
}
}
else
{
if (Rectangle.Intersect(Position, final.Position).Left == final.Position.Left)
{
Velocity = new Vector2(-1, Velocity.Y);
Position = new Rectangle(final.Position.Left - Position.Width, Position.Y, Position.Width, Position.Height);
}
else if (Rectangle.Intersect(Position, final.Position).Right == final.Position.Right)
{
Velocity = new Vector2(1, Velocity.Y);
Position = new Rectangle(final.Position.Right, Position.Y, Position.Width, Position.Height);
}
}
break;
}
}
}