コード例 #1
0
ファイル: InputCore.cs プロジェクト: retNull/SquidEngine-XNA
 private static void FireCommand(InputCommand _commanad)
 {
     if (InputCommandFired != null)
     {
         InputCommandFired(_commanad);
     }
 }
コード例 #2
0
ファイル: InputCore.cs プロジェクト: retNull/SquidEngine-XNA
 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);
     }
 }
コード例 #3
0
ファイル: InputCore.cs プロジェクト: retNull/SquidEngine-XNA
        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);
            }
        }
コード例 #4
0
ファイル: InputCore.cs プロジェクト: retNull/SquidEngine-XNA
        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
            }
        }