/// <summary> /// Constructor /// </summary> /// <param name="game">The <see cref="QSGame"/> instance for the game</param> public GamePadHandler(QSGame game) : base(game) { this.currentGamePadStates = new GamePadState[MaxNumGamepads]; this.previousGamePadStates = new GamePadState[MaxNumGamepads]; previousButtonsHeld = new Dictionary <int, bool> [MaxNumGamepads]; for (int i = 0; i < previousButtonsHeld.Length; i++) { previousButtonsHeld[i] = new Dictionary <int, bool>(); } }
/// <summary> /// Gets the list of input handlers /// </summary> /// <param name="game">Instance of the current <see cref="QSGame"/></param> /// <returns>A list of handlers</returns> /// <exception cref="ArgumentNullException">If <paramref name="game"/> is null</exception> /// <exception cref="ArgumentException">If the configuration does not contain a handlers section</exception> /// <exception cref="XmlException">If the specified handler entry is invalid</exception> /// <exception cref="TypeLoadException">If the handler could not be loaded or created</exception> public List <InputHandler> GetInputHandlers(QSGame game) { if (game == null) { throw new ArgumentNullException("game"); } List <string> path = new List <string>(new string[] { ConfigurationManager.SectionConfiguration, ConfigurationManager.SectionInputManager }); XmlNode managerNode = this.GetNode(path); if (managerNode == null) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "section '{0}' was not found", "managers")); } List <InputHandler> handlers = new List <InputHandler>(); for (int i = managerNode.ChildNodes.Count - 1; i >= 0; --i) { XmlNode node = managerNode.ChildNodes[i]; // Skip comment nodes if (node.NodeType == XmlNodeType.Comment) { continue; } string typeName = node.Attributes[ConfigurationManager.AttributeValue].Value; if (string.IsNullOrEmpty(typeName) == true) { throw new XmlException("The input handler type was not specified in configuration file"); } Type type = Type.GetType(typeName); if (type == null) { throw new TypeLoadException(string.Format(CultureInfo.InvariantCulture, "Could not find input handler type '{0}'", typeName)); } InputHandler handler = QSActivator.CreateInstance(type, game) as InputHandler; if (handler == null) { throw new TypeLoadException(string.Format(CultureInfo.InvariantCulture, "Input handler type '{0}' was not found", typeName)); } handlers.Add(handler); } return(handlers); }
/// <summary> /// Constructor /// </summary> /// <param name="game">The <see cref="QSGame"/> instance for the game</param> public MouseHandler(QSGame game) : base(game) { MouseState state = Mouse.GetState(); this.lastState[MouseButton.Left] = state.LeftButton; this.lastState[MouseButton.Middle] = state.MiddleButton; this.lastState[MouseButton.Right] = state.RightButton; this.lastState[MouseButton.XButton1] = state.XButton1; this.lastState[MouseButton.XButton2] = state.XButton2; this.lastScrollValue = state.ScrollWheelValue; lastPositionX = lastPositionY = 100; Mouse.SetPosition(lastPositionX, lastPositionY); this.Game.Activated += this.Game_Activated; this.Game.Deactivated += this.Game_Deactivated; this.Game.GameMessage += this.Game_GameMessage; }
/// <summary> /// Create instance of a type. /// </summary> /// <remarks> /// The type must contain a constructor of the form: Type(QSGame) /// </remarks> /// <param name="type">The <see cref="Type"/> to instantiate.</param> /// <param name="game">The <see cref="QSGame"/> instance to pass to the class constructor.</param> /// <returns>An instance of the specified <see cref="Type"/> or null if it could not be instantiated</returns> /// <exception cref="ArgumentNullException">If <paramref name="type"/> or <paramref name="=game"/> are null.</exception> public static object CreateInstance(Type type, QSGame game) { if (type == null) { throw new ArgumentNullException("type"); } if (game == null) { throw new ArgumentNullException("game"); } ConstructorInfo info = type.GetConstructor(new Type[] { typeof(QSGame) }); if (info == null) { return(null); } object instance; try { instance = info.Invoke(new object[] { game }); } catch (Exception exception) { if (exception is SystemException) { throw; } instance = null; } return(instance); }
/// <summary> /// Default constructor /// </summary> public Scene(QSGame game) { this.game = game; this.fogSettings = new FogSettings(); }
/// <summary> /// Constructor /// </summary> /// <param name="game">The <see cref="QSGame"/> instance for the game</param> public BaseManager(QSGame game) { this.enabled = true; this.updateOrder = -1; this.game = game; }
/// <summary> /// Constructor /// </summary> /// <param name="game">The <see cref="QSGame"/> instance for the game</param> public InputHandler(QSGame game) { this.enabled = false; this.updateOrder = -1; this.game = game; }
/// <summary> /// Creates a keyboard handler. /// </summary> /// <param name="game"></param> public KeyboardHandler(QSGame game) : base(game) { this.previousDownKeys = new List <KeyInfo>(); }
/// <summary> /// Constructor /// </summary> /// <param name="game">Instance of the current <see cref="QSGame"/></param> public Settings(QSGame game) : this() { game.GameExiting += Game_Exiting; }
/// <summary> /// Creates and initializes a scene manager. /// </summary> /// <param name="game">Base engine game class</param> public SceneManager(QSGame game) : base(game) { this.Game.Services.AddService(typeof(SceneManager), this); }
/// <summary> /// Constructor /// </summary> /// <param name="game">The <see cref="QSGame"/> instance for the game</param> public InputManager(QSGame game) : base(game) { this.UpdateOrder = Int32.MaxValue; this.handlers = new List <InputHandler>(); }