コード例 #1
0
ファイル: Input.cs プロジェクト: JoshuaKlaser/ANSKLibrary
        private List<Player> _players; // List of players that are registered in the game. Used for Xbox controller input organisation.

        #endregion Fields

        #region Constructors

        public Input(Game1 game)
            : base(game)
        {
            _gamePadToCheck = new List<Buttons>();
            _keyboardToCheck = new List<Keys>();

            _gamePadCommandsC = new List<Dictionary<Buttons, InputTypeComplex>> ();
            _keyboardCommandsC = new Dictionary<Keys, InputTypeComplex>();
            _mouseCommandsC = new Dictionary<MouseInput.MouseButtonsXNA, InputTypeComplex>();

            _mouseCommandsC.Add(MouseInput.MouseButtonsXNA.LeftButton, new InputTypeComplex());
            _mouseCommandsC.Add(MouseInput.MouseButtonsXNA.RightButton, new InputTypeComplex());
            _mouseCommandsC.Add(MouseInput.MouseButtonsXNA.MiddleButton, new InputTypeComplex());
            _mouseCommandsC.Add(MouseInput.MouseButtonsXNA.XButton1, new InputTypeComplex());
            _mouseCommandsC.Add(MouseInput.MouseButtonsXNA.XButton2, new InputTypeComplex());

            _padEnable = _keyEnable = _mouseEnable = true;

            for (int i = 0; i < LocalPlayerRegistry.MAX_LOCAL_MACHINE_PLAYERS; i++)
            {
                _gamePadCommandsC.Add(new Dictionary<Buttons, InputTypeComplex>());
            }

            _mouse = new MouseInput(game);
            _mouse.CenterScreen = new Microsoft.Xna.Framework.Vector2(game.GraphicsDevice.DisplayMode.Width / 2, game.GraphicsDevice.DisplayMode.Height / 2);

            _container = new InputContainer(_gamePadCommandsC, _keyboardCommandsC, _mouseCommandsC, _mouse, this);

            ReloadPlayerList();
        }
コード例 #2
0
 public InputTypeComplex(MouseInput.MouseButtonsXNA button, Game1 game)
 {
     _button = button;
     _type = Type.Mouse;
     _timePressed = 0;
     _pressed = _prevPressed = false;
     _mouse = new MouseInput(game);
 }
コード例 #3
0
 public InputTypeComplex()
 {
     _button = -1;
     _type = Type.None;
     _timePressed = 0;
     _pressed = _prevPressed = false;
     _mouse = null;
 }
コード例 #4
0
 public InputTypeComplex(Buttons button)
 {
     _button = button;
     _type = Type.Pad;
     _timePressed = 0;
     _pressed = _prevPressed = false;
     _mouse = null;
 }
コード例 #5
0
        private Input _parentInput; // The parent Input class that this InputContainer was retrieved from.

        #endregion Fields

        #region Constructors

        public InputContainer(List<Dictionary<Buttons, InputTypeComplex>> gamePadRefC, Dictionary<Keys, InputTypeComplex> keyboardRefC, Dictionary<MouseInput.MouseButtonsXNA, InputTypeComplex> mouseRefC, MouseInput mouse, Input parent)
        {
            _gamePadCommandsC = gamePadRefC;
            _keyboardCommandsC = keyboardRefC;
            _mouseCommandsC = mouseRefC;
            _mouse = mouse;
            _parentInput = parent;
        }
コード例 #6
0
 public double TimePressed(MouseInput.MouseButtonsXNA button)
 {
     return _mouseCommandsC [button].TimePressed;
 }
コード例 #7
0
 public bool IsFirstReleased(MouseInput.MouseButtonsXNA button)
 {
     return _mouseCommandsC [button].FirstReleased;
 }
コード例 #8
0
 public void EmulateInput(MouseInput.MouseButtonsXNA button)
 {
     _mouseCommandsC [button].Pressed = true;
 }
コード例 #9
0
 /// <summary>
 /// Checks the Mouse to see if the specified mouse button has been pressed.
 /// </summary>
 /// <param name="button">'MouseButtonsXNA' enum type of which input to check for.</param>
 /// <returns>Return true if mouse button is pressed. Return false if not.</returns>
 public bool this[MouseInput.MouseButtonsXNA button]
 {
     get
     {
         return _mouseCommandsC [button].Pressed;
     }
 }