コード例 #1
0
ファイル: Road.cs プロジェクト: WesleyHendon/DispensaryTycoon
    public VertexPath GetPath(Vehicle vehicleRequestingPath, RoadManager.LaneDirection laneDirection)
    {
        if (IsJunction())
        {
            return(GetRandomTurningPath(vehicleRequestingPath, laneDirection));
        }
        Lane lane = GetLane(laneDirection);

        if (lane != null)
        {
            return(new VertexPath(new BezierPath(lane.GetLaneWaypoints(), false, PathSpace.xyz)));
        }
        else
        {
            return(null);
        }
    }
コード例 #2
0
ファイル: Road.cs プロジェクト: WesleyHendon/DispensaryTycoon
    public VertexPath GetRandomTurningPath(Vehicle vehicleRequestingPath, RoadManager.LaneDirection fromDirection)
    {
        List <Lane> possibleTurnLanes = new List <Lane>();

        switch (fromDirection)
        {
        case RoadManager.LaneDirection.north_north:
            if (LaneExists(RoadManager.LaneDirection.north_north))
            {
                possibleTurnLanes.Add(GetLane(RoadManager.LaneDirection.north_north));
            }
            if (LaneExists(RoadManager.LaneDirection.north_east))
            {
                possibleTurnLanes.Add(GetLane(RoadManager.LaneDirection.north_east));
            }
            if (LaneExists(RoadManager.LaneDirection.north_west))
            {
                possibleTurnLanes.Add(GetLane(RoadManager.LaneDirection.north_west));
            }
            break;

        case RoadManager.LaneDirection.south_south:
            if (LaneExists(RoadManager.LaneDirection.south_south))
            {
                possibleTurnLanes.Add(GetLane(RoadManager.LaneDirection.south_south));
            }
            if (LaneExists(RoadManager.LaneDirection.south_east))
            {
                possibleTurnLanes.Add(GetLane(RoadManager.LaneDirection.south_east));
            }
            if (LaneExists(RoadManager.LaneDirection.south_west))
            {
                possibleTurnLanes.Add(GetLane(RoadManager.LaneDirection.south_west));
            }
            break;

        case RoadManager.LaneDirection.east_east:
            if (LaneExists(RoadManager.LaneDirection.east_east))
            {
                possibleTurnLanes.Add(GetLane(RoadManager.LaneDirection.east_east));
            }
            if (LaneExists(RoadManager.LaneDirection.east_north))
            {
                possibleTurnLanes.Add(GetLane(RoadManager.LaneDirection.east_north));
            }
            if (LaneExists(RoadManager.LaneDirection.east_south))
            {
                possibleTurnLanes.Add(GetLane(RoadManager.LaneDirection.east_south));
            }
            break;

        case RoadManager.LaneDirection.west_west:
            if (LaneExists(RoadManager.LaneDirection.west_west))
            {
                possibleTurnLanes.Add(GetLane(RoadManager.LaneDirection.west_west));
            }
            if (LaneExists(RoadManager.LaneDirection.west_north))
            {
                possibleTurnLanes.Add(GetLane(RoadManager.LaneDirection.west_north));
            }
            if (LaneExists(RoadManager.LaneDirection.west_south))
            {
                possibleTurnLanes.Add(GetLane(RoadManager.LaneDirection.west_south));
            }
            break;
        }
        Lane randomLane = possibleTurnLanes[Random.Range(0, possibleTurnLanes.Count)];

        vehicleRequestingPath.currentDirection = RoadManager.GetEndDirection(randomLane.laneDirection);
        return(new VertexPath(new BezierPath(randomLane.GetLaneWaypoints(), false, PathSpace.xyz)));
    }