예제 #1
0
        private void Move(int i, IPredictorable mover)
        {
            while (true)
            {
                var newPosition = mover.Peek(balls[i].Position);
                var border      = space.GetBorder(newPosition);

                if (Inside(border))
                {
                    if (IsFreeSpace(newPosition))
                    {
                        MoveToFreeSpace(i, newPosition);
                        break;
                    }
                    else if (IsBrick(newPosition))
                    {
                        RemoveBrick(newPosition);
                    }
                    border = Reflector.CreateBorder(ballsDirections[balls[i].Name]);
                }

                ballsDirections[balls[i].Name] = border.ChangeDirection(ballsDirections[balls[i].Name]);
                mover = CreatePredicator(i);
            }
        }
예제 #2
0
        private void Move(int i, IPredictorable mover)
        {
            while (true)
            {
                var newPosition = mover.Peek(balls[i].Position);
                var border = space.GetBorder(newPosition);

                if (Inside(border))
                {
                    if (IsFreeSpace(newPosition))
                    {
                        MoveToFreeSpace(i, newPosition);
                        break;
                    }
                    else if (IsBrick(newPosition))
                    {
                        RemoveBrick(newPosition);
                    }
                    border = Reflector.CreateBorder(ballsDirections[balls[i].Name]);
                }

                ballsDirections[balls[i].Name] = border.ChangeDirection(ballsDirections[balls[i].Name]);
                mover = CreatePredicator(i);
            }
            

        }