Example #1
0
        private int TryPush(IMapObject target, Point position, out Point currentPosition)
        {
            currentPosition = position;
            var initialForce = GetInitialForce(target);

            for (var remainingForce = initialForce; remainingForce > 0; remainingForce--)
            {
                var nextPosition   = Point.GetPointInDirection(currentPosition, direction);
                var movementResult = MovementHelper.MoveObject(target, currentPosition, nextPosition);
                if (!movementResult.Success)
                {
                    return(remainingForce);
                }

                if (!movementResult.NewPosition.Equals(nextPosition))
                {
                    return(0);
                }
                currentPosition = nextPosition;
            }

            return(0);
        }