void Update() { if (GameManager.Instance.gameState != GameManager.GameState.GAME_RUNNING) { return; } if (Input.anyKeyDown) { string rawInput = Input.inputString; if (rawInput.Length > 0) { Vector2Int playerInput = KeyboardMapper.getPositionInMap(rawInput[0]); if (playerInput != null) { MovePlayer(playerInput); if (onTopOf == LevelLoader.Instance.keyId) { onTopOf = LevelLoader.Instance.floorId; Key keyComponnent = Key.getKeyByPosition(currentPosition); if (keyComponnent != null) { Sound.Instance.Play(2, (int)Sound.soundEvents.GRAB); keyRing.Add(keyComponnent.id); Destroy(keyComponnent.gameObject); } } } } } if (onTopOf == LevelLoader.Instance.victoryPlateId) { GameManager.Instance.PlayerReachedGoal(); } }
static void Main(string[] args) { for (var i = 0; i < args.Length; i++) { if (args[i] == "--debug") { IsDebug = true; } if (args[i] == "--default") { ForceDefaultMapping = true; } if (args[i] == "--skip-ui") { ShouldOpenUI = false; } if (args[i] == "--mapping") { InitialMappingName = args[i + 1]; i++; } if (args[i] == "--start-disabled") { ShouldStartDisabled = true; } } RestServerInstance = new RestServer(); KeyboardMapperInstance = new KeyboardMapper(); ControllerManagerInstance = new ControllerManager(); KeyboardMapperInstance.OnParse += (s, e) => { if (ControllerManagerInstance.IsRunning) { ControllerManagerInstance.Stop(); ControllerManagerInstance.Start(); } }; RestServerInstance.Start(); if (!ShouldStartDisabled) { KeyboardMapperInstance.Start(); ControllerManagerInstance.Start(); } // See https://github.com/gmamaladze/globalmousekeyhook/issues/3#issuecomment-230909645 System.Windows.Forms.ApplicationContext msgLoop = new System.Windows.Forms.ApplicationContext(); ConsoleCtrlHandlerRef += new ConsoleCtrlHandler(HandleConsoleExit); SetConsoleCtrlHandler(ConsoleCtrlHandlerRef, true); System.Windows.Forms.Application.Run(msgLoop); }
public void Run() { var keyboard = new KeyboardMapper(); keyboard.OnInput(InputKey.MOUSE_CLICK); var gamepad = new GamepadMapper(); gamepad.OnInput(GamepadKey.X); }
public static void InputWords(string message) { BotHelper.Wait(60); foreach (var character in message) { Keys key = KeyboardMapper.GetKey(character); Keyboard.KeyPress(key, 50); BotHelper.Wait(100); } BotHelper.Wait(60); }
public void inputWords(string message) { wait(100); foreach (var character in message) { Keys key = KeyboardMapper.GetKey(character); Keyboard.KeyPress(key, 150); wait(100); } wait(100); }
public void UpdateText(Vector2Int position, bool hideWithTime) { char c = KeyboardMapper.getCharInPosition(position); foreach (var t in texts) { t.text = c.ToString(); } if (hideWithTime) { StartCoroutine(hide()); } }
public void talk(string message) { Keyboard.KeyPress(Keys.Enter, 150); WinApi.wait(100); foreach (var character in message) { Keys key = KeyboardMapper.GetKey(character); Keyboard.KeyPress(key, 150); WinApi.wait(100); } WinApi.wait(100); Keyboard.KeyPress(Keys.Enter, 150); }
public void talkInChampSelect(string message) { InputHelper.LeftClick(390, 940, 200); BotHelper.Wait(100); foreach (var character in message) { Keys key = KeyboardMapper.GetKey(character); Keyboard.KeyPress(key, 150); BotHelper.Wait(100); } BotHelper.InputIdle(); Keyboard.KeyPress(Keys.Enter, 150); BotHelper.InputIdle(); }
public void talkInGame(string message) { Keyboard.KeyPress(Keys.Enter, 150); BotHelper.Wait(100); foreach (var character in message) { Keys key = KeyboardMapper.GetKey(character); Keyboard.KeyPress(key, 150); BotHelper.Wait(100); } BotHelper.InputIdle(); Keyboard.KeyPress(Keys.Enter, 150); BotHelper.InputIdle(); }
static void Main(string[] args) { for (var i = 0; i < args.Length; i++) { if (args[i] == "--debug") { IsDebug = true; } if (args[i] == "--default") { ForceDefaultMapping = true; } if (args[i] == "--skip-ui") { ShouldOpenUI = false; } } RestServerInstance = new RestServer(); KeyboardMapperInstance = new KeyboardMapper(); ControllerManagerInstance = new ControllerManager(); KeyboardMapperInstance.OnParse += (s, e) => { if (ControllerManagerInstance.IsRunning) { ControllerManagerInstance.Stop(); ControllerManagerInstance.Start(); } }; RestServerInstance.Start(); KeyboardMapperInstance.Start(); ControllerManagerInstance.Start(); // See https://github.com/gmamaladze/globalmousekeyhook/issues/3#issuecomment-230909645 System.Windows.Forms.ApplicationContext msgLoop = new System.Windows.Forms.ApplicationContext(); System.Windows.Forms.Application.Run(msgLoop); }
KeyboardInput() { inputDevice = EInputDevices.KeyboardMouse; characterInput = new CharacterInputData(); keyMapper = new KeyboardMapper(); }
public void SetupInput() { // Get the move method var moveMethod = this.GetType().GetMethod(nameof(Move)); // Define actions var moveLeftAction = new MethodAction(moveMethod, this) { Values = { new ParameterValue() { Name = "direction", Value = MoveDirection.Left }, new ParameterValue() { Name = "amount", Value = 20d } } }; var jumpLeftAction = new MethodAction(moveMethod, this) { Values = { new ParameterValue() { Name = "direction", Value = MoveDirection.Left }, new ParameterValue() { Name = "amount", Value = 100d } } }; var moveRightAction = new MethodAction(moveMethod, this) { Values = { new ParameterValue() { Name = "direction", Value = MoveDirection.Right }, new ParameterValue() { Name = "amount", Value = 20d } } }; var jumpRightAction = new MethodAction(moveMethod, this) { Values = { new ParameterValue() { Name = "direction", Value = MoveDirection.Right }, new ParameterValue() { Name = "amount", Value = 100d } } }; // Create key bindings var moveLeftKey = new KeyBinding() { Key = VirtualKey.Left, WhenRepeated = true, Action = moveLeftAction }; var jumpLeftKey = new KeyBinding() { Key = VirtualKey.Left, Modifier = VirtualKey.Shift, WhenRepeated = true, Action = jumpLeftAction }; var moveRightKey = new KeyBinding() { Key = VirtualKey.Right, WhenRepeated = true, Action = moveRightAction }; var jumpRightKey = new KeyBinding() { Key = VirtualKey.Right, WhenRepeated = true, Modifier = VirtualKey.Shift, Action = jumpRightAction }; // Create key bindings var moveLeftJoy = new KeyBinding() { Key = VirtualKey.GamepadDPadLeft, WhenRepeated = true, Action = moveLeftAction }; var jumpLeftJoy = new KeyBinding() { Key = VirtualKey.GamepadDPadLeft, Modifier = VirtualKey.GamepadLeftShoulder, WhenRepeated = true, Action = jumpLeftAction }; var moveRightJoy = new KeyBinding() { Key = VirtualKey.GamepadDPadRight, WhenRepeated = true, Action = moveRightAction }; var jumpRightJoy = new KeyBinding() { Key = VirtualKey.GamepadDPadRight, WhenRepeated = true, Modifier = VirtualKey.GamepadLeftShoulder, Action = jumpRightAction }; // Create keyboard mapper var keyMapper = new KeyboardMapper() { Bindings = { moveLeftKey, moveRightKey, jumpLeftKey, jumpRightKey, moveLeftJoy, moveRightJoy, jumpLeftJoy, jumpRightJoy } }; // Start listening to events keyMapper.SubscribeEvents(); }