コード例 #1
0
        internal void Move2NextLocation(Point nextLocation, ColoBox boxToPlace)
        {
            bool  isValid          = false;
            Point calcNextLocation = nextLocation;

            //isInsideBoundingBox = true;
            locationMachine.CurrentBoxToPlace = boxToPlace;

            //reseting the flag indicates we are hitting a tilted wall
            isMeetingTiltedWall = false;
            int i = 0;

            while (!isValid)
            {
                boxToPlace.MoveOriginTo(calcNextLocation);
                //if we are in a situation that we are placing outside the bounding box (and there is more space to place inside)
                //we need to verify if we crossed back into the internal side of the bounding box. if we did, switch the stateMachine to indicate
                //that state (inside the box)
                if (locationMachine.CurrentlyOutsideTheBox)
                {
                    if (locationMachine.LocationWithinBoundingBox)
                    {
                        locationMachine.INSIDEBOUNDINGBOX.SetCurrent();
                    }
                }
                ++i;
                if (i == 7)
                {
                }

                if (nextSpaceValid(boxToPlace))
                {
                    locationMachine.NextState();


                    //if we are out of the bounding box, the break should not hit until we either step out of the outer bounding box or until
                    //we got back in
                    if (!locationMachine.IsSteppedOutBoundingBox)
                    {
                        break;
                    }
                }
                calcNextLocation = locationMachine.NextLocation;
            }
        }