Exemplo n.º 1
0
 private void OnGearChange(CarType.Gear oldGear, CarType.Gear newGear)
 {
     if (!firstTick && Life != 0)
     {
         bool   up        = Math.Abs(newGear.Number) > Math.Abs(oldGear.Number);
         string soundName = up ? Type.SoundGearUp : Type.SoundGearDown;
         SoundPlay3D(soundName, .7f, true);
     }
 }
Exemplo n.º 2
0
        private void TickCurrentGear()
        {
            if (currentGear == null)
            {
                return;
            }
            if (motorOn)
            {
                float        speed   = GetWheelsSpeed();
                CarType.Gear newGear = null;

                if (speed < currentGear.SpeedRange.Minimum || speed > currentGear.SpeedRange.Maximum)
                {
                    //find new gear
                    newGear = Type.Gears.Find(delegate(CarType.Gear gear)
                    {
                        return(speed >= gear.SpeedRange.Minimum && speed <= gear.SpeedRange.Maximum);
                    });
                }

                if (newGear != null && currentGear != newGear)
                {
                    //change gear
                    CarType.Gear oldGear = currentGear;
                    OnGearChange(oldGear, newGear);
                    currentGear = newGear;
                }
            }
            else
            {
                if (currentGear.Number != 0)
                {
                    currentGear = Type.Gears.Find(delegate(CarType.Gear gear)
                    {
                        return(gear.Number == 0);
                    });
                }
            }
        }
Exemplo n.º 3
0
        private void TickCurrentGear()
        {
            if (currentGear == null)
                return;
            if (motorOn)
            {
                float speed = GetWheelsSpeed();
                CarType.Gear newGear = null;

                if (speed < currentGear.SpeedRange.Minimum || speed > currentGear.SpeedRange.Maximum)
                {
                    //find new gear
                    newGear = Type.Gears.Find(delegate(CarType.Gear gear)
                    {
                        return speed >= gear.SpeedRange.Minimum && speed <= gear.SpeedRange.Maximum;
                    });
                }

                if (newGear != null && currentGear != newGear)
                {
                    //change gear
                    CarType.Gear oldGear = currentGear;
                    OnGearChange(oldGear, newGear);
                    currentGear = newGear;
                }
            }
            else
            {
                if (currentGear.Number != 0)
                {
                    currentGear = Type.Gears.Find(delegate(CarType.Gear gear)
                    {
                        return gear.Number == 0;
                    });
                }
            }
        }