Esempio n. 1
0
    public void SetCarsToBackSide(float position, int carNum)
    {
        RollingStock rs = GetCar(carNum);

        //clear engine
        if (rs.IsEngine)
        {
            rs.Engine.IsActive = false;
            rs.Engine.IsPlayer = false;
        }
        //clear all connections
        ClearConnections(rs);
        //release prev TC
        tempTC = rs.OwnTrackCircuit;
        // set new TPU
        rs.OwnTrack = TrackPath.Instance.GetTrackPathUnitByName(Constants.TRACK_BACKSIDE);
        // set new TC
        rs.OwnTrackCircuit = rs.OwnTrack.TrackCircuit;
        // release prev tracks
        ReleaseStartTracks(rs, tempTC);
        //set position
        rs.OwnPosition = position;
        //set bogeys the same trackpathunit
        rs.ResetBogeys();

        CompositionManager.Instance.FormCompositionOnBackSide(rs);
        IndicationManager.Instance.UpdateCouplerIndication();
    }
Esempio n. 2
0
    public void SetCarsPosition(string trackName, float position, int [] carsNums, int activeEngine = 0)
    {
        RollingStock [] cars   = new RollingStock [carsNums.Length];
        RollingStock    rs     = GetCar(carsNums [0]);
        RollingStock    actEng = GetCar(activeEngine);

        // fill array of cars
        cars [0] = rs;
        //clear all connections
        ClearConnections(rs);

        //release prev TC
        tempTC = rs.OwnTrackCircuit;

        rs.OwnTrack        = TrackPath.Instance.GetTrackPathUnitByName(trackName);
        rs.OwnTrackCircuit = rs.OwnTrack.TrackCircuit;

        ReleaseStartTracks(rs, tempTC);
        //set position
        rs.OwnPosition = position;
        //set bogeys the same trackpathunit
        rs.ResetBogeys();

        // if one car no need
        for (int i = 1; i < carsNums.Length; i++)
        {
            //take previous car
            rs = GetCar(carsNums [i - 1]);
            // get next car
            RollingStock rightCar = GetCar(carsNums [i]);
            // fill array of cars
            cars [i] = rightCar;
            //clear all connections
            ClearConnections(rightCar);
            //release prev TC
            tempTC                   = rightCar.OwnTrackCircuit;
            rightCar.OwnTrack        = rs.OwnTrack;
            rightCar.OwnTrackCircuit = rs.OwnTrack.TrackCircuit;
            ReleaseStartTracks(rightCar, tempTC);

            rs.RSConnection.InitConnection(rightCar.RSConnection);
            rightCar.ResetBogeys();
        }
        CompositionManager.Instance.FormCompositionsAfterSettingCars(cars, actEng);
        IndicationManager.Instance.UpdateCouplerIndication();
    }