////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    void Update()
    {
        if (GameUI.manage.gameFinished)
        {
            vehicleMode = VehicleMode.AICar;
        }


        if (!carSetting.automaticGear)
        {
            if (Input.GetKeyDown("page up"))
            {
                ShiftUp();
            }
            if (Input.GetKeyDown("page down"))
            {
                ShiftDown();
            }
        }

        if (vehicleMode == VehicleMode.Player && GameUI.manage.gameStarted)
        {
            if (AIControl.manage.controlMode == ControlMode.Mobile)
            {
                if (GameUI.manage.panels.gamePlay.buttonsUI.activeSelf)
                {
                    steer = Mathf.MoveTowards(steer, steerAmount, Time.deltaTime * (10.0f * PlayerPrefs.GetFloat("Sensitivity")));
                }
                else if (GameUI.manage.panels.gamePlay.accelUI.activeSelf)
                {
                    steer = Mathf.MoveTowards(steer, Input.acceleration.x * 3.0f, (Time.deltaTime * 25.0f) * PlayerPrefs.GetFloat("Sensitivity"));
                }
            }
        }
    }
Exemple #2
0
    public IEnumerator Transition()
    {
        isTransitioning = true;
        velocity        = Vector2.zero;

        if (VehicleMode == VehicleMode.Land)
        {
            WheelAnimator[0].SetTrigger("CloseWheels");
            WheelAnimator[1].SetTrigger("CloseWheels");
            PropAnimator.SetTrigger("OpenProp");
            while (!PropAnimator.GetCurrentAnimatorStateInfo(0).IsName("Prop_Spin") &&
                   !WheelAnimator[0].GetCurrentAnimatorStateInfo(0).IsName("Wheel_Off"))
            {
                yield return(new WaitForSeconds(Time.deltaTime));
            }

            VehicleMode = VehicleMode.Water;
        }
        else
        {
            WheelAnimator[0].SetTrigger("OpenWheels");
            WheelAnimator[1].SetTrigger("OpenWheels");
            PropAnimator.SetTrigger("CloseProp");
            while (!PropAnimator.GetCurrentAnimatorStateInfo(0).IsName("Prop_Off") &&
                   !WheelAnimator[0].GetCurrentAnimatorStateInfo(0).IsName("Wheel_On"))
            {
                yield return(new WaitForSeconds(Time.deltaTime));
            }

            VehicleMode = VehicleMode.Land;
        }

        isTransitioning = false;
    }
Exemple #3
0
 public Vehicle(string strXml, string strVin, VehicleMode mode, int nGroupId)
 {
     XML          = strXml;
     VIN          = strVin;
     Vehicle_Mode = mode;
     GroupId      = nGroupId;
     VectoVehicle = null;
 }
Exemple #4
0
        public bool AddVehicle(string strXml, string strVin, VehicleMode mode, int nGroupId)
        {
            try {
                this.Database.ExecuteSqlCommand("Insert into Vehicle Values(@VIN, @XML, @Vehicle_Mode, @GroupId)",
                                                new SqlParameter("VIN", strVin),
                                                new SqlParameter("XML", strXml),
                                                new SqlParameter("Vehicle_Mode", mode),
                                                new SqlParameter("GroupId", nGroupId));
                return(true);
            }
            catch {
            }

            return(false);
        }
Exemple #5
0
        public bool InitializeFromXMLFile(VehicleMode mode, string strFilename)
        {
            try
            {
                using (var rdr = new StreamReader(strFilename))
                {
                    using (XmlReader reader = XmlReader.Create(rdr))
                    {
                        return(InitializeFromXML(mode, reader));
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return(false);
        }
Exemple #6
0
        public bool InitializeFromXML(VehicleMode mode, XmlReader rdr)
        {
            try
            {
                //Reco3_Defines.DeclarationNamespace;
                if (Vecto_Vehicle_Declaration != null)
                {
                    Vecto_Vehicle_Declaration = null;
                }
                if (Vecto_Vehicle_Engineering != null)
                {
                    Vecto_Vehicle_Engineering = null;
                }

                Vehicle_Mode = mode;
                switch (Vehicle_Mode)
                {
                case VehicleMode.VectoDeclaration:
                    Vecto_Vehicle_Declaration = new XmlSerializer(typeof(Scania.Vehicle.TUG.Declaration.VectoDeclarationJobType)).Deserialize(rdr)
                                                as Scania.Vehicle.TUG.Declaration.VectoDeclarationJobType;



                    break;

                case VehicleMode.VectoEngineering:
                    Vecto_Vehicle_Engineering = new XmlSerializer(typeof(Scania.Vehicle.TUG.Engineering.VectoJobEngineeringType)).Deserialize(rdr)
                                                as Scania.Vehicle.TUG.Engineering.VectoJobEngineeringType;
                    break;

                default:
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return(false);
        }
    void FixedUpdate()
    {
        // speed of car
        speed = myRigidbody.velocity.magnitude * 2.7f;

        if (speed < lastSpeed - 10 && slip < 10)
        {
            slip = lastSpeed / 15;
        }

        lastSpeed = speed;

        if (slip2 != 0.0f)
        {
            slip2 = Mathf.MoveTowards(slip2, 0.0f, 0.1f);
        }


        myRigidbody.centerOfMass = carSetting.shiftCentre;


        if (vehicleMode == VehicleMode.Player && GameUI.manage.gameStarted)
        {
            if (AIControl.manage.controlMode == ControlMode.Simple)
            {
                accel = 0;
                brake = false;
                shift = false;

                if (carWheels.wheels.frontWheelDrive || carWheels.wheels.backWheelDrive)
                {
                    steer = Input.GetAxis("Horizontal");
                    accel = Input.GetAxis("Vertical");
                    brake = Input.GetButton("Jump");
                    shift = Input.GetKey(KeyCode.LeftShift) | Input.GetKey(KeyCode.RightShift);
                }

                if (!carSetting.automaticGear)
                {
                    if (Input.GetKeyDown("page up"))
                    {
                        ShiftUp();
                    }
                    if (Input.GetKeyDown("page down"))
                    {
                        ShiftDown();
                    }
                }
            }
            else if (AIControl.manage.controlMode == ControlMode.Mobile)
            {
                if (accelFwd != 0)
                {
                    accel = accelFwd;
                }
                else
                {
                    accel = accelBack;
                }

                if (GameUI.manage.panels.gamePlay.buttonsUI.activeSelf)
                {
                    steer = Mathf.MoveTowards(steer, steerAmount, 0.1f);
                }
                else if (GameUI.manage.panels.gamePlay.accelUI.activeSelf)
                {
                    steer = Mathf.MoveTowards(steer, Input.acceleration.x * 2.0f, 0.4f);
                }
            }
        }
        else if (vehicleMode == VehicleMode.AICar && GameUI.manage.gameStarted)
        {
            shift = false;


            if (!GameUI.manage.gameFinished)
            {
                vehicleMode = VehicleMode.Player;
            }


            steer = AIVehicle.AISteer;
            accel = AIVehicle.AIAccel;
            brake = AIVehicle.AIBrake;
        }
        else
        {
            steer = 0;
            shift = false;

            if (vehicleMode == VehicleMode.Player)
            {
                if (AIControl.manage.controlMode == ControlMode.Simple)
                {
                    accel = Input.GetAxis("Vertical");
                }
                else
                {
                    accel = accelFwd;
                }
            }
            else
            {
                accel = 1.0f;
            }
        }


        if (!carWheels.wheels.frontWheelDrive && !carWheels.wheels.backWheelDrive)
        {
            accel = 0.0f;
        }

        if (carSetting.carSteer)
        {
            carSetting.carSteer.localEulerAngles = new Vector3(steerCurAngle.x, steerCurAngle.y, steerCurAngle.z + (steer * -120.0f));
        }

        if (carSetting.automaticGear && (currentGear == 1) && (accel < 0.0f))
        {
            if (speed < 5.0f)
            {
                ShiftDown();
            }
        }

        else if (carSetting.automaticGear && (currentGear == 0) && (accel > 0.0f))
        {
            if (speed < 5.0f)
            {
                ShiftUp();
            }
        }
        else if (carSetting.automaticGear && (motorRPM > carSetting.shiftUpRPM) && (accel > 0.0f) && speed > 10.0f && !brake)
        {
            ShiftUp();
        }
        else if (carSetting.automaticGear && (motorRPM < carSetting.shiftDownRPM) && (currentGear > 1))
        {
            ShiftDown();
        }


        if (speed < 1.0f)
        {
            Backward = true;
        }


        if (currentGear == 0 && Backward == true)
        {
            carSetting.shiftCentre.z = -accel / -5;
            if (speed < carSetting.gears[0] * -10)
            {
                accel = -accel;
            }
        }
        else
        {
            Backward = false;
            if (currentGear > 0)
            {
                carSetting.shiftCentre.z = -(accel / currentGear) / -5;
            }
        }



        carSetting.shiftCentre.x = -Mathf.Clamp(steer * (speed / 100), -0.03f, 0.03f);


        // Brake Lights

        foreach (Light brakeLight in carLights.brakeLights)
        {
            if (brake || accel < 0 || speed < 1.0f)
            {
                brakeLight.intensity = Mathf.MoveTowards(brakeLight.intensity, 8, 0.5f);
            }
            else
            {
                brakeLight.intensity = Mathf.MoveTowards(brakeLight.intensity, 0, 0.5f);
            }

            brakeLight.enabled = brakeLight.intensity == 0 ? false : true;
        }


        // Reverse Lights

        foreach (Light WLight in carLights.reverseLights)
        {
            if (speed > 2.0f && currentGear == 0)
            {
                WLight.intensity = Mathf.MoveTowards(WLight.intensity, 8, 0.5f);
            }
            else
            {
                WLight.intensity = Mathf.MoveTowards(WLight.intensity, 0, 0.5f);
            }
            WLight.enabled = WLight.intensity == 0 ? false : true;
        }



        wantedRPM = (5500.0f * accel) * 0.1f + wantedRPM * 0.9f;

        float rpm             = 0.0f;
        int   motorizedWheels = 0;
        bool  floorContact    = false;
        int   currentWheel    = 0;


        if (currentGear > 0)
        {
            myRigidbody.AddRelativeTorque(0, steer * 10000, 0);
        }
        else
        {
            myRigidbody.AddRelativeTorque(0, -steer * 10000, 0);
        }


        foreach (WheelComponent w in wheels)
        {
            WheelHit      hit;
            WheelCollider col = w.collider;

            if (w.drive)
            {
                if (!NeutralGear && brake && currentGear < 2)
                {
                    rpm += accel * carSetting.idleRPM;
                }
                else
                {
                    if (!NeutralGear)
                    {
                        rpm += col.rpm;
                    }
                    else
                    {
                        rpm += (carSetting.idleRPM * accel);
                    }
                }

                motorizedWheels++;
            }


            if (brake || accel < 0.0f)
            {
                if ((accel < 0.0f) || (brake && (w == wheels[2] || w == wheels[3])))
                {
                    if (brake && (accel > 0.0f))
                    {
                        slip = Mathf.Lerp(slip, 5.0f, accel * 0.01f);
                    }
                    else if (speed > 1.0f)
                    {
                        slip = Mathf.Lerp(slip, 1.0f, 0.002f);
                    }
                    else
                    {
                        slip = Mathf.Lerp(slip, 1.0f, 0.02f);
                    }

                    wantedRPM       = 0.0f;
                    col.brakeTorque = carSetting.brakePower;
                    w.rotation      = w_rotate;
                }
            }
            else
            {
                col.brakeTorque = accel == 0 || NeutralGear ? col.brakeTorque = 1000 : col.brakeTorque = 0;


                slip = speed > 0.0f ?
                       (speed > 100 ? slip = Mathf.Lerp(slip, 1.0f + Mathf.Abs(steer), 0.02f) : slip = Mathf.Lerp(slip, 1.5f, 0.02f))
    : slip = Mathf.Lerp(slip, 0.01f, 0.02f);

                w_rotate = w.rotation;
            }

            WheelFrictionCurve fc = col.forwardFriction;

            fc.asymptoteValue   = 5000.0f;
            fc.extremumSlip     = 2.0f;
            fc.asymptoteSlip    = 20.0f;
            fc.stiffness        = carSetting.stiffness / (slip + slip2);
            col.forwardFriction = fc;
            fc           = col.sidewaysFriction;
            fc.stiffness = carSetting.stiffness / (slip + slip2);

            fc.extremumSlip = 0.3f + Mathf.Abs(steer);

            col.sidewaysFriction = fc;


            if (shift && (currentGear > 1 && speed > 50.0f) && shifmotor)
            {
                if (powerShift == 0)
                {
                    shifmotor = false;
                }

                powerShift = Mathf.MoveTowards(powerShift, 0.0f, Time.deltaTime * 10.0f);

                carSounds.nitro.volume = Mathf.Lerp(carSounds.nitro.volume, 1.0f, Time.deltaTime * 10.0f);

                if (!carSounds.nitro.isPlaying)
                {
                    carSounds.nitro.GetComponent <AudioSource>().Play();
                }

                shifting  = true;
                curTorque = powerShift > 0 ? carSetting.shiftPower / slipRate : carSetting.carPower / slipRate;
                carParticles.shiftParticle1.emissionRate = Mathf.Lerp(carParticles.shiftParticle1.emissionRate, powerShift > 0 ? 50 : 0, Time.deltaTime * 10.0f);
                carParticles.shiftParticle2.emissionRate = Mathf.Lerp(carParticles.shiftParticle2.emissionRate, powerShift > 0 ? 50 : 0, Time.deltaTime * 10.0f);
            }
            else
            {
                if (powerShift > 20)
                {
                    shifmotor = true;
                }

                carSounds.nitro.volume = Mathf.MoveTowards(carSounds.nitro.volume, 0.0f, Time.deltaTime * 2.0f);

                if (carSounds.nitro.volume == 0)
                {
                    carSounds.nitro.Stop();
                }

                shifting   = false;
                powerShift = Mathf.MoveTowards(powerShift, 100.0f, Time.deltaTime * 5.0f);
                curTorque  = carSetting.carPower / slipRate;
                carParticles.shiftParticle1.emissionRate = Mathf.Lerp(carParticles.shiftParticle1.emissionRate, 0, Time.deltaTime * 10.0f);
                carParticles.shiftParticle2.emissionRate = Mathf.Lerp(carParticles.shiftParticle2.emissionRate, 0, Time.deltaTime * 10.0f);
            }


            w.rotation            = Mathf.Repeat(w.rotation + Time.deltaTime * col.rpm * 360.0f / 60.0f, 360.0f);
            w.rotation2           = Mathf.Lerp(w.rotation2, col.steerAngle, 0.1f);
            w.wheel.localRotation = Quaternion.Euler(w.rotation, w.rotation2, 0.0f);


            Vector3 lp = w.wheel.localPosition;

            if (col.GetGroundHit(out hit))
            {
                if (carParticles.brakeParticlePerfab)
                {
                    if (Particle[currentWheel] == null)
                    {
                        Particle[currentWheel]                  = Instantiate(carParticles.brakeParticlePerfab, w.wheel.position, Quaternion.identity) as GameObject;
                        Particle[currentWheel].name             = "WheelParticle";
                        Particle[currentWheel].transform.parent = transform.transform;

                        Particle[currentWheel].AddComponent <AudioSource>();
                        Particle[currentWheel].GetComponent <AudioSource>().maxDistance           = 50;
                        Particle[currentWheel].GetComponent <AudioSource>().spatialBlend          = 1;
                        Particle[currentWheel].GetComponent <AudioSource>().dopplerLevel          = 5;
                        Particle[currentWheel].GetComponent <AudioSource>().rolloffMode           = AudioRolloffMode.Custom;
                        Particle[currentWheel].GetComponent <AudioSource>().outputAudioMixerGroup = carSounds.brakeAudioMixer;
                    }


                    var  pc        = Particle[currentWheel].GetComponent <ParticleSystem>();
                    bool WGrounded = false;

                    slipRate = 1.0f;

                    for (int i = 0; i < carSetting.hitGround.Length; i++)
                    {
                        if (hit.collider.CompareTag(carSetting.hitGround[i].tag))
                        {
                            WGrounded = carSetting.hitGround[i].grounded;

                            if ((brake || Mathf.Abs(hit.sidewaysSlip) > 0.3f) && speed > 1)
                            {
                                Particle[currentWheel].GetComponent <AudioSource>().clip = carSetting.hitGround[i].brakeSound;
                            }
                            else if (Particle[currentWheel].GetComponent <AudioSource>().clip != carSetting.hitGround[i].groundSound && !Particle[currentWheel].GetComponent <AudioSource>().isPlaying)
                            {
                                Particle[currentWheel].GetComponent <AudioSource>().clip = carSetting.hitGround[i].groundSound;
                            }

                            Particle[currentWheel].GetComponent <ParticleSystem>().startColor = carSetting.hitGround[i].brakeColor;
                        }
                    }


                    if (WGrounded)
                    {
                        GameUI.manage.carPenalty = true;
                        if (speed > 70)
                        {
                            w.collider.brakeTorque = 2000;
                        }
                    }
                    else
                    {
                        GameUI.manage.carPenalty = false;
                    }


                    if (WGrounded && speed > 5 && !brake)
                    {
                        pc.enableEmission = true;
                        pc.emissionRate   = Mathf.Lerp(pc.emissionRate, 100.0f, 0.1f);

                        GameUI.manage.driftAmount = 0;
                        GameUI.manage.canDrift    = false;

                        Particle[currentWheel].GetComponent <AudioSource>().volume = 0.5f;

                        if (!Particle[currentWheel].GetComponent <AudioSource>().isPlaying)
                        {
                            Particle[currentWheel].GetComponent <AudioSource>().Play();
                        }
                    }
                    else if ((brake || Mathf.Abs(hit.sidewaysSlip) > 0.2f) && speed > 1)
                    {
                        if ((accel < 0.0f) || ((brake || Mathf.Abs(hit.sidewaysSlip) > 0.2f) && (w == wheels[2] || w == wheels[3])))
                        {
                            pc.emissionRate   = Mathf.Lerp(pc.emissionRate, 100.0f, 0.5f);
                            pc.enableEmission = true;

                            if (!Particle[currentWheel].GetComponent <AudioSource>().isPlaying)
                            {
                                Particle[currentWheel].GetComponent <AudioSource>().Play();
                            }

                            Particle[currentWheel].GetComponent <AudioSource>().volume = 10;


                            if (speed > 20.0f && Mathf.Abs(hit.sidewaysSlip) > 0.1f && GameUI.manage.canDrift)
                            {
                                GameUI.manage.driftAmount += 1;
                            }
                            else
                            {
                                GameUI.manage.driftAmount = 0;
                                GameUI.manage.canDrift    = false;
                            }
                        }
                    }
                    else
                    {
                        pc.emissionRate = Mathf.Lerp(pc.emissionRate, 0.0f, 0.05f);

                        if (pc.emissionRate < 2.0f)
                        {
                            GameUI.manage.driftAmount = 0;
                            GameUI.manage.canDrift    = false;
                            pc.enableEmission         = false;
                        }

                        Particle[currentWheel].GetComponent <AudioSource>().volume = Mathf.Lerp(Particle[currentWheel].GetComponent <AudioSource>().volume, 0, Time.deltaTime * 10.0f);
                    }
                }

                lp.y        -= Vector3.Dot(w.wheel.position - hit.point, transform.TransformDirection(0, 1, 0) / transform.lossyScale.x) - (col.radius);
                lp.y         = Mathf.Clamp(lp.y, -10.0f, w.pos_y);
                floorContact = floorContact || (w.drive);
            }
            else
            {
                if (Particle[currentWheel] != null)
                {
                    var pc = Particle[currentWheel].GetComponent <ParticleSystem>();
                    pc.emissionRate = Mathf.Lerp(pc.emissionRate, 0.0f, 0.1f);

                    if (pc.emissionRate < 2.0f)
                    {
                        GameUI.manage.driftAmount = 0;
                        GameUI.manage.canDrift    = false;
                        pc.enableEmission         = false;
                    }
                }

                lp.y = w.startPos.y - carWheels.setting.Distance;
                myRigidbody.AddForce(Vector3.down * 10000);
            }

            currentWheel++;
            w.wheel.localPosition = lp;
        }


        if (motorizedWheels > 1)
        {
            rpm = rpm / motorizedWheels;
        }

        motorRPM = 0.95f * motorRPM + 0.05f * Mathf.Abs(rpm * carSetting.gears[currentGear]);
        if (motorRPM > 5500.0f)
        {
            motorRPM = 5200.0f;
        }


        int index = (int)(motorRPM / efficiencyTableStep);

        if (index >= efficiencyTable.Length)
        {
            index = efficiencyTable.Length - 1;
        }
        if (index < 0)
        {
            index = 0;
        }


        float newTorque = curTorque * carSetting.gears[currentGear] * efficiencyTable[index];

        foreach (WheelComponent w in wheels)
        {
            WheelCollider col = w.collider;

            if (w.drive)
            {
                if (Mathf.Abs(col.rpm) > Mathf.Abs(wantedRPM))
                {
                    col.motorTorque = 0;
                }
                else
                {
                    float curTorqueCol = col.motorTorque;

                    if (!brake && accel != 0 && NeutralGear == false)
                    {
                        if ((speed < carSetting.LimitForwardSpeed && currentGear > 0) ||
                            (speed < carSetting.LimitBackwardSpeed && currentGear == 0))
                        {
                            col.motorTorque = curTorqueCol * 0.9f + newTorque * 1.0f;
                        }
                        else
                        {
                            col.motorTorque = 0;
                            col.brakeTorque = 0;
                        }
                    }
                    else
                    {
                        col.motorTorque = 0;
                    }
                }
            }

            if (brake || slip2 > 2.0f)
            {
                col.steerAngle = Mathf.Lerp(col.steerAngle, steer * w.maxSteer, 0.05f);
            }
            else
            {
                float SteerAngle = Mathf.Clamp(speed / carSetting.maxSteerAngle, 1.0f, carSetting.maxSteerAngle);
                col.steerAngle = steer * (w.maxSteer / SteerAngle);
            }
        }

        // calculate pitch (keep it within reasonable bounds)
        Pitch = Mathf.Clamp(1.2f + ((motorRPM - carSetting.idleRPM) / (carSetting.shiftUpRPM - carSetting.idleRPM)), 1.0f, 10.0f);

        shiftTime = Mathf.MoveTowards(shiftTime, 0.0f, 0.1f);

        if (Pitch == 1)
        {
            carSounds.IdleEngine.volume = Mathf.Lerp(carSounds.IdleEngine.volume, 1.0f, 0.1f);
            carSounds.LowEngine.volume  = Mathf.Lerp(carSounds.LowEngine.volume, 0.5f, 0.1f);
            carSounds.HighEngine.volume = Mathf.Lerp(carSounds.HighEngine.volume, 0.0f, 0.1f);
        }
        else
        {
            carSounds.IdleEngine.volume = Mathf.Lerp(carSounds.IdleEngine.volume, 1.8f - Pitch, 0.1f);

            if ((Pitch > PitchDelay || accel > 0) && shiftTime == 0.0f)
            {
                carSounds.LowEngine.volume  = Mathf.Lerp(carSounds.LowEngine.volume, 0.0f, 0.2f);
                carSounds.HighEngine.volume = Mathf.Lerp(carSounds.HighEngine.volume, 1.0f, 0.1f);
            }
            else
            {
                carSounds.LowEngine.volume  = Mathf.Lerp(carSounds.LowEngine.volume, 0.5f, 0.1f);
                carSounds.HighEngine.volume = Mathf.Lerp(carSounds.HighEngine.volume, 0.0f, 0.2f);
            }

            carSounds.HighEngine.pitch = Pitch;
            carSounds.LowEngine.pitch  = Pitch;

            PitchDelay = Pitch;
        }
    }
Exemple #8
0
        /// <summary>
        /// Zmiana wartosci <see cref="ModeProperty"/>
        /// </summary>
        /// <param name="o"></param>
        /// <param name="e"></param>
        public static object ModePropertyChanged(DependencyObject o, object e)
        {
            VehicleMode mode = (VehicleMode)e;

            if (mode == VehicleMode.None)
            {
                return(e);
            }

            VehicleControl vehicleControl = (VehicleControl)o;

            switch (mode)
            {
            case VehicleMode.Arrival:
            {
                vehicleControl.MoveVehicle.MoveOnArrival();
                break;
            }

            case VehicleMode.Departure:
            {
                VehicleViewModel vehicleVM = (VehicleViewModel)vehicleControl.DataContext;

                vehicleControl.MoveVehicle.MoveOnDeparture(vehicleVM.Lane, DI.laneDirectionPickerVM.NumberOfLanes + 1, vehicleVM.DirectionPicked);

                VehicleStorage.RemoveVehicle(vehicleVM.Lane);

                //jesli jeszcze jest jakis pojazd na wlocie to pierwszemu jest wlaczany
                //aby umozliwic operacje DragDrop
                if (VehicleStorage.GetLane(vehicleVM.Lane).Count > 0)
                {
                    VehicleStorage.GetFirstOnLane(vehicleVM.Lane).Enabled = true;
                }

                //ustawienie trybu kazdego pojazdu na VehicleMode.Lane, aby poruszyl sie na pasie
                //gdy ten pojazd odjedzie
                foreach (VehicleViewModel VM in VehicleStorage.GetLane(vehicleVM.Lane))
                {
                    VM.QueuePosition -= 1;

                    VM.Mode = VehicleMode.None;
                    VM.Mode = VehicleMode.Lane;
                }

                break;
            }

            case VehicleMode.Lane:
            {
                vehicleControl.MoveVehicle.MoveOnLane();
                break;
            }

            case VehicleMode.Remove:
            {
                (vehicleControl.Parent as Grid).Children.Remove(vehicleControl);
                break;
            }

            default: break;
            }

            return(e);
        }
Exemple #9
0
 /// <summary>
 /// Ustawienie wartosci
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="value"></param>
 public static void SetMode(DependencyObject obj, VehicleMode value)
 {
     obj.SetValue(ModeProperty, value);
 }