コード例 #1
0
    public void InitNewRoad()
    {
        if (doMakeRandomPath)
        {
            MakeRandomPath();
        }
        else if (doLoadScriptPath)
        {
            MakeScriptedPath();
        }
        else if (doLoadPointPath)
        {
            MakePointPath();
        }

        if (smoothPathIter > 0)
        {
            SmoothPath();
        }

        //Should we build a road mesh along the path?
        if (doBuildRoad && roadBuilder != null)
        {
            roadBuilder.InitRoad(path);
        }

        if (doBuildRoad && semanticSegRoadBuilder != null)
        {
            semanticSegRoadBuilder.InitRoad(path);
        }

        if (doChangeLanes && laneChTrainer != null)
        {
            laneChTrainer.ModifyPath(ref path);
        }

        foreach (GameObject challenge in challenges)        // Init each challenges
        {
            IChallenge chal = challenge.GetComponent <IChallenge>();
            if (chal != null)
            {
                chal.InitChallenge(path);
            }
        }

        if (locationMarkerPrefab != null && path != null)
        {
            int iLocId = 0;
            for (int iN = 0; iN < path.nodes.Count; iN += markerEveryN)
            {
                Vector3    np = path.nodes[iN].pos;
                GameObject go = Instantiate(locationMarkerPrefab, np, Quaternion.identity) as GameObject;
                go.transform.parent = this.transform;
                go.GetComponent <LocationMarker>().id = iLocId;
                iLocId++;
            }
        }

        if (doShowPath && path != null)
        {
            for (int iN = 0; iN < path.nodes.Count; iN++)
            {
                Vector3    np = path.nodes[iN].pos;
                GameObject go = Instantiate(prefab, np, Quaternion.identity) as GameObject;
                go.tag = "pathNode";
                go.transform.parent = this.transform;
            }
        }
    }