/// <summary> /// Updates the input manager, checking for changes in input /// </summary> /// <param name="pGameTime"></param> public void Update(GameTime pGameTime) { // IF there are keyboard listeners if (NewKeyboardInput != null) { // DELCARE and INSTANTIATE a new KeyboardHandler and pass it 'entityComponentLink, call it 'args' IKeyboardInput args = new KeyboardHandler(_entityComponentLink); // IF a key has been pressed then trigger keyboard event if (args.GetInputKey().Length > 0) { OnNewKeyboardInput(); } } // IF there are mouse listeners if (NewMouseInput != null) { // DELCARE and INSTANTIATE a new MouseHandler and pass it 'entityComponentLink, call it 'args' IMouseInput args = new MouseHandler(); // IF a key has been pressed then trigger mouse event if (args.GetMouseVal() != null) { OnNewMouseInput(args); } } }
/// <summary> /// Publisher method, contacts all listeners /// </summary> private void OnNewKeyboardInput() { // DECLARE and INSTANTIATE a new KeyboardHandler, call it 'args' and pass it '_entityComponentLink' IKeyboardInput args = new KeyboardHandler(_entityComponentLink); // Trigger NewKeyboardInput events, passing it 'args' NewKeyboardInput(this, args); }