示例#1
0
        private bool IsProposedAreaToTheRightOfThis(Area proposedArea, out ProximityTestResult comparisonResult)
        {
            if (proposedArea.TopLeft.X >= BottomRight.X)
            {
                // proposed area is completely to the right of this area.
                if (ItMightBeClose(proposedArea.TopLeft.X, BottomRight.X))
                {
                    if (proposedArea.TopLeft.Y.IsBetween(TopLeft.Y, BottomRight.Y) || proposedArea.BottomRight.Y.IsBetween(TopLeft.Y, BottomRight.Y))
                    {
                        {
                            comparisonResult = new ProximityTestResult(Proximity.VeryClose) { DirectionToOtherObject = Direction.Right, DistanceToClosestObject = proposedArea.TopLeft.X - BottomRight.X, };
                            return true;
                        }
                    }
                }

                {
                    comparisonResult = new ProximityTestResult(Proximity.NotOverlapping);
                    return true;
                }
            }

            comparisonResult = new ProximityTestResult(Proximity.Unknown);
            return false;
        }
示例#2
0
        private bool IsProposedAreaAboveThis(Area proposedArea, out ProximityTestResult comparisonResult)
        {
            if (proposedArea.BottomRight.Y <= TopLeft.Y)
            {
                // porposed area is completely above this area
                if (ItMightBeClose(proposedArea.BottomRight.Y, TopLeft.Y))
                {
                    if (proposedArea.TopLeft.X.IsBetween(TopLeft.X, BottomRight.X) || proposedArea.BottomRight.X.IsBetween(TopLeft.X, BottomRight.X))
                    {
                        {
                            comparisonResult = new ProximityTestResult(Proximity.VeryClose) { DirectionToOtherObject = Direction.Up, DistanceToClosestObject = TopLeft.Y - proposedArea.BottomRight.Y, };
                            return true;
                        }
                    }
                }

                {
                    comparisonResult = new ProximityTestResult(Proximity.NotOverlapping);
                    return true;
                }
            }

            comparisonResult = new ProximityTestResult(Proximity.Unknown);
            return false;
        }