示例#1
0
    /// <summary>
    /// place road component of the given type after this road
    /// component
    /// </summary>
    /// <param name="type">type of next road component</param>
    /// <returns>position of place road component</returns>
    public Vector3 Place(RoadType type)
    {
        RoadComponent shouldBePlacedRoad = collection.Get(type);
        RoadComponent currentRoad        = collection.GetCurrentRoadComponent();

        currentRoad.SetActive(false);

        // get last placed road
        RoadComponent lastRoad = collection.GetLastRoadComponent();

        // get position of last placed road
        position = lastRoad.GetPosition();
        // move position forwad for finding position of next road
        position.z += planeWidth;
        shouldBePlacedRoad.SetPosition(position); // place new road after the last road
        collection.Place(type);                   // a new road has been placed
        shouldBePlacedRoad.Place();
        collection.Next();                        // update collection current road to next road
        return(position);
    }