IsActive() public method

public IsActive ( ) : bool
return bool
コード例 #1
0
ファイル: Helli.cs プロジェクト: AKNightHawk/AssaultKnights2
        private void TickSound()
        {
            bool lastMotorOn = HelliOn;

            HelliOn = Intellect != null && Intellect.IsActive();

            //sound on, off
            if (HelliOn != lastMotorOn)
            {
                if (HelliOn)
                {
                    Sound sound = SoundWorld.Instance.SoundCreate(Type.SoundOn, SoundMode.Mode3D);
                    if (sound != null)
                    {
                        soundOnChannel = SoundWorld.Instance.SoundPlay(sound, EngineApp.Instance.DefaultSoundChannelGroup, .7f, true);
                        if (soundOnChannel != null)
                        {
                            soundOnChannel.Position = Position;
                            soundOnChannel.Pause    = false;
                        }
                    }
                    //SoundPlay3D(Type.SoundOn, .7f, true);
                }
                else
                {
                    MohiOff();
                    SoundPlay3D(Type.SoundOff, 0.7f, true);
                }
            }

            string needSoundName = null;

            if (HelliOn)
            {
                needSoundName = Type.SoundIdle;
            }
            if (needSoundName != currentRotorSoundName)
            {
                currentRotorSoundName = needSoundName;

                if (!string.IsNullOrEmpty(needSoundName))
                {
                    Sound sound = SoundWorld.Instance.SoundCreate(needSoundName,
                                                                  SoundMode.Mode3D | SoundMode.Loop);

                    if (sound != null)
                    {
                        rotorSoundChannel = SoundWorld.Instance.SoundPlay(
                            sound, EngineApp.Instance.DefaultSoundChannelGroup, 1, true);
                        rotorSoundChannel.Position = Position;
                        rotorSoundChannel.Pause    = false;
                    }
                }
            }
        }
コード例 #2
0
ファイル: Forklift.cs プロジェクト: gsaone/forklift
        void TickMotorSound()
        {
            bool lastMotorOn = motorOn;

            motorOn = Intellect != null && Intellect.IsActive();

            //sound on, off
            if (motorOn != lastMotorOn)
            {
                if (!firstTick && Life != 0)
                {
                    if (motorOn)
                    {
                        SoundPlay3D(Type.SoundOn, .7f, true);
                    }
                    else
                    {
                        SoundPlay3D(Type.SoundOff, .7f, true);
                    }
                }
            }

            string needSoundName = null;

            if (motorOn && currentGear != null)
            {
                needSoundName = currentGear.SoundMotor;
            }

            if (needSoundName != currentMotorSoundName)
            {
                //change motor sound

                if (motorSoundChannel != null)
                {
                    motorSoundChannel.Stop();
                    motorSoundChannel = null;
                }

                currentMotorSoundName = needSoundName;

                if (!string.IsNullOrEmpty(needSoundName))
                {
                    Sound sound = SoundWorld.Instance.SoundCreate(needSoundName,
                                                                  SoundMode.Mode3D | SoundMode.Loop);

                    if (sound != null)
                    {
                        motorSoundChannel = SoundWorld.Instance.SoundPlay(
                            sound, EngineApp.Instance.DefaultSoundChannelGroup, .3f, true);
                        motorSoundChannel.Position = Position;
                        motorSoundChannel.Pause    = false;
                    }
                }
            }
            //update motor channel position and pitch
            if (motorSoundChannel != null)
            {
                Range speedRangeAbs = currentGear.SpeedRange;
                if (speedRangeAbs.Minimum < 0 && speedRangeAbs.Maximum < 0)
                {
                    speedRangeAbs = new Range(-speedRangeAbs.Maximum, -speedRangeAbs.Minimum);
                }
                Range pitchRange = currentGear.SoundMotorPitchRange;

                Vec3  Velocity = forkliftBody.LinearVelocity * forkliftBody.Rotation.GetInverse();
                float speedAbs = Velocity.X * 1;

                float speedCoef = 0;
                if (speedRangeAbs.Size() != 0)
                {
                    speedCoef = (speedAbs - speedRangeAbs.Minimum) / speedRangeAbs.Size();
                }
                MathFunctions.Clamp(ref speedCoef, 0, 1);

                //update channel
                motorSoundChannel.Pitch    = pitchRange.Minimum + speedCoef * pitchRange.Size();
                motorSoundChannel.Position = Position;
            }
        }
コード例 #3
0
ファイル: Car.cs プロジェクト: AKNightHawk/AssaultKnights2
        private void TickMotorSound()
        {
            bool lastMotorOn = motorOn;

            motorOn = Intellect != null && Intellect.IsActive();

            //sound on, off
            if (motorOn != lastMotorOn)
            {
                if (!firstTick && Life != 0)
                {
                    if (motorOn)
                    {
                        Sound sound = SoundWorld.Instance.SoundCreate(Type.SoundOn, SoundMode.Mode3D);
                        if (sound != null)
                        {
                            soundOnChannel = SoundWorld.Instance.SoundPlay(sound, EngineApp.Instance.DefaultSoundChannelGroup, .7f, true);
                            if (soundOnChannel != null)
                            {
                                soundOnChannel.Position = Position;
                                soundOnChannel.Pause    = false;
                            }
                        }
                        //SoundPlay3D(Type.SoundOn, .7f, true);
                    }
                    else
                    {
                        SoundPlay3D(Type.SoundOff, .7f, true);
                    }
                }
            }

            string needSoundName = null;

            if (motorOn && currentGear != null)
            {
                needSoundName = currentGear.SoundMotor;
            }

            if (needSoundName != currentMotorSoundName)
            {
                //change motor sound

                if (motorSoundChannel != null)
                {
                    motorSoundChannel.Stop();
                    motorSoundChannel = null;
                }

                currentMotorSoundName = needSoundName;

                if (!string.IsNullOrEmpty(needSoundName))
                {
                    Sound sound = SoundWorld.Instance.SoundCreate(needSoundName,
                                                                  SoundMode.Mode3D | SoundMode.Loop);

                    if (sound != null)
                    {
                        motorSoundChannel = SoundWorld.Instance.SoundPlay(
                            sound, EngineApp.Instance.DefaultSoundChannelGroup, .3f, true);
                        motorSoundChannel.Position = Position;
                        motorSoundChannel.Pause    = false;
                    }
                }
            }

            //update motor channel position and pitch
            if (motorSoundChannel != null)
            {
                Range speedRangeAbs = currentGear.SpeedRange;
                if (speedRangeAbs.Minimum < 0 && speedRangeAbs.Maximum < 0)
                {
                    speedRangeAbs = new Range(-speedRangeAbs.Maximum, -speedRangeAbs.Minimum);
                }
                Range pitchRange = currentGear.SoundMotorPitchRange;

                float speedAbs = Math.Abs(GetWheelsSpeed());

                float speedCoef = 0;
                if (speedRangeAbs.Size() != 0)
                {
                    speedCoef = (speedAbs - speedRangeAbs.Minimum) / speedRangeAbs.Size();
                }
                MathFunctions.Clamp(ref speedCoef, 0, 1);

                float carpitch;
                //update channel

                /*bool onGround = LFWheel.onGround || RFWheel.onGround;
                 * if (!onGround)
                 * {
                 *  if (Intellect.IsControlKeyPressed(GameControlKeys.ArowUp))
                 *  {
                 *      carpitch = pitchRange.Minimum + pitchRange.Size();
                 *  }
                 *  else
                 *  {
                 *      carpitch = pitchRange.Minimum;
                 *  }
                 * }
                 * else*/
                {
                    carpitch = pitchRange.Minimum + speedCoef * pitchRange.Size();
                }
                motorSoundChannel.Pitch    = carpitch;
                motorSoundChannel.Position = Position;
            }
        }
コード例 #4
0
ファイル: Helli.cs プロジェクト: AKNightHawk/AssaultKnights2
        private void TickIntellect()
        {
            ShiftBooster();

            HelliOn = Intellect != null && Intellect.IsActive();
            // GUItest();

            //finding motors
            GearedMotor main = PhysicsModel.GetMotor("hellimain") as GearedMotor;
            GearedMotor back = PhysicsModel.GetMotor("helliback") as GearedMotor;

            if (HelliOn)
            {
                main.Enabled = true;
                back.Enabled = true;
            }

            //engine force + sound pitch control

            if (Intellect.IsControlKeyPressed(GameControlKeys.Forward))
            {
                force   += forceadd;
                enpitch += 0.02f;
            }
            else if (Intellect.IsControlKeyPressed(GameControlKeys.Backward))
            {
                dec      = true;
                force   -= forceadd;
                enpitch -= 0.02f;
            }
            else
            {
                dec      = false;
                enpitch -= 0.01f;
                if (force > 50)
                {
                    force -= forceadd;
                }
                if (force < 50)
                {
                    force += forceadd;
                }
            }

            MathFunctions.Clamp(ref force, 0.1f, 100 + Type.MaxForce);
            MathFunctions.Clamp(ref enpitch, 0.8f, 1.3f);

            //update helli channel position and pitch
            if (rotorSoundChannel != null)
            {
                //update channel
                rotorSoundChannel.Pitch       = enpitch;
                rotorSoundChannel.Volume      = 1;
                rotorSoundChannel.Position    = Position;
                rotorSoundChannel.MinDistance = 10;
            }

            //end of engine force + sound pitch control

            //Forces
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            //start helli Pitch
            if (Intellect.IsControlKeyPressed(GameControlKeys.ArrowUp) || Intellect.IsControlKeyPressed(GameControlKeys.ArrowDown))
            {
                float AUp   = Intellect.GetControlKeyStrength(GameControlKeys.ArrowUp) / 2;
                float ADown = Intellect.GetControlKeyStrength(GameControlKeys.ArrowDown) / 2;
                Hpitch += (AUp - ADown);
                MathFunctions.Clamp(ref Hpitch, -10, 10);

                HelliBody.AddForce(ForceType.GlobalAtLocalPos, TickDelta,
                                   HelliBody.Rotation * new Vec3(0, 0, Hpitch / 2) * HelliBody.Mass, new Vec3(-2, 0, 0));
            }
            else
            {
                Hpitch = 0;
            }
            //end of helli pitch

            //start helli Z turn
            if (Intellect.IsControlKeyPressed(GameControlKeys.Right) || Intellect.IsControlKeyPressed(GameControlKeys.Left))
            {
                float right = Intellect.GetControlKeyStrength(GameControlKeys.Right) / 2;
                float left  = Intellect.GetControlKeyStrength(GameControlKeys.Left) / 2;
                TrunZ += (left - right);
                MathFunctions.Clamp(ref TrunZ, -10, 10);

                HelliBody.AddForce(ForceType.GlobalTorque, TickDelta,
                                   HelliBody.Rotation * new Vec3(0, 0, TrunZ) * HelliBody.Mass, Vec3.Zero);
            }
            else
            {
                TrunZ = 0;
            }

            //end of helli Z turn

            //start helli X turn
            if (Intellect.IsControlKeyPressed(GameControlKeys.ArowRight) || Intellect.IsControlKeyPressed(GameControlKeys.ArowLeft))
            {
                float rightX = Intellect.GetControlKeyStrength(GameControlKeys.ArowRight) / 2;
                float leftX  = Intellect.GetControlKeyStrength(GameControlKeys.ArowLeft) / 2;
                TrunX += (rightX - leftX);
                MathFunctions.Clamp(ref TrunX, -10, 10);

                HelliBody.AddForce(ForceType.GlobalTorque, TickDelta,
                                   HelliBody.Rotation * new Vec3(TrunX / 5, 0, 0) * HelliBody.Mass, Vec3.Zero);
            }
            else
            {
                TrunX = 0;
            }
            //end of helli X turn

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

            //start of adding force

            MathFunctions.Clamp(ref force, 0.1f, 100);

            //anti gravity when helli is not decending
            if (dec == false)
            {
                HelliBody.AddForce(ForceType.GlobalAtLocalPos, TickDelta,
                                   new Vec3(0, 0, 2) * HelliBody.Mass, Vec3.Zero);
            }

            //if Max Alt is not reached add helli motor force
            if (GetRealAlt() < Type.MaxAlt)
            {
                HelliBody.AddForce(ForceType.GlobalAtLocalPos, TickDelta,
                                   HelliBody.Rotation * 2 * new Vec3(0, 0, force / 7) * HelliBody.Mass, Vec3.Zero);
            }

            //dampings
            HelliBody.AngularDamping = 1.5f;
            HelliBody.LinearDamping  = 0.4f;

            //another anti gravity force
            if (HelliBody.LinearVelocity.Z < 0)
            {
                HelliBody.AddForce(ForceType.GlobalAtLocalPos, TickDelta,
                                   HelliBody.Rotation * new Vec3(0, 0, -HelliBody.LinearVelocity.Z) * HelliBody.Mass, Vec3.Zero);
            }
        }