public bool Equals(PuzzlePiecePosition other) { if (other == null) { return false; } return Piece == other.Piece && Position == other.Position; }
private Point GetExitDirection(PuzzlePiecePosition piece) { Point minBounds; Point maxBounds; CalculateBounds(new[] { piece.Piece }, out minBounds, out maxBounds); foreach (var kvp in _exitTests) { Point direction = kvp.Key; var test = kvp.Value; var testPosition = piece; Point vector = Point.Zero; while (true) { if (test(testPosition.CurrentPoints, minBounds, maxBounds)) { return direction; } testPosition = testPosition.Move(direction); vector = Point.Add(vector, direction); PuzzleMove testMove = new PuzzleMove(this, piece.Piece, vector); if (!testMove.IsLegal()) { break; } } } //if (piece.CurrentPoints.All(p => p.X > maxBounds.X)) //{ // return new Point(1, 0, 0); //} //if (piece.CurrentPoints.All(p => p.X < minBounds.X)) //{ // return new Point(-1, 0, 0); //} //if (piece.CurrentPoints.All(p => p.Y > maxBounds.Y)) //{ // return new Point(0, 1, 0); //} //if (piece.CurrentPoints.All(p => p.Y < minBounds.Y)) //{ // return new Point(0, -1, 0); //} //if (piece.CurrentPoints.All(p => p.Z > maxBounds.Z)) //{ // return new Point(0, 0, 1); //} //if (piece.CurrentPoints.All(p => p.Z < minBounds.Z)) //{ // return new Point(0, 0, -1); //} return Point.Zero; }