Esempio n. 1
0
 public static void RegisterCommand(int id, Buttons[] buttons, Keys[] keys)
 {
     if (CommandExists(id))
     {
         throw new ArgumentException("Command Already Exists With That ID");
     }
     else
     {
         InputCommand command = new InputCommand();
         command.AnyPlayer = true;
         command.id        = id;
         command.buttons   = buttons;
         command.keys      = keys;
         _commands.Add(command);
     }
 }
Esempio n. 2
0
        public static void RegisterCommand(int id, System.Windows.Forms.MouseButtons buttonState)
        {
            if (CommandExists(id))
            {
                throw new ArgumentException("Command Already Exists With That ID");
            }
            else
            {
                InputCommand command = new InputCommand();
                command.id = id;
                // command.buttons = buttons;
                command.MouseButton = buttonState;
                // command.keys = keys;

                _commands.Add(command);
            }
        }
Esempio n. 3
0
        private static void CheckCommands()
        {
            for (int i = 0; i < _commands.Count; i++)
            {
                if (i >= _commands.Count)
                {
                    break;
                }

                InputCommand _command = _commands[i];
                if (_command.keys != null)
                {
                    foreach (var item in _command.keys)
                    {
                        if (_command.AnyPlayer)
                        {
                            if (IsNewKeyPress(item))
                            {
                                FireCommand(_command);
                            }
                        }
                        else
                        if (IsNewKeyPress(_command.PlayerIndex, item))
                        {
                            FireCommand(_command);
                        }
                    }
                }
                if (_command.buttons != null)
                {
                    foreach (var item in _command.buttons)
                    {
                        if (_command.AnyPlayer)
                        {
                            if (IsNewButtonPress(item, ref _command.PlayerIndex))
                            {
                                FireCommand(_command);
                            }
                        }
                        else
                        if (IsNewButtonPress(_command.PlayerIndex, item))
                        {
                            FireCommand(_command);
                        }
                    }
                }
            #if (WINDOWS)
                if (_command.MouseButton != null)
                {
                    if (_command.MouseButton == System.Windows.Forms.MouseButtons.Left)
                    {
                        if (_currentMouseState.LeftButton == ButtonState.Released &&
                            _lastMouseState.LeftButton == ButtonState.Pressed)
                        {
                            FireCommand(_command);
                        }
                    }
                    if (_command.MouseButton == System.Windows.Forms.MouseButtons.Right)
                    {
                        if (_currentMouseState.RightButton == ButtonState.Released &&
                            _lastMouseState.RightButton == ButtonState.Pressed)
                        {
                            FireCommand(_command);
                        }
                    }
                }
            #endif
            }
        }
Esempio n. 4
0
        public static void RegisterCommand(int id, System.Windows.Forms.MouseButtons buttonState)
        {
            if (CommandExists(id))
            {
                throw new ArgumentException("Command Already Exists With That ID");
            }
            else
            {
                InputCommand command = new InputCommand();
                command.id = id;
               // command.buttons = buttons;
                command.MouseButton = buttonState;
               // command.keys = keys;

                _commands.Add(command);
            }
        }
Esempio n. 5
0
 public static void RegisterCommand(int id, Buttons[] buttons, Keys[] keys)
 {
     
     if (CommandExists(id))
     {
         throw new ArgumentException("Command Already Exists With That ID");
     }
     else
     {
         InputCommand command = new InputCommand();
         command.AnyPlayer = true;
         command.id = id;
         command.buttons = buttons;
         command.keys = keys;
         _commands.Add(command);
     }
 }
Esempio n. 6
0
 private static void FireCommand(InputCommand _commanad)
 {
     if (InputCommandFired != null)
         InputCommandFired(_commanad);
 }