public IntImput(IInputable textBox) { this.check = true; this.text = ""; this.textToInt = 0; this.textBox = textBox; }
public virtual IInputable[] TextBoxs(string name) { GetMapObjects(TestObjectType.TextBox, name); IInputable[] tmp = new IInputable[_lastObjects.Length]; _lastObjects.CopyTo(tmp, 0); return tmp; }
public virtual IInputable[] TextBoxs(TestProperty[] properties) { GetMapObjects(TestObjectType.TextBox, properties); IInputable[] tmp = new IInputable[_lastObjects.Length]; _lastObjects.CopyTo(tmp, 0); return tmp; }
public void Register(IInputable inputable, int priority) { if (!this.inputablePriorities.ContainsKey(priority)) { this.inputablePriorities[priority] = new FastList <IInputable>(); } this.inputablePriorities[priority].Add(inputable); }
/// <summary> /// Prevents a default instance of the <see cref="Engine" /> class from being created. /// </summary> private Engine() { this.consoleDrawer = new ConsoleRenderer(); this.consoleReader = new ConsoleInput(); this.inputHandler = new InputHandler(this.consoleDrawer, this.consoleReader); this.mineFactory = new MineCreator(); this.highscore = new HighScore(); this.finalScore = InitialScore; }
public void Start() { _inputable = new MouseInput(); _playerInstance = _player.CreatePlayer(); _ballInstance = _ball.CreateBall(this); _arrowInstance = _arrow.CreateArrow(); _aiInstance = _ai.CreateAI(); _mapInstance = _map.CreateMap(); _blocks = new List <Block>(); _blocks.Add(_block.CreateBlock(new Vector3(LeftBlockX, BlockY, BlockZ))); _blocks.Add(_block.CreateBlock(new Vector3(CenterBlockX, BlockY, BlockZ))); _blocks.Add(_block.CreateBlock(new Vector3(RightBlockX, BlockY, BlockZ))); _entityTransform = new EntityTransform(Camera.main, _playerInstance, _ballInstance, _arrowInstance, _aiInstance); _difficultGame = new DifficultGame(); _saveState = new SaveState(_ballInstance); _uiManager.GameManager = this; StartGame(); }
private void Reconstruct(DisplayInfo dInfo, WPFBlockCrash.BlockCrashView.EOperatingType OperatingType) { switch (OperatingType) { case BlockCrashView.EOperatingType.DESKTOP_KEYBOARD: CurrentState = title = new Title(this, dInfo, new DesktopKeyboard()); break; case BlockCrashView.EOperatingType.VIRTOS_SLIDER: CurrentState = title = new Title(this, dInfo, new VIRTOSSlider()); break; case BlockCrashView.EOperatingType.AUTO: CurrentState = title = new Title(this, dInfo, new AutomaticOperator()); break; default: throw new InvalidOperationException("EOperatingType is UNKNOWN."); } ResultIgnore = true; }
public void ProcessLoop(Input input, Graphics g) { g.FillRectangle(Brushes.Black, 0, 0, 800, 600); if (input.IsPushedKeys) { input.rB = input.RB.Output; input.lB = input.LB.Output; input.eB = input.EB.Output; } if (input.AT) //自動化状態 { ATMode(input); if (input.barx == 50 || (input.eB && input.lB && input.rB)) { input.AT = false; SwapOperatingMode(); Restart(input); } } ProcessResult r = CurrentState.Process(input, g, userChoice, takeOver); if (!ResultIgnore) { CurrentState = r.NextState; } else { CurrentState = title; ResultIgnore = false; } input.ClearSmaller(); }
/// <summary> /// creates a new ui manager /// </summary> /// <param name="game">the parent game to reference to</param> /// <param name="assetManager">the asset manager for the ui elements to reference to</param> public UIManager(Game game, AssetManager assetManager) { Game = game; SortMode = SpriteSortMode.FrontToBack; Assets = assetManager; Elements = new Dictionary <string, UIElement>(); CurrentInput = null; ScrollMultiplier = -16; lastPressedKeys = new Keys[0]; lastScrollAmount = 0; KeyToCharMap = new Dictionary <Keys, char>(); KeyToShiftedCharMap = new Dictionary <Keys, char>(); InputShifted = false; TopUINode = new GroupElement(this, new Vector2(0, 0), new Vector2(Game.GraphicsDevice.Viewport.Width, Game.GraphicsDevice.Viewport.Height), 0f, "top"); AddKeyToChar(Keys.D0, '0', ')'); //lmk if there is a better way to go about adding these characters AddKeyToChar(Keys.D1, '1', '!'); AddKeyToChar(Keys.D2, '2', '@'); AddKeyToChar(Keys.D3, '3', '#'); AddKeyToChar(Keys.D4, '4', '$'); AddKeyToChar(Keys.D5, '5', '%'); AddKeyToChar(Keys.D6, '6', '^'); AddKeyToChar(Keys.D7, '7', '&'); AddKeyToChar(Keys.D8, '8', '*'); AddKeyToChar(Keys.D9, '9', '('); AddKeyToChar(Keys.OemPipe, '\\', '|'); AddKeyToChar(Keys.OemQuestion, '/', '?'); AddKeyToChar(Keys.OemMinus, '-', '_'); AddKeyToChar(Keys.OemPlus, '=', '+'); AddKeyToChar(Keys.OemComma, ',', '<'); AddKeyToChar(Keys.OemPeriod, '.', '>'); AddKeyToChar(Keys.OemQuotes, '\'', '"'); AddKeyToChar(Keys.OemSemicolon, ';', ':'); AddKeyToChar(Keys.OemOpenBrackets, '[', '{'); AddKeyToChar(Keys.OemCloseBrackets, ']', '}'); AddKeyToChar(Keys.OemTilde, '`', '~'); AddKeyToChar(Keys.A, 'a', 'A'); AddKeyToChar(Keys.B, 'b', 'B'); AddKeyToChar(Keys.C, 'c', 'C'); AddKeyToChar(Keys.D, 'd', 'D'); AddKeyToChar(Keys.E, 'e', 'E'); AddKeyToChar(Keys.F, 'f', 'F'); AddKeyToChar(Keys.G, 'g', 'G'); AddKeyToChar(Keys.H, 'h', 'H'); AddKeyToChar(Keys.I, 'i', 'I'); AddKeyToChar(Keys.J, 'j', 'J'); AddKeyToChar(Keys.K, 'k', 'K'); AddKeyToChar(Keys.L, 'l', 'L'); AddKeyToChar(Keys.M, 'm', 'M'); AddKeyToChar(Keys.N, 'n', 'N'); AddKeyToChar(Keys.O, 'o', 'O'); AddKeyToChar(Keys.P, 'p', 'P'); AddKeyToChar(Keys.Q, 'q', 'Q'); AddKeyToChar(Keys.R, 'r', 'R'); AddKeyToChar(Keys.S, 's', 'S'); AddKeyToChar(Keys.T, 't', 'T'); AddKeyToChar(Keys.U, 'u', 'U'); AddKeyToChar(Keys.V, 'v', 'V'); AddKeyToChar(Keys.W, 'w', 'W'); AddKeyToChar(Keys.X, 'x', 'X'); AddKeyToChar(Keys.Y, 'y', 'Y'); AddKeyToChar(Keys.Z, 'z', 'Z'); }
/// <summary> /// updates the for input and updates the ui elements /// </summary> public void Update() { MouseState = Mouse.GetState(); KeyboardState = Keyboard.GetState(); if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || KeyboardState.IsKeyDown(Keys.Escape)) { Game.Exit(); } TopUINode.Update(); //mouse clicks Vector2 mousePos = new Vector2(MouseState.X, MouseState.Y); if ((MouseState.LeftPressed() && !PreviousMouseState.LeftPressed()) || (MouseState.RightPressed() && !PreviousMouseState.RightPressed()) || (MouseState.MiddlePressed() && !PreviousMouseState.MiddlePressed())) { CurrentInput = null; TopUINode.MousePressed(MouseState, new Vector2(0, 0)); } if ((!MouseState.LeftPressed() && PreviousMouseState.LeftPressed()) || (!MouseState.RightPressed() && PreviousMouseState.RightPressed()) || (!MouseState.MiddlePressed() && PreviousMouseState.MiddlePressed())) { TopUINode.MouseReleased(MouseState, new Vector2(0, 0)); } //scrolling int scrollAmount = MouseState.ScrollWheelValue; float scrollValue = Math.Sign(lastScrollAmount - scrollAmount) * ScrollMultiplier; if (scrollValue != 0) { TopUINode.Scroll(MouseState, scrollValue); } //text input Keys[] pressedKeys = KeyboardState.GetPressedKeys(); List <Keys> newKeys = FindChanges(pressedKeys, lastPressedKeys); List <Keys> releasedKeys = FindChanges(lastPressedKeys, pressedKeys); if (newKeys.Contains(Keys.LeftShift) || newKeys.Contains(Keys.RightShift)) { InputShifted = true; } else if (!releasedKeys.Contains(Keys.LeftShift) && !releasedKeys.Contains(Keys.RightShift)) { InputShifted = false; } lastPressedKeys = pressedKeys; if (CurrentInput != null) { for (int i = 0; i < newKeys.Count; i++) { Keys key = newKeys[i]; char keyChar = KeyToChar(key, InputShifted); char[] validKeys = CurrentInput.ValidKeys; bool isValid = false; for (int j = 0; j < validKeys.Length; j++) { if (validKeys[j].Equals(keyChar)) { isValid = true; break; } } if (isValid) { CurrentInput.Text = CurrentInput.Text + keyChar; } else { if (key.Equals(Keys.Back)) { if (CurrentInput.Text.Length > 0) { CurrentInput.Text = CurrentInput.Text.Substring(0, CurrentInput.Text.Length - 1); } } } } } PreviousMouseState = MouseState; PreviousKeyboardState = KeyboardState; lastScrollAmount = scrollAmount; }
//use dependancy injection(design pattern) for private fields in the engine //show what the engine class uses in order to work public Engine()//TODO: pass needed arguments through the constructor or with dependancy injection { consoleDrawer = new ConsoleRenderer(); consoleReader = new ConsoleInput(consoleDrawer); }
public ProcessResult Process(Input input, Graphics g, UserChoice uc, TakeOver takeOver) { if (GameFrameProcess(input, g, uc, takeOver)) { if (Stock > 1) { if (IsPlaying) { message = new Message(EMessageType.FAILED, 50, dInfo); IsPlaying = false; mainBall.IsStop = true; } if (message.Process(input, g, uc, takeOver).IsDead) { Reset(); --Stock; IsPlaying = true; message = null; } } else // Stock == 0 { if (IsPlaying) { message = new Message(EMessageType.GAMEOVER, 120, dInfo); IsPlaying = false; mainBall.IsStop = true; } if (message.Process(input, g, uc, takeOver).IsDead) { return(new ProcessResult() { IsDead = true, NextState = new Ranking(Score, BarType, dInfo, Operator), TakeOver = takeOver }); } } } else if (cleared) { if (IsPlaying) { message = new Message(EMessageType.CLEAR, 200, dInfo); IsPlaying = false; mainBall.IsStop = true; } if (message.Process(input, g, uc, takeOver).IsDead) { if (input.AT) { return new ProcessResult() { IsDead = true, NextState = new Title(Main.MainInstance, dInfo, Operator), TakeOver = takeOver } } ; else { return new ProcessResult() { IsDead = true, NextState = new Ranking(Score, BarType, dInfo, Operator), TakeOver = takeOver } }; } } return(new ProcessResult() { IsDead = false, NextState = this, TakeOver = takeOver, UserChoice = uc }); }
/// <summary> /// Initializes a new instance of the <see cref="InputHandler" /> class. /// </summary> /// <param name="drawer">An instance of IDrawer for the UI.</param> /// <param name="inputer">An instance of IInputable to get the user input.</param> public InputHandler(IDrawer drawer, IInputable inputer) { this.drawer = drawer; this.inputer = inputer; }