Пример #1
0
 void OnGearChange(SSDCType.SSDC_CONF.SoundGear old_gear, SSDCType.SSDC_CONF.SoundGear new_gear)
 {
     if (!first_tick && Health != 0)
     {
         bool   up         = Math.Abs(new_gear.Number) > Math.Abs(old_gear.Number);
         string sound_name = up ? Type.CONF.SoundGearUp : Type.CONF.SoundGearDown;
         SoundPlay3D(sound_name, .7f, true);
     }
 }
Пример #2
0
        void TickCurrentGear()
        {
            if (current_gears == null)
            {
                return;
            }

            if (motor_on)
            {
                //if (World.Instance.Random.NextBool()) { SoundPlay3D(Type.CONF.SoundBackfire, .7f, true); } //backfire
                float speed = (PhysicsModel.Bodies[0].LinearVelocity.Length() * 3600.0f / 1000.0f);

                SSDCType.SSDC_CONF.SoundGear new_gear = null;

                if (speed < current_gears.SpeedRange.Minimum || speed > current_gears.SpeedRange.Maximum)
                {
                    //find new gear
                    new_gear = Type.CONF.SoundGears.Find(delegate(SSDCType.SSDC_CONF.SoundGear gear)
                    {
                        return(speed >= gear.SpeedRange.Minimum && speed <= gear.SpeedRange.Maximum);
                    });
                }

                if (new_gear != null && current_gears != new_gear)
                {
                    //change gear
                    SSDCType.SSDC_CONF.SoundGear old_gear = current_gears;
                    OnGearChange(old_gear, new_gear);
                    current_gears = new_gear;
                }
            }
            else
            {
                if (current_gears.Number != 0)
                {
                    current_gears = Type.CONF.SoundGears.Find(delegate(SSDCType.SSDC_CONF.SoundGear gear)
                    {
                        return(gear.Number == 0);
                    });
                }
            }
        }
Пример #3
0
        protected override void OnPostCreate(bool loaded)
        {
            base.OnPostCreate(loaded);
            current_gears = Type.CONF.SoundGears.Find(delegate(SSDCType.SSDC_CONF.SoundGear gear)
            {
                return(gear.Number == 0);
            });
            if (EngineApp.Instance.ApplicationType != EngineApp.ApplicationTypes.ResourceEditor)
            {
                if (PhysicsModel == null)
                {
                    Log.Error("Car: Physics model not exists.");
                    return;
                }

                car_body  = PhysicsModel.GetBody("chassis");
                dmd_shape = car_body.GetShape("dmd");
                if (car_body == null)
                {
                    Log.Error("Car: \"chassis\" body not exists.");
                    return;
                }
                if (dmd_shape == null)
                {
                    Log.Error("Car: \"dmd\" shape not exists.");
                    return;
                }
                attached_mesh = GetFirstAttachedObjectByAlias("dmd") as MapObjectAttachedMesh;
                if (attached_mesh == null)
                {
                    Log.Error("Car: mesh by \"dmd\" alias not exists.");
                    return;
                }
                else
                {
                    mesh_name = this.Name;
                    attached_mesh.MeshObject.Mesh.Save("Data\\" + mesh_name + ".mesh");
                    attached_mesh.MeshName = mesh_name + ".mesh";
                    mesh = attached_mesh.MeshObject.Mesh;
                    if (Type.CONF.RandomMaterials.Any())
                    {
                        attached_mesh.MeshObject.SetMaterialNameForAllSubObjects(Type.CONF.RandomMaterials[World.Instance.Random.Next(0, Type.CONF.RandomMaterials.Count)].Path);
                    }
                }

                if (Type.CONF.Deformation)
                {
                    ParsingMesh();
                }
            }
            if (EntitySystemWorld.Instance.WorldSimulationType != WorldSimulationTypes.Editor)
            {
                SubscribeToTickEvent();

                MapObjectAttachedObject[] ortbrake = GetAllAttachedObjectsByAlias("brake");
                for (int i = 0; i < ortbrake.Length; i++)
                {
                    MapObjectAttachedRibbonTrail rt = ortbrake[i] as MapObjectAttachedRibbonTrail;
                    if (rt != null)
                    {
                        rtbrake.Add(rt.RibbonTrail);
                    }
                }
            }

            if (car_body != null)
            {
                car_body.Collision += OnCollision;
            }
        }