Example #1
0
    public void ClearTrackLayout()
    {
        var children = new List <GameObject>();

        foreach (Transform child in transform)
        {
            children.Add(child.gameObject);
        }
        if (Application.isEditor)
        {
            children.ForEach(child => DestroyImmediate(child));
        }
        else
        {
            children.ForEach(child => Destroy(child));
        }

        trackCollection.Clear();
        if (trackObjects != null)
        {
            trackObjects.Clear();
        }
        else
        {
            trackObjects = new List <GameObject>();
        }
        if (junctionObjects != null)
        {
            junctionObjects.Clear();
        }
        else
        {
            junctionObjects = new List <GameObject>();
        }
    }
        public override TrackCollection Sort(BackgroundWorker backgroundWorker, TrackCollection trackCollection, TrackCollection fixedTracks)
        {
            var nbCollections    = fixedTracks.Count;
            var resultCollection = new TrackCollection();
            var collections      = new List <TrackCollection>();
            int numCollection    = 0;

            fixedTracks.ForEach(delegate(Track track)
            {
                collections.Add(new TrackCollection());
                int pos = trackCollection.IndexOf(track);
                if (pos != -1)
                {
                    for (int i = 0; i < pos; i++)
                    {
                        collections[numCollection].Add(trackCollection[i]);
                    }
                    numCollection++;

                    collections.Add(new TrackCollection());
                    collections[numCollection].Add(trackCollection[pos]); // add the fixed Track
                    numCollection++;

                    trackCollection.RemoveRange(0, pos + 1);
                }
            });

            collections.Add(new TrackCollection());
            for (int i = 0; i < trackCollection.Count; i++)
            {
                collections[numCollection].Add(trackCollection[i]);
            }
            numCollection++;
            trackCollection.Clear();

            for (int i = 0; i < collections.Count; i++)
            {
                TrackCollection newCollection;
                newCollection = Sort(backgroundWorker, collections[i]);

                if (!newCollection.Equals(collections[i]))
                {
                    var pos = collections.IndexOf(collections[i]);
                    collections[pos] = newCollection;
                }
            }

            collections.ForEach(delegate(TrackCollection collection)
            {
                resultCollection.Concat(collection);
            });

            return(resultCollection);
        }
Example #3
0
    public static void PopulateTrackCollection(TrackLayout layout, TrackCollection target)
    {
        target.Clear();
        foreach (TrackSectionSerializer serializedTrack in layout.trackSections)
        {
            TrackSection track = serializedTrack.ToTrackSection();
            if (!target.Add(track, track.index))
            {
                Debug.LogError("Could not add track section to collection at index " + track.index);
            }
        }

        foreach (TrackJunctionSerializer serializedJunction in layout.trackJunctions)
        {
            TrackJunction track = serializedJunction.ToTrackJunction();
            if (!target.Add(track, track.index))
            {
                Debug.LogError("Could not add track junction to collection at index " + track.index);
            }
        }
    }
Example #4
0
 public void ResetCollection()
 {
     TrackCollection.Clear();
     CurrentTrack = 0;
 }