Пример #1
0
    public State StartTree()
    {
        // Check future positions for collisions
        CheckForCollisions();

        // If not currently switching to the left lane
        if (!switchingLanes)
        {
            // Steer to the next point in the route
            car.SteerToNextPoint();
            if (car.isInLeftLane)
            {
                car.speed = car.leftLaneSpeed;
                // Check if future point of collision has been passed, if one exists
                if (CheckIfPastPointOfCollision())
                {
                    // Check the radius for other cars
                    if (CheckRadius() == State.SUCCESSFUL)
                    {
                        car.isInLeftLane = false;
                    }
                }
            }
        }
        else
        {
            car.SwitchingLanes();
            switchingLanes = false;
        }

        if (!returnToMainTree)
        {
            return(State.RUNNING);
        }
        else
        {
            return(State.SUCCESSFUL);
        }
    }