Ejemplo n.º 1
0
        /// <summary>
        /// Update method
        /// </summary>
        /// <param name="gameTime">Current game time</param>
        public void Update(GameTime gameTime)
        {
            if (instance == null)
            {
                return;
            }

            if (instance.controllerType == ControllerType.GamePad)
            {
                if (GamePad.GetState(PlayerIndex.One).IsConnected)
                {
                    instance.gamePadState = GamePad.GetState(PlayerIndex.One);
                }
                else
                {
                    instance = null;
                }
            }
            else
            {
                if (GamePad.GetState(PlayerIndex.One).IsConnected)
                {
                    instance = null;
                }
                else
                {
                    instance.keyboardState = Keyboard.GetState();
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Allows the instance to be retrieved. This acts as the constructor
 /// </summary>
 /// <param name="type">Type of the controller to be used</param>
 /// <returns>The only instance of input manager</returns>
 public static InputManager GetInstance()
 {
     if (instance == null)
     {
         instance = new InputManager();
     }
     
     return instance;
 }