本文整理汇总了C#中Point.ConvertToTilePosition方法的典型用法代码示例。如果您正苦于以下问题:C# Point.ConvertToTilePosition方法的具体用法?C# Point.ConvertToTilePosition怎么用?C# Point.ConvertToTilePosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Point
的用法示例。
在下文中一共展示了Point.ConvertToTilePosition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PlaceDoor
public void PlaceDoor(Point start)
{
//figure out if they meant to put door on left or top of tile
var left = start.X % Gc.TILE_SIZE;
var top = start.Y % Gc.TILE_SIZE;
start = start.ConvertToTilePosition(Gc.TILE_SIZE);
var d = new Door
{
Line = new Line
{
Stroke = new SolidColorBrush(Colors.DarkGray),
StrokeThickness = 5,
X1 = start.X,
X2 = start.X,
Y1 = start.Y,
Y2 = start.Y
}
};
if (left < top) // they were closer to left side of tile
{
d.Rotation = 90;
d.Line.Y2 += Gc.TILE_SIZE;
}
else // else they were closer to top, or were equal distances at which point I'm putting it here because the user is an indecisive bastard
{
d.Rotation = 0;
d.Line.X2 += Gc.TILE_SIZE;
}
Canvas.SetZIndex(d.Line, DOOR_LAYER);
Map.Children.Add(d.Line);
DoorList.Add(d);
}
示例2: PlaceWall
public void PlaceWall(Point start, Point end)
{
start = start.ConvertToTilePosition(Gc.TILE_SIZE);
end = end.ConvertToTilePosition(Gc.TILE_SIZE);
var b = new Bounds(start, end).KeepBoundsWidthOf1();
//hack to add last tile of wall since walls start at 0,0 but should go the full length of last tile
if (b.LowerX == b.UpperX) b.UpperY += Gc.TILE_SIZE;
else if (b.LowerY == b.UpperY) b.UpperX += Gc.TILE_SIZE;
var w = new Wall
{
Line = new Line
{
X1 = b.LowerX,
Y1 = b.LowerY,
X2 = b.UpperX,
Y2 = b.UpperY,
Stroke = new SolidColorBrush(Colors.Gray),
StrokeThickness = 3
},
};
Canvas.SetZIndex(w.Line, WALL_LAYER);
Map.Children.Add(w.Line);
WallList.Add(w);
}
示例3: RemoveExistingTilesBetween
public void RemoveExistingTilesBetween(Point start, Point end)
{
var tiles = Map.Children.OfType<Rectangle>()
.Where(x => x != selectionRectangle)
.Where(x => x.WithinBounds(start.ConvertToTilePosition(Gc.TILE_SIZE), end.ConvertToTilePosition(Gc.TILE_SIZE)))
.ToList();
for (int i = tiles.Count() - 1; i >= 0; i--)
{
Map.Children.Remove(tiles[i]);
TileList.Remove(TileList.FirstOrDefault(x => x.Rectangle == tiles[i]));
}
}
示例4: PlaceTile
public void PlaceTile(Point start, Point end)
{
start = start.ConvertToTilePosition(Gc.TILE_SIZE);
end = end.ConvertToTilePosition(Gc.TILE_SIZE);
RemoveExistingTilesBetween(start, end);
PlaceTilesBetween(start, end);
}