Пример #1
0
        /// <summary>
        /// Handle pilot commands that require the controller to do something.
        /// </summary>
        /// <param name="key_cmd"></param>
        public void pilotKeyCommand(PilotKeyCommands key_cmd)
        {
            switch (key_cmd)
            {
            case PilotKeyCommands.RotateClockwiseKeyDown:
                break;

            case PilotKeyCommands.RotateClockwiseKeyUp:
                break;

            case PilotKeyCommands.RotateCounterClockwiseKeyDown:
                break;

            case PilotKeyCommands.RotateCounterClockwiseKeyUp:
                break;

            default:
                break;
            }
        }
Пример #2
0
        /// <summary>
        /// Process the commands that come in key presses.
        /// </summary>
        /// <param name="key_cmd"></param>
        public void pilotKeyCommand(PilotKeyCommands key_cmd)
        {
            bool handled = false;

            // Let the prime pilot sprite have first shot at the command.
            if (_prime_pilot_sprite != null)
            {
                handled = _prime_pilot_sprite.keyCommand(key_cmd);
            }

            if (!handled)
            {
                switch (key_cmd)
                {
                case PilotKeyCommands.RadarRangeIncreaseKeyDown:
                    _pre_pilot_radar_range = _pre_pilot_radar_range * 1.20;
                    break;

                case PilotKeyCommands.RadarRangeIncreaseKeyUp:
                    break;

                case PilotKeyCommands.RadarRangeDecreaseKeyDown:
                    _pre_pilot_radar_range = _pre_pilot_radar_range * 1.0 / 1.20;
                    break;

                case PilotKeyCommands.RadarRangeDecreaseKeyUp:
                    break;

                case PilotKeyCommands.RadarTrackNextBogeyKeyDown:
                    trackNextRadarBogey();
                    break;

                default:
                    break;
                }
            }
        }
Пример #3
0
        /// <summary>
        // Process a key command.
        /// </summary>
        /// <param name="command"></param>


        /// <summary>
        // Process a key command.
        /// </summary>
        /// <param name="key_cmd"></param>
        /// <returns>handled</returns>
        public bool keyCommand(PilotKeyCommands key_cmd)
        {
            bool handled = false;

            /////////////////////////////////
            // Let the debug attempt to handle the command first.
            if (DebugCommandsOn)
            {
                handled = true;
                switch (key_cmd)
                {
                case PilotKeyCommands.RotateClockwiseKeyDown:
                    Heading = MathHelper.normalizeAngle(Heading + 5.0);
                    break;

                case PilotKeyCommands.RotateClockwiseKeyUp:
                    break;

                case PilotKeyCommands.RotateCounterClockwiseKeyDown:
                    Heading = MathHelper.normalizeAngle(Heading - 5.0);
                    break;

                case PilotKeyCommands.RotateCounterClockwiseKeyUp:
                    break;

                default:
                    handled = false;
                    break;
                }
            }


            /////////////////////////////////
            if (!handled)
            {
                handled = true;
                switch (key_cmd)
                {
                //case PilotKeyCommands.RotateClockwiseKeyDown:
                //    Heading = MathHelper.NormalizeAngle(Heading + 5.0);
                //    break;
                //case PilotKeyCommands.RotateClockwiseKeyUp:
                //    break;

                case PilotKeyCommands.FireMissileAtTrackedTargetKeyDown:
                    queFireMissleAtTrackedTarget();
                    break;

                case PilotKeyCommands.FireMissileAtTrackedTargetKeyUp:
                    break;

                case PilotKeyCommands.FireMissileUnTrackedKeyDown:
                    queFireMissleUnTracked();
                    break;

                case PilotKeyCommands.FireMissileUnTrackedKeyUp:
                    break;

                default:
                    handled = false;
                    break;
                }
            }

            return(handled);
        }
Пример #4
0
        /// <summary>
        /// Get the preview version of key down events.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PilotStageUI_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            // Trace.WriteLine(String.Format("PilotStageUI_PreviewKeyDown: {0}", e.Key));
            PilotKeyCommands key_cmd = PilotKeyCommands.Invalid;

            switch (e.Key)
            {
            case Key.Left:
            case Key.NumPad4:
                key_cmd = PilotKeyCommands.RotateCounterClockwiseKeyDown;
                break;

            case Key.Right:
            case Key.NumPad6:
                key_cmd = PilotKeyCommands.RotateClockwiseKeyDown;
                break;

            case Key.Up:
            case Key.NumPad8:
                break;

            case Key.Down:
            case Key.NumPad2:
                break;

            case Key.Space:
            case Key.NumPad5:
                //////////////////////////////////////////////////////
                // Require control key to be pressed for fire commands.
                // If control and shift, then fire untracked missile.
                if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control) && Keyboard.Modifiers.HasFlag(ModifierKeys.Shift))
                {
                    key_cmd = PilotKeyCommands.FireMissileUnTrackedKeyDown;
                }

                // If control the fire tracked missile.
                else if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
                {
                    key_cmd = PilotKeyCommands.FireMissileAtTrackedTargetKeyDown;
                }
                break;

            case Key.T:
                key_cmd = PilotKeyCommands.RadarRangeDecreaseKeyDown;
                break;

            case Key.R:
                key_cmd = PilotKeyCommands.RadarRangeIncreaseKeyDown;
                break;

            case Key.Tab:
                key_cmd = PilotKeyCommands.RadarTrackNextBogeyKeyDown;
                break;

            default:
                break;
            }

            // If the key is valid, pass it on ...
            if (key_cmd != PilotKeyCommands.Invalid)
            {
                e.Handled = true;   // swallow the key press if it mapped to a command.
                pilotKeyCommand(key_cmd);
            }

            //if (e.Key == Key.Left)
            //    MessageBox.Show("Left Key Down");

            //if (e.Key == Key.Right)
            //    MessageBox.Show("Right Key Down");
        }