InputHandler input; //GameConsole depends on InputHandler public GameConsole(Game game) : base(game) { this.fontName = "Arial"; //default font this.gameConsoleText = new List <string>(); this.maxLines = 20; //deafult nuber of lines this.debugText = "Console default \ndebug text"; this.ToggleConsoleKey = Keys.OemTilde; //default key this.debugTextStartX = 400; //Default locationX this.debugTextStartY = 0; //Default locationY this.debugTextOutput = new Dictionary <string, string>(); this.gameConsoleState = GameConsoleState.Open; input = (InputHandler)game.Services.GetService(typeof(IInputHandler)); //Make sure input service exsists if not lazily add one if (input == null) { //try to add one input = new InputHandler(game); game.Components.Add(input); //Check again if (input == null) { throw new Exception("GameConsole Depends on Input service please add input service before you add GameConsole."); } } game.Services.AddService(typeof(IGameConsole), this); }
InputHandler input; //GameConsole depends on InputHandler public GameConsole(Game game) : base(game) { // TODO: Construct any child components here this.fontName = "Arial"; this.gameConsoleText = new List <string>(); this.gameConsoleText.Add("Console Initalized"); content = new ContentManager(game.Services); this.maxLines = 20; this.debugText = "Console default \ndebug text"; this.ToggleConsoleKey = Keys.OemTilde; this.gameConsoleState = GameConsoleState.Open; input = (InputHandler)game.Services.GetService(typeof(IInputHandler)); //Make sure input service exsists if (input == null) { //try to add one input = new InputHandler(game); game.Components.Add(input); //Check again if (input == null) { throw new Exception("GameConsole Depends on Input service please add input service before you add GameConsole."); } } game.Services.AddService(typeof(IGameConsole), this); }
public GameConsole(Game game) : base(game) { // TODO: Construct any child components here this.fontName = "Arial"; this.gameConsoleText = new List<string>(); this.gameConsoleText.Add("Console Initalized"); content = new ContentManager(game.Services); this.maxLines = 20; this.debugText = "Console default \n debug text"; this.ToggleConsoleKey = Keys.OemTilde; this.gameConsoleState = GameConsoleState.Closed; input = (InputHandler)game.Services.GetService(typeof(IInputHandler)); //Make sure input service exsists if (input == null) { throw new Exception("GameConsole Depends on Input service please add input service before you add GameConsole."); } game.Services.AddService(typeof(IGameConsole), this); }
/// <summary> /// Opens or closes the Console Display /// </summary> public void ToggleConsole() { if (this.gameConsoleState == GameConsoleState.Closed) { this.gameConsoleState = GameConsoleState.Open; } else { this.gameConsoleState = GameConsoleState.Closed; } }
public void Awake() { ToggleConsoleKey = KeyCode.BackQuote; gameConsoleText = new List <string>(); gameConsoleState = GameConsoleState.Open; MaxLines = 15; GameConsoleWrite("Awake Called"); debugText = "Default Debug Text"; //Test for Canvas and GameConsoleText and Debug Text }
public void ToggleConsole() { if (this.gameConsoleState == GameConsoleState.Closed) { this.gameConsoleState = GameConsoleState.Open; Console.enabled = true; Debug.enabled = true; } else { this.gameConsoleState = GameConsoleState.Closed; Console.enabled = false; Debug.enabled = false; } }
/// <summary> /// Allows the game component to update itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> public override void Update(GameTime gameTime) { // TODO: Add your update code here if (input.KeyboardState.HasReleasedKey(ToggleConsoleKey)) { if (this.gameConsoleState == GameConsoleState.Closed) { this.gameConsoleState = GameConsoleState.Open; } else { this.gameConsoleState = GameConsoleState.Closed; } } base.Update(gameTime); }
InputHandler input; //GameConsole depends on InputHandler public GameConsole(Game game) : base(game) { this.fontName = "Arial"; //default font this.gameConsoleText = new List <string>(); this.maxLines = 20; //default number of lines this.debugText = "Console default \ndebug text"; this.ToggleConsoleKey = Keys.OemTilde; //default key this.debugTextStartX = 400; //Default locationX this.debugTextStartY = 0; //Default locationY this.debugTextOutput = new Dictionary <string, string>(); this.gameConsoleState = GameConsoleState.Open; //InputHandler Dependency input = GameUtil.GetService <InputHandler, IInputHandler>(game); game.Services.AddService(typeof(IGameConsole), this); }
public override void Update(GameTime gameTime) { if (input.KeyboardState.HasReleasedKey(ToggleConsoleKey)) { if (this.gameConsoleState == GameConsoleState.Closed) this.gameConsoleState = GameConsoleState.Open; else this.gameConsoleState = GameConsoleState.Closed; } base.Update(gameTime); }