protected override void Update(GameTime gameTime) { tick++; updateMessage = ""; inputState.set(Keyboard.GetState(), Mouse.GetState()); if (needToResetUserInput) { needToResetUserInput = false; userInputList.Clear(); userInputList.Add(console); userInputList.Add(inventory); if (currentWorld != null) { if (currentWorld.player != null) { userInputList.Add(currentWorld.player.movement); } } } foreach (InputUser i in userInputList) { inputState = i.update(this, inputState); } inputState.regergitateKeyboardAndMouse(); if (inputState.down(Keys.X)) { currentWorld.player.position.Y += 16; } if (inputState.pressed(Game.KEY_ESCAPE)) { this.Exit(); } if (inputState.pressed(Game.KEY_DEBUG_MENU)) { debugEnabled = !debugEnabled; } SoundEffectPlayer.update(); if (currentWorld != null) { currentWorld.Update(this, tick); if (inputState.getKeyboardState().IsKeyDown(Game.KEY_FAST_FORWARD_CLOCK)) { currentWorld.time += 10; } } EntityItem.playedSoundEffectRecently = false; inputState.setLast(Keyboard.GetState(), Mouse.GetState()); base.Update(gameTime); updateFps.update(); }
private string keyToString(InputState inputState, Keys key) { bool shift = false; if (inputState.down(Keys.LeftShift) || inputState.down(Keys.RightShift)) { shift = !shift; } switch (key) { case Keys.Back: { if (inputPosition > 0) { input = input.Substring(0, inputPosition - 1) + input.Substring(inputPosition); inputPosition--; } return(""); } case Keys.A: return(shift ? "A" : "a"); case Keys.B: return(shift ? "B" : "b"); case Keys.C: return(shift ? "C" : "c"); case Keys.D: return(shift ? "D" : "d"); case Keys.E: return(shift ? "E" : "e"); case Keys.F: return(shift ? "F" : "f"); case Keys.G: return(shift ? "G" : "g"); case Keys.H: return(shift ? "H" : "h"); case Keys.I: return(shift ? "I" : "i"); case Keys.J: return(shift ? "J" : "j"); case Keys.K: return(shift ? "K" : "k"); case Keys.L: return(shift ? "L" : "l"); case Keys.M: return(shift ? "M" : "m"); case Keys.N: return(shift ? "N" : "n"); case Keys.O: return(shift ? "O" : "o"); case Keys.P: return(shift ? "P" : "p"); case Keys.Q: return(shift ? "Q" : "q"); case Keys.R: return(shift ? "R" : "r"); case Keys.S: return(shift ? "S" : "s"); case Keys.T: return(shift ? "T" : "t"); case Keys.U: return(shift ? "U" : "u"); case Keys.V: return(shift ? "V" : "v"); case Keys.W: return(shift ? "W" : "w"); case Keys.X: return(shift ? "X" : "x"); case Keys.Y: return(shift ? "Y" : "y"); case Keys.Z: return(shift ? "Z" : "z"); case Keys.D1: return(shift ? "!" : "1"); case Keys.D2: return(shift ? "@" : "2"); case Keys.D3: return(shift ? "#" : "3"); case Keys.D4: return(shift ? "$" : "4"); case Keys.D5: return(shift ? "%" : "5"); case Keys.D6: return(shift ? "^" : "6"); case Keys.D7: return(shift ? "&" : "7"); case Keys.D8: return(shift ? "*" : "8"); case Keys.D9: return(shift ? "(" : "9"); case Keys.D0: return(shift ? ")" : "0"); case Keys.OemMinus: return(shift ? "_" : "-"); case Keys.OemPlus: return(shift ? "+" : "="); case Keys.OemQuestion: return(shift ? "?" : "/"); case Keys.OemComma: return(shift ? "<" : ","); case Keys.OemPeriod: return(shift ? ">" : "."); case Keys.OemSemicolon: return(shift ? ":" : ";"); case Keys.OemTilde: return(shift ? "\"" : "\'"); case Keys.OemQuotes: return(shift ? "|" : "\\"); case Keys.OemOpenBrackets: return(shift ? "{" : "["); case Keys.OemCloseBrackets: return(shift ? "}" : "]"); case Keys.Tab: return(" "); case Keys.Space: return(" "); case Keys.Left: { inputPosition--; return(""); } case Keys.Right: { inputPosition++; return(""); } } return(""); }
private string keyToString(InputState inputState, Keys key) { bool shift = false; if(inputState.down(Keys.LeftShift) || inputState.down(Keys.RightShift)){ shift = !shift; } switch (key) { case Keys.Back: { if (inputPosition > 0) { input = input.Substring(0, inputPosition - 1) + input.Substring(inputPosition); inputPosition--; } return ""; } case Keys.A: return shift ? "A" : "a"; case Keys.B: return shift ? "B" : "b"; case Keys.C: return shift ? "C" : "c"; case Keys.D: return shift ? "D" : "d"; case Keys.E: return shift ? "E" : "e"; case Keys.F: return shift ? "F" : "f"; case Keys.G: return shift ? "G" : "g"; case Keys.H: return shift ? "H" : "h"; case Keys.I: return shift ? "I" : "i"; case Keys.J: return shift ? "J" : "j"; case Keys.K: return shift ? "K" : "k"; case Keys.L: return shift ? "L" : "l"; case Keys.M: return shift ? "M" : "m"; case Keys.N: return shift ? "N" : "n"; case Keys.O: return shift ? "O" : "o"; case Keys.P: return shift ? "P" : "p"; case Keys.Q: return shift ? "Q" : "q"; case Keys.R: return shift ? "R" : "r"; case Keys.S: return shift ? "S" : "s"; case Keys.T: return shift ? "T" : "t"; case Keys.U: return shift ? "U" : "u"; case Keys.V: return shift ? "V" : "v"; case Keys.W: return shift ? "W" : "w"; case Keys.X: return shift ? "X" : "x"; case Keys.Y: return shift ? "Y" : "y"; case Keys.Z: return shift ? "Z" : "z"; case Keys.D1: return shift ? "!" : "1"; case Keys.D2: return shift ? "@" : "2"; case Keys.D3: return shift ? "#" : "3"; case Keys.D4: return shift ? "$" : "4"; case Keys.D5: return shift ? "%" : "5"; case Keys.D6: return shift ? "^" : "6"; case Keys.D7: return shift ? "&" : "7"; case Keys.D8: return shift ? "*" : "8"; case Keys.D9: return shift ? "(" : "9"; case Keys.D0: return shift ? ")" : "0"; case Keys.OemMinus: return shift ? "_" : "-"; case Keys.OemPlus: return shift ? "+" : "="; case Keys.OemQuestion: return shift ? "?" : "/"; case Keys.OemComma: return shift ? "<" : ","; case Keys.OemPeriod: return shift ? ">" : "."; case Keys.OemSemicolon: return shift ? ":" : ";"; case Keys.OemTilde: return shift ? "\"" : "\'"; case Keys.OemQuotes: return shift ? "|" : "\\"; case Keys.OemOpenBrackets: return shift ? "{" : "["; case Keys.OemCloseBrackets: return shift ? "}" : "]"; case Keys.Tab: return " "; case Keys.Space: return " "; case Keys.Left: { inputPosition--; return ""; } case Keys.Right: { inputPosition++; return ""; } } return ""; }