コード例 #1
0
 private void OnGearChange(AKCarType.Gear oldGear, AKCarType.Gear newGear)
 {
     if (!firstTick && Health != 0)
     {
         bool   up        = Math.Abs(newGear.Number) > Math.Abs(oldGear.Number);
         string soundName = up ? Type.SoundGearUp : Type.SoundGearDown;
         SoundPlay3D(soundName, .7f, true);
     }
 }
コード例 #2
0
        protected override void OnPostCreate(bool loaded)
        {
            base.OnPostCreate(loaded);

            SubscribeToTickEvent();

            if (EntitySystemWorld.Instance.WorldSimulationType != WorldSimulationTypes.Editor)
            {
                if (PhysicsModel == null)
                {
                    Log.Error("Class AKCar: Physics model not exists.");
                    return;
                }

                chassisBody = PhysicsModel.GetBody("AKCar");
                if (chassisBody == null)
                {
                    Log.Error("Class AKCar: \"AKCar\" body dose not exists.");
                    return;
                }

                //chassisBody.Collision += chassisBody_Collision;

                foreach (MapObjectAttachedObject attachedObject in AttachedObjects)
                {
                    if (attachedObject.Alias == "leftTrack")
                    {
                        leftTrack.trackHelpers.Add((MapObjectAttachedHelper)attachedObject);
                    }
                    if (attachedObject.Alias == "rightTrack")
                    {
                        rightTrack.trackHelpers.Add((MapObjectAttachedHelper)attachedObject);
                    }
                }

                if (leftTrack.trackHelpers.Count != 0)
                {
                    tracksPositionYOffset = Math.Abs(leftTrack.trackHelpers[0].PositionOffset.Y);
                }
            }

            //initialize currentGear
            currentGear = Type.Gears.Find(delegate(AKCarType.Gear gear)
            {
                return(gear.Number == 0);
            });
        }
コード例 #3
0
        private void TickCurrentGear()
        {
            if (currentGear == null)
            {
                return;
            }
            CUGear = currentGear.Number;
            if (motorOn)
            {
                float          speed   = GetTracksSpeed();
                AKCarType.Gear newGear = null;

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

                if (newGear != null && currentGear != newGear)
                {
                    //change gear
                    AKCarType.Gear oldGear = currentGear;
                    OnGearChange(oldGear, newGear);
                    currentGear = newGear;
                    DownTime    = true;
                }
            }
            else
            {
                if (currentGear.Number != 0)
                {
                    currentGear = Type.Gears.Find(delegate(AKCarType.Gear gear)
                    {
                        return(gear.Number == 0);
                    });
                }
            }
        }
コード例 #4
0
ファイル: AKCar.cs プロジェクト: AKNightHawk/AssaultKnights2
        private void TickCurrentGear()
        {
            if (currentGear == null)
                return;
            CUGear = currentGear.Number;
            if (motorOn)
            {
                float speed = GetTracksSpeed();
                AKCarType.Gear newGear = null;

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

                if (newGear != null && currentGear != newGear)
                {
                    //change gear
                    AKCarType.Gear oldGear = currentGear;
                    OnGearChange(oldGear, newGear);
                    currentGear = newGear;
                    DownTime = true;
                }
            }
            else
            {
                if (currentGear.Number != 0)
                {
                    currentGear = Type.Gears.Find(delegate(AKCarType.Gear gear)
                    {
                        return gear.Number == 0;
                    });
                }
            }
        }
コード例 #5
0
ファイル: AKCar.cs プロジェクト: AKNightHawk/AssaultKnights2
        protected override void OnPostCreate(bool loaded)
        {
            base.OnPostCreate(loaded);

            SubscribeToTickEvent();

            if (EntitySystemWorld.Instance.WorldSimulationType != WorldSimulationTypes.Editor)
            {
                if (PhysicsModel == null)
                {
                    Log.Error("Class AKCar: Physics model not exists.");
                    return;
                }

                chassisBody = PhysicsModel.GetBody("AKCar");
                if (chassisBody == null)
                {
                    Log.Error("Class AKCar: \"AKCar\" body dose not exists.");
                    return;
                }

                //chassisBody.Collision += chassisBody_Collision;

                foreach (MapObjectAttachedObject attachedObject in AttachedObjects)
                {
                    if (attachedObject.Alias == "leftTrack")
                        leftTrack.trackHelpers.Add((MapObjectAttachedHelper)attachedObject);
                    if (attachedObject.Alias == "rightTrack")
                        rightTrack.trackHelpers.Add((MapObjectAttachedHelper)attachedObject);
                }

                if (leftTrack.trackHelpers.Count != 0)
                    tracksPositionYOffset = Math.Abs(leftTrack.trackHelpers[0].PositionOffset.Y);
            }

            //initialize currentGear
            currentGear = Type.Gears.Find(delegate(AKCarType.Gear gear)
            {
                return gear.Number == 0;
            });
        }