Exemple #1
0
    public void GetTrackPath(RollingStock car)
    {
        PathMade++;
        ClearPath(car);
        // if we change swithces in indication mode
        if (IndicationManager.Instance.IsPathIndicate)
        {
            IndicationManager.Instance.TurnPathIndicationOff();
            IndicationManager.Instance.IsPathIndicate = true;
        }

        SetEachPathClosePaths();
        TrackPathUnit currentTrack = car.OwnTrack;

        tempLeft  = currentTrack.LeftTrackPathUnit;
        tempRight = currentTrack.RightTrackPathUnit;

        count      = Constants.PATHS_NUM / 2;
        countLeft  = count;
        countRight = count;
        TrackPathUnit [] pathOwn = new TrackPathUnit [Constants.PATHS_NUM];
        pathOwn [count] = currentTrack;

        while (tempLeft != null || tempRight != null)
        {
            if (tempLeft != null)
            {
                pathOwn[countLeft - 1] = tempLeft;
                countLeft--;
                tempLeft = tempLeft.LeftTrackPathUnit;
            }
            if (tempRight != null)
            {
                pathOwn [countRight + 1] = tempRight;
                countRight++;
                tempRight = tempRight.RightTrackPathUnit;
            }
        }
        car.SetPathToRS(pathOwn, countLeft, countRight);
        PathMade--;
        // if all paths of all compositions are made
        if (PathMade == 0)
        {
            print("PathMade");
            EventManager.PathUpdated();
        }
    }