Example #1
0
        public void Move(InputState input, PlayerIndex[] controllingPlayer)
        {
            if (Active == true)
            {
                Rotation.Y += MathHelper.ToRadians(5.0f);
                if (
                    (input.IsNewButtonHeld(ButtonMappings.Pad_LeftStickLeft, controllingPlayer[0], out controllingPlayer[1]) ||
                     input.IsNewKeyHeld(ButtonMappings.Keyboard_LeftStickLeft, controllingPlayer[0], out controllingPlayer[1])) &&
                    (hasPlayArea == false || (hasPlayArea == true && Bounds.Max.X > playArea.Min.X))
                    )
                {
                    velocity.X      = -1;
                    acceleration.X += accelerationBit;
                }
                else if (
                    (input.IsNewButtonHeld(ButtonMappings.Pad_LeftStickRight, controllingPlayer[0], out controllingPlayer[1]) ||
                     input.IsNewKeyHeld(ButtonMappings.Keyboard_LeftStickRight, controllingPlayer[0], out controllingPlayer[1])) &&
                    (hasPlayArea == false || (hasPlayArea == true && Bounds.Min.X < playArea.Max.X))
                    )
                {
                    velocity.X      = 1;
                    acceleration.X += accelerationBit;
                }
                else
                {
                    acceleration.X -= accelerationBit;
                }

                if (
                    (input.IsNewButtonHeld(ButtonMappings.Pad_LeftStickUp, controllingPlayer[0], out controllingPlayer[1]) ||
                     input.IsNewKeyHeld(ButtonMappings.Keyboard_LeftStickUp, controllingPlayer[0], out controllingPlayer[1])) &&
                    (hasPlayArea == false || (hasPlayArea == true && Bounds.Max.Z > playArea.Min.Z))
                    )
                {
                    velocity.Z      = -1;
                    acceleration.Z += accelerationBit;
                }
                else if (
                    (input.IsNewButtonHeld(ButtonMappings.Pad_LeftStickDown, controllingPlayer[0], out controllingPlayer[1]) ||
                     input.IsNewKeyHeld(ButtonMappings.Keyboard_LeftStickDown, controllingPlayer[0], out controllingPlayer[1])) &&
                    (hasPlayArea == false || (hasPlayArea == true && Bounds.Min.Z < playArea.Max.Z))
                    )
                {
                    velocity.Z      = 1;
                    acceleration.Z += accelerationBit;
                }
                else
                {
                    acceleration.Z -= accelerationBit;
                }

                if (Fuel > 0 &&
                    ((input.IsNewButtonHeld(ButtonMappings.Pad_RightTrigger, controllingPlayer[0], out controllingPlayer[1]) ||
                      input.IsNewButtonHeld(ButtonMappings.Pad_LeftTrigger, controllingPlayer[0], out controllingPlayer[1]) ||
                      input.IsNewButtonHeld(ButtonMappings.Pad_ABtn, controllingPlayer[0], out controllingPlayer[1]) ||
                      input.IsNewKeyHeld(ButtonMappings.Keyboard_ABtn, controllingPlayer[0], out controllingPlayer[1])) &&
                     (hasPlayArea == false || (hasPlayArea == true && Bounds.Min.Y < playArea.Max.Y)))
                    )
                {
                    GenerateThrustParticles();
                    velocity.Y += thrust;
                    Fuel--;
                    acceleration.Y += accelerationBit;
                    soundPlayer.PlaySound("Thrust");
                }
                else if ((hasPlayArea == false || (hasPlayArea == true && Bounds.Max.Y > playArea.Min.Y)))
                {
                    velocity.Y     -= gravity;
                    acceleration.Y += accelerationBit;
                    soundPlayer.StopSound("Thrust");
                }
                else
                {
                    velocity.Y = 0;
                    soundPlayer.StopSound("Thrust");
                }
                velocity.Y = MathHelper.Clamp(velocity.Y, -1.0f, 1.0f);
            }
        }
        public void Move(InputState input, PlayerIndex[] controllingPlayer)
        {
            if (input.IsNewButtonHeld(ButtonMappings.Pad_RightStickLeft, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyHeld(ButtonMappings.Keyboard_RightStickLeft, controllingPlayer[0], out controllingPlayer[1]))
            {
                if (Position.Z > 130)
                {
                    Position.X -= Speed;
                    View.X     += Speed;
                }
                else
                {
                    Position.X += Speed;
                    View.X     -= Speed;
                }
            }
            if (input.IsNewButtonHeld(ButtonMappings.Pad_RightStickRight, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyHeld(ButtonMappings.Keyboard_RightStickRight, controllingPlayer[0], out controllingPlayer[1]))
            {
                if (Position.Z <= 130)
                {
                    Position.X -= Speed;
                    View.X     += Speed;
                }
                else
                {
                    Position.X += Speed;
                    View.X     -= Speed;
                }
            }
            if (input.IsNewButtonHeld(ButtonMappings.Pad_RightStickUp, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyHeld(ButtonMappings.Keyboard_RightStickUp, controllingPlayer[0], out controllingPlayer[1]))
            {
                Position.Y += Speed;
                View.Y     -= Speed;
            }
            if (input.IsNewButtonHeld(ButtonMappings.Pad_RightStickDown, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyHeld(ButtonMappings.Keyboard_RightStickDown, controllingPlayer[0], out controllingPlayer[1]))
            {
                Position.Y -= Speed;
                View.Y     += Speed;
            }
            if (input.IsNewButtonHeld(ButtonMappings.Pad_LeftShoulder, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyHeld(ButtonMappings.Keyboard_LeftShoulder, controllingPlayer[0], out controllingPlayer[1]))
            {
                Position.Z += Speed;
                View.Z     -= Speed;
            }
            if (input.IsNewButtonHeld(ButtonMappings.Pad_RightShoulder, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyHeld(ButtonMappings.Keyboard_RightShoulder, controllingPlayer[0], out controllingPlayer[1]))
            {
                Position.Z -= Speed;
                View.Z     += Speed;
            }
            if (input.IsNewButtonHeld(ButtonMappings.Pad_RightStickPress, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyHeld(ButtonMappings.Keyboard_RightStickPress, controllingPlayer[0], out controllingPlayer[1]))
            {
                ResetCamera();
            }

            Position.X = MathHelper.Clamp(Position.X, positionLimits[0].X, positionLimits[1].X);
            View.X     = MathHelper.Clamp(View.X, viewLimits[0].X, viewLimits[1].X);
            Position.Y = MathHelper.Clamp(Position.Y, positionLimits[0].Y, positionLimits[1].Y);
            View.Y     = MathHelper.Clamp(View.Y, viewLimits[0].Y, viewLimits[1].Y);
            Position.Z = MathHelper.Clamp(Position.Z, positionLimits[0].Z, positionLimits[1].Z);
            View.Z     = MathHelper.Clamp(View.Z, viewLimits[0].Z, viewLimits[1].Z);

            cameraFrustum.Matrix = GetViewMatrix() * GetProjectionMatrix();
        }
        public void Move(InputState input, PlayerIndex[] controllingPlayer)
        {
            if (input.IsNewButtonHeld(ButtonMappings.Pad_RightStickLeft, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyHeld(ButtonMappings.Keyboard_RightStickLeft, controllingPlayer[0], out controllingPlayer[1]))
            {
                if (Position.Z > 130)
                {
                    Position.X -= Speed;
                    View.X += Speed;
                }
                else
                {
                    Position.X += Speed;
                    View.X -= Speed;
                }
            }
            if (input.IsNewButtonHeld(ButtonMappings.Pad_RightStickRight, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyHeld(ButtonMappings.Keyboard_RightStickRight, controllingPlayer[0], out controllingPlayer[1]))
            {
                if (Position.Z <= 130)
                {
                    Position.X -= Speed;
                    View.X += Speed;
                }
                else
                {
                    Position.X += Speed;
                    View.X -= Speed;
                }
            }
            if (input.IsNewButtonHeld(ButtonMappings.Pad_RightStickUp, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyHeld(ButtonMappings.Keyboard_RightStickUp, controllingPlayer[0], out controllingPlayer[1]))
            {
                Position.Y += Speed;
                View.Y -= Speed;
            }
            if (input.IsNewButtonHeld(ButtonMappings.Pad_RightStickDown, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyHeld(ButtonMappings.Keyboard_RightStickDown, controllingPlayer[0], out controllingPlayer[1]))
            {
                Position.Y -= Speed;
                View.Y += Speed;
            }
            if (input.IsNewButtonHeld(ButtonMappings.Pad_LeftShoulder, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyHeld(ButtonMappings.Keyboard_LeftShoulder, controllingPlayer[0], out controllingPlayer[1]))
            {
                Position.Z += Speed;
                View.Z -= Speed;
            }
            if (input.IsNewButtonHeld(ButtonMappings.Pad_RightShoulder, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyHeld(ButtonMappings.Keyboard_RightShoulder, controllingPlayer[0], out controllingPlayer[1]))
            {
                Position.Z -= Speed;
                View.Z += Speed;
            }
            if (input.IsNewButtonHeld(ButtonMappings.Pad_RightStickPress, controllingPlayer[0], out controllingPlayer[1]) ||
                input.IsNewKeyHeld(ButtonMappings.Keyboard_RightStickPress, controllingPlayer[0], out controllingPlayer[1]))
            {
                ResetCamera();
            }

            Position.X = MathHelper.Clamp(Position.X, positionLimits[0].X, positionLimits[1].X);
            View.X = MathHelper.Clamp(View.X, viewLimits[0].X, viewLimits[1].X);
            Position.Y = MathHelper.Clamp(Position.Y, positionLimits[0].Y, positionLimits[1].Y);
            View.Y = MathHelper.Clamp(View.Y, viewLimits[0].Y, viewLimits[1].Y);
            Position.Z = MathHelper.Clamp(Position.Z, positionLimits[0].Z, positionLimits[1].Z);
            View.Z = MathHelper.Clamp(View.Z, viewLimits[0].Z, viewLimits[1].Z);

            cameraFrustum.Matrix = GetViewMatrix() * GetProjectionMatrix();
        }
Example #4
0
        public void Move(InputState input, PlayerIndex[] controllingPlayer)
        {
            if (Active == true)
            {
                Rotation.Y += MathHelper.ToRadians(5.0f);
                if (
                    (input.IsNewButtonHeld(ButtonMappings.Pad_LeftStickLeft, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewKeyHeld(ButtonMappings.Keyboard_LeftStickLeft, controllingPlayer[0], out controllingPlayer[1]))
                    && (hasPlayArea == false || (hasPlayArea == true && Bounds.Max.X > playArea.Min.X))
                    )
                {
                    velocity.X = -1;
                    acceleration.X += accelerationBit;
                }
                else if (
                    (input.IsNewButtonHeld(ButtonMappings.Pad_LeftStickRight, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewKeyHeld(ButtonMappings.Keyboard_LeftStickRight, controllingPlayer[0], out controllingPlayer[1]))
                    && (hasPlayArea == false || (hasPlayArea == true && Bounds.Min.X < playArea.Max.X))
                    )
                {
                    velocity.X = 1;
                    acceleration.X += accelerationBit;
                }
                else
                {
                    acceleration.X -= accelerationBit;
                }

                if (
                    (input.IsNewButtonHeld(ButtonMappings.Pad_LeftStickUp, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewKeyHeld(ButtonMappings.Keyboard_LeftStickUp, controllingPlayer[0], out controllingPlayer[1]))
                    && (hasPlayArea == false || (hasPlayArea == true && Bounds.Max.Z > playArea.Min.Z))
                    )
                {
                    velocity.Z = -1;
                    acceleration.Z += accelerationBit;
                }
                else if (
                    (input.IsNewButtonHeld(ButtonMappings.Pad_LeftStickDown, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewKeyHeld(ButtonMappings.Keyboard_LeftStickDown, controllingPlayer[0], out controllingPlayer[1]))
                    && (hasPlayArea == false || (hasPlayArea == true && Bounds.Min.Z < playArea.Max.Z))
                    )
                {
                    velocity.Z = 1;
                    acceleration.Z += accelerationBit;
                }
                else
                {
                    acceleration.Z -= accelerationBit;
                }

                if (Fuel>0 &&
                    ((input.IsNewButtonHeld(ButtonMappings.Pad_RightTrigger, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewButtonHeld(ButtonMappings.Pad_LeftTrigger, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewButtonHeld(ButtonMappings.Pad_ABtn, controllingPlayer[0], out controllingPlayer[1]) ||
                    input.IsNewKeyHeld(ButtonMappings.Keyboard_ABtn, controllingPlayer[0], out controllingPlayer[1]))
                    && (hasPlayArea == false || (hasPlayArea == true && Bounds.Min.Y < playArea.Max.Y)))
                    )
                {
                    GenerateThrustParticles();
                    velocity.Y += thrust;
                    Fuel--;
                    acceleration.Y += accelerationBit;
                    soundPlayer.PlaySound("Thrust");
                }
                else if ((hasPlayArea == false || (hasPlayArea == true && Bounds.Max.Y > playArea.Min.Y)))
                {
                    velocity.Y -= gravity;
                    acceleration.Y += accelerationBit;
                    soundPlayer.StopSound("Thrust");
                }
                else
                {
                    velocity.Y = 0;
                    soundPlayer.StopSound("Thrust");
                }
                velocity.Y = MathHelper.Clamp(velocity.Y, -1.0f, 1.0f);
            }
        }