private static bool CornerCheck(Brick brick) { return (Math.Abs(Canvas.GetLeft(brick)) < 0.1 || Math.Abs(Canvas.GetLeft(brick) - 19 * Squaresize) < 0.1) && (Math.Abs(Canvas.GetTop(brick)) < 0.1 || Math.Abs(Canvas.GetTop(brick) - 19 * Squaresize) < 0.1); }
internal static Point GetCoordinates(Brick element) { for (var j = 0; j < FieldElementsArray.GetLength(0); j++) { for (var i = 0; i < FieldElementsArray.GetLength(1); i++) { if (FieldElementsArray[i, j] == element) { return new Point(i, j); } } } var x = Math.Round(Canvas.GetLeft(element) / Squaresize); var y = Math.Round(Canvas.GetTop(element) / Squaresize); return new Point(x, y); }
private static void AddBrick(ushort x, ushort y) { if (FieldElementsArray[x, y] != null) return; var tempBrick = new Brick { Width = Squaresize, Height = Squaresize, }; MainWindow.Wm.Battlfield.Children.Add(tempBrick); Canvas.SetLeft(tempBrick, Squaresize * x); Canvas.SetTop(tempBrick, Squaresize * y); FieldElementsArray[x, y] = tempBrick; BricksList.Add(tempBrick); }
internal static double FindDirectDistance(Brick brick1, Brick brick2) { var x1 = Canvas.GetLeft(brick1); var y1 = Canvas.GetTop(brick1); var x2 = Canvas.GetLeft(brick2); var y2 = Canvas.GetTop(brick2); return Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2)); }