public void SetControllerOldInputState(InputStates inputFromOldState) { foreach (IController controller in controllerList) { controller.OldInputState = inputFromOldState; } }
public override bool touch_rectangle( InputStates state, Rectangle rect, bool consumeInput) { Vector2 touch_loc = TouchTriggerPosition; if (state == InputStates.Released) { touch_loc = TouchReleasePosition; } else if (state == InputStates.Pressed) { if (TouchPressOutsideTolerance) { return(false); } } touch_loc = Tactile.Input.mouse_world_loc(touch_loc); bool result = rect.Contains( (int)touch_loc.X, (int)touch_loc.Y); if (TouchState.HasEnumFlag(state)) { if (result && consumeInput && consume_touch_input()) { return(false); } return(result); } return(false); }
// Use this for initialization public virtual void Start() { camera_mag = (target_pos - transform.position).magnitude; _camera = GetComponent <Camera>(); lookAtTarget(); inputStates = new InputStates(); }
protected virtual void MoveCenter(InputStates input) { if (input.MouseLeft.IsDragging) { Center += new Vector3(input.MouseLeft.Offset, 0); } }
public static bool Update(ref List <CheatCodeLogic.CheatCode> ___allCheatCodes_, ref bool ___invalidateAll_) { var inputManager_ = G.Sys.InputManager_; var menuPanelManager_ = G.Sys.MenuPanelManager_; var allCheatCodes_ = ___allCheatCodes_; var invalidateAll_ = ___invalidateAll_; if (!inputManager_.GetKey(InputAction.MenuPageLeft, -2) || !inputManager_.GetKey(InputAction.MenuPageRight, -2) || menuPanelManager_.IsOneAboveRoot()) { invalidateAll_ = true; } else { if (invalidateAll_) { for (int index = 0; index < allCheatCodes_.Count; ++index) { allCheatCodes_[index].currentIndex_ = 0; } invalidateAll_ = false; } for (int index1 = 0; index1 < allCheatCodes_.Count; ++index1) { CheatCodeLogic.CheatCode allCheatCode = allCheatCodes_[index1]; if (!allCheatCode.isUnlocked_) { InputAction action = allCheatCode.sequence_[allCheatCode.currentIndex_]; bool flag = false; InputStates inputStates = G.Sys.InputManager_.GetInputStates(-1); for (int index2 = 0; index2 < 55; ++index2) { if (inputStates.GetReleased((InputAction)index2)) { flag = true; } } if (flag) { if (inputManager_.GetKeyUp(action, -2)) { ++allCheatCode.currentIndex_; if (allCheatCode.currentIndex_ == allCheatCode.sequence_.Count) { AudioManager.PostEvent("Play_VocalGPS"); allCheatCode.onCheatCodeEntered_(); allCheatCode.isUnlocked_ = true; } } else { allCheatCode.currentIndex_ = 0; } } } } } return(false); }
private void DoEdit(InputStates input) { if (!TargetVertices.Any()) { return; } if (input.MouseLeft.IsStartingJust) { TargetVertices = TargetMaterial.IsSelected.Where(p => p.Value).Select(p => p.Key); TotalOffset = Matrix.Identity; StartPos = input.MouseLeft.Start; } if (input.MouseLeft.IsDragging) { CurrentPos = input.MouseLeft.Current; UpdateParameter(); // 頂点編集のプレビュー // 直接頂点位置を編集するわけにはいかないので見た目だけ変換する TargetMaterial.TemporaryTransformMatrices *= Offset; TotalOffset *= Offset; // オフセットを得た時点で現在地点を次の初期位置扱いする // 評価ごとの移動量にすることで累積が可能になる StartPos = CurrentPos; } if (input.MouseLeft.IsEndingJust) { // コマンド生成が可能であることを申告 IsReady = true; // プレビュー表示のための変換行列を初期化 TargetMaterial.TemporaryTransformMatrices = Matrix.Identity; } }
static GamePad() { if (SGameWindow.Main is null) { throw new NullReferenceException("Main window is null; don't use input until main window exists"); } SGameWindow.Main.KeyDown += Main_KeyDown; SGameWindow.Main.KeyUp += Main_KeyUp; KeyboardState = new KeyState(); States = new InputStates { GamePadState = OpenTK.Input.GamePad.GetState(FirstPlayer), }; for (var i = 0; i < 6; i++) { var name = OpenTK.Input.GamePad.GetName(i); if (!string.IsNullOrEmpty(name)) { if (FirstPlayer == -1) { FirstPlayer = i; } Console.WriteLine($"Gamepad: {i} {name}"); } } }
void Start() { activeCursor = transform.parent.eulerAngles.y <= 180 ? shootCursorR : shootCursorL; aspectRatio = (referenceScreenWidth / Screen.width) + (referenceScreenHeight / Screen.height); activeCursor.position = shootGuide.position; state = InputStates.Standby; originalRot = gun.right; }
public SceneValues(InputStates i, string name, string text) { FULL_TEXT = text; NAME = name; VISIBLE = ""; MiscValues = new List <object>( ); BefInput = i; }
public override bool Query(int data, InputStates state) { // This isn't a perfect assertion (since not all keys within this integer range are valid), but it's better // than nothing. Debug.Assert(data >= 0 && data <= GLFW_KEY_LAST, "Invalid key (outside maximum range)."); return((keys[data] & state) == state); }
public abstract bool touch_rectangle( InputStates state, Rectangle rect, Vector2 loc, Vector2 rectOriginOffset, float angle, bool mirrored, bool consumeInput);
// This direct access function should be used sparingly (likely only for internal features like the freecam). // All other input queries should use binds. public bool Query(InputTypes inputType, int data, InputStates state) { var inputData = dataArray[(int)inputType]; Debug.Assert(inputData != null, $"Direct input access for type {inputType} is not connected."); return(inputData.Query(data, state)); }
private void RefreshInputState() { _keyboard = _keyboard.Next(KB.GetState()); _mouse = _mouse.Next(MS.GetState()); UpdateGamePadState(PlayerIndex.One); UpdateGamePadState(PlayerIndex.Two); UpdateGamePadState(PlayerIndex.Three); UpdateGamePadState(PlayerIndex.Four); }
private bool consume_touch_input() { if (TouchState.HasEnumFlag(InputStates.InputConsumed)) { return(true); } TouchState |= InputStates.InputConsumed; return(false); }
// Click condition function public static bool Click(InputStates i, GameScene.SceneValues sv) { InputStates ni = new InputStates( ); if (ni.MouseReleased(i).Button == MouseButton.LEFT) { return(true); } return(false); }
public static bool Enter(InputStates i, GameScene.SceneValues sv) { InputStates ni = new InputStates( ); if (ni.KeyUp(i, Keys.Enter)) { return(true); } return(false); }
/// <summary> /// Function that check results of Condition() /// </summary> /// <param name="b"></param> /// <param name="gs"></param> public void ConditionClock(InputStates b, GameScene gs) { if (ConditionWait) { if (Condition(b, gs.VALUES)) { gs.ShowNext( ); Reset( ); } } }
private void Start() { cam = Camera.main; currentState = InputStates.Default; selected = null; mouseButton0Clicked = false; mouseButton1Clicked = false; }
public static bool ClickOrEnter(InputStates i, GameScene.SceneValues sv) { if (Click(i, sv)) { return(true); } else if (Enter(i, sv)) { return(true); } return(false); }
private void Start() { #region Testing doesPlayerHaveControl = false; isInCombat = false; isInDigitalWorld = false; currentFile = GameDataFile.Aplha; GameData.Instance.InitializeGameData(); overworldPlayer = GameObject.FindGameObjectWithTag("Overworld_Controller").GetComponent <OverworldController>(); inputState = InputStates.Overworld; #endregion }
public void DriveTool(InputStates input) { if (Current.Tool is null) { return; } Current.Tool.ReadInput(input); if (Current.Tool.IsReady) { Do(Current.Material, Current.Tool.CreateCommand(Current.Material)); } }
protected override bool get_input( MouseButtons inputName, InputStates inputState, bool consumeInput) { bool result = MouseStates[inputName].HasEnumFlag(inputState); if (result && consumeInput && consume_input(inputName)) { return(false); } return(result); }
protected virtual void Execute(InputStates input, SelectionMode mode, Action <InputStates> editFunction) { switch (mode) { case SelectionMode.Center: MoveCenter(input); break; default: editFunction(input); break; } }
/// <summary> /// Start of whole system /// </summary> /// <param name="sv"></param> public void Init(GameScene sv) { Before( ); input = new InputStates( ); if (Period > 0) { MainClock = new Timer(UpdateClock, sv, this.Period, this.Period); } else { UpdateClick(sv); } }
/// <summary> /// Get the state of a button by name /// </summary> /// <param name="button"></param> /// <param name="gamePadState"></param> /// <returns></returns> private static bool IsButtonDown(this InputStates state, string button, bool gamepadOnly = false) { if (!gamepadOnly && KeyboardMappings.TryGetValue(button, out var key) && KeyboardState.IsKeyDown(key)) { return(true); } var prop = typeof(GamePadButtons).GetProperty(button); if (prop is null) { throw new ArgumentException($"Button {button} is not a valid button", nameof(button)); } return((ButtonState)prop.GetValue(state.GamePadState.Buttons) == ButtonState.Pressed); }
//private sbyte[] dPadButtonPressed; // Storing d-pad presses #endregion #region Initialization public void Awake(GameController _gameController) { leftStickPositions = new float[2] { 0, 0 }; rightStickPositions = new float[2] { 0, 0 }; availableStates = new InputStates[2] { new GameInput(this), new PausedInput(this) }; currentState = availableStates[0]; TogglePause = _gameController.TogglePause; //dPadButtonPressed = new sbyte[2] { 0, 0 }; }
protected override bool get_input( Inputs inputName, InputStates inputState, bool consumeInput) { bool result = ButtonStates[(int)inputName].HasEnumFlag(inputState); if (result) //@Debug { } if (result && consumeInput && consume_input(inputName)) { return(false); } return(result); }
public bool Query(List <InputBind> binds, InputStates state, out InputBind bindUsed) { foreach (InputBind bind in binds) { if (dataArray[(int)bind.InputType].Query(bind.Data, state)) { bindUsed = bind; return(true); } } bindUsed = null; return(false); }
public override void Loop(MovingObject pShip) { InputStates.Clear(); if ((TargetShip.Position - pShip.Position).Length > 16) // chase the player ship if it gets too far { Targets.Clear(); Targets.Add(TargetShip.Position); } else if (Targets.Count == 0) // face the same way as the player ship once you reach it { InputStates.Left = Methods.AngleDifference(pShip.Angle, TargetShip.Angle) < -15; InputStates.Right = Methods.AngleDifference(pShip.Angle, TargetShip.Angle) > 15; } InputStates.Add(MoveToNextTarget(pShip)); InputStates.DetectPresses(); }
public void ResetUpdate() { if (!m_updated) { return; } InputStates tempInputStates = m_previousState; m_previousState = m_currentState; m_currentState = tempInputStates; m_currentState.left = false; m_currentState.right = false; m_currentState.jump = false; m_updated = false; }
public static void RemoveMouseCallback(MouseButtons Mousebutton, InputStates InputState, bool PauseMenu = false) { RemoveCallback((int)Mousebutton, InputState, InputData.InputTypes.Mouse, PauseMenu); }
private static void RemoveCallback(int InputValue, InputStates InputState, InputData.InputTypes InputType, bool PauseMenu) { for (int i = _callbackData.Count - 1; i >= 0; i--) { if (_callbackData[i].InputValue == InputValue && _callbackData[i].InputState == InputState && _callbackData[i].InputType == InputType) { _callbackData.RemoveAt(i); return; } } }
void ApplyTouchInput() { switch(state) { case InputStates.Standby: GunAlignStart(); break; case InputStates.Moving: if (Input.touchCount == 1) { Vector3 touchPos = Input.GetTouch(0).position; Vector3 offset = touchPos - activeCursor.position; activeCursor.position = Camera.main.WorldToScreenPoint(gun.position) + Vector3.ClampMagnitude(offset, 185f/aspectRatio); float d = Vector3.Distance (Camera.main.ScreenToWorldPoint (activeCursor.position), shootGuide.position); GunAlignToCursor(); ArrowStretch(d); shootPower = d * 3f; } else{ state = InputStates.Standby; transform.parent.GetComponent<CharacterControl>().state = CharacterControl.MoveStates.Idle; } break; case InputStates.Shoot: ShootProjectile(); shootPower = 0.1f; shootGuide.localScale = new Vector3(1.5f,1.5f,1f); transform.parent.GetComponent<CharacterControl>().state = CharacterControl.MoveStates.Idle; state = InputStates.Standby; break; default: break; } }
public void Shoot() { state = InputStates.Shoot; }
public InputMap(InputStates last, InputStates now) { this.last = last; this.now = now; }
public void GetInput() { if (inputState == InputStates.Character) { if (Input.KeyPressed(Microsoft.Xna.Framework.Input.Keys.I)) inputState = InputStates.Inventory; if (Input.KeyPressed(Microsoft.Xna.Framework.Input.Keys.P)) inputState = InputStates.Menu; moveAxis = Vector2.Zero; if (Input.DownHeld) { moveAxis += new Vector2(0, 1); } if (Input.UpHeld) { moveAxis += new Vector2(0, -1); } if (Input.LeftHeld) { moveAxis += new Vector2(-1, 0); } if (Input.RightHeld) { moveAxis += new Vector2(1, 0); } if (Input.KeyHeld(Microsoft.Xna.Framework.Input.Keys.Space)) { Attack(); } } else if(inputState == InputStates.Inventory) { if (Input.KeyPressed(Microsoft.Xna.Framework.Input.Keys.I)) inputState = InputStates.Character; if (Input.KeyPressed(Microsoft.Xna.Framework.Input.Keys.P)) inputState = InputStates.Menu; if (menuIndex == 0 && Input.ConfirmPressed) Inventory.UnequipWeapon(); if (menuIndex == 1 && Input.ConfirmPressed) Inventory.UnequipArmor(); if (menuIndex == 2 && Input.ConfirmPressed) Inventory.UnequipOffhand(); if(menuIndex < 3) { if (Input.RightPressed) menuIndex++; if(Input.DownPressed) { if (menuIndex == 0) menuIndex = 3; if (menuIndex == 1) menuIndex = 4; if (menuIndex == 2) menuIndex = 5; } if (Input.LeftPressed || Input.UpPressed) menuIndex--; } else { if (Input.RightPressed) menuIndex++; if (Input.LeftPressed) menuIndex--; if (Input.DownPressed) menuIndex += Inventory.gridWidth; if (Input.UpPressed) { if (menuIndex == 3) menuIndex = 0; else if (menuIndex == 4) menuIndex = 1; else if (menuIndex == 5) menuIndex = 2; else menuIndex -= Inventory.gridWidth; } if(Input.ConfirmPressed) { Inventory.UseItem(menuIndex - 3); } if (menuIndex > Inventory.maxItems + 2) menuIndex = Inventory.maxItems + 2; } DrawDepth = -int.MaxValue; } else if (inputState == InputStates.Menu) { if (Input.KeyPressed(Microsoft.Xna.Framework.Input.Keys.I)) inputState = InputStates.Inventory; if (Input.KeyPressed(Microsoft.Xna.Framework.Input.Keys.P)) inputState = InputStates.Character; DrawDepth = -int.MaxValue; } if (menuIndex < 0) menuIndex = 0; }
public static void RemoveKeyboardCallback(Keys Key, InputStates InputState, bool PauseMenu = false) { RemoveCallback((int)Key, InputState, InputData.InputTypes.Keyboard, PauseMenu); }
public void MoveToTouch() { state = InputStates.Moving; }
void Start() { activeCursor = transform.parent.eulerAngles.y <= 180 ? shootCursorR : shootCursorL; aspectRatio = (referenceScreenWidth / Screen.width) + (referenceScreenHeight/Screen.height); activeCursor.position = shootGuide.position; state = InputStates.Standby; originalRot = gun.right; }
public InputData(int InputValue, DelegateFunctionCall Function, InputStates InputState, InputTypes InputType, bool PauseMenu) { this.Function = Function; this.InputState = InputState; this.InputValue = InputValue; this.InputType = InputType; this.Enabled = true; this.PauseMenu = PauseMenu; }
public static void AddMouseCallback(MouseButtons Mousebutton, DelegateFunctionCall Function, InputStates InputState, bool PauseMenu = false) { _callbackData.Add(new InputData((int)Mousebutton, Function, InputState, InputData.InputTypes.Mouse, PauseMenu)); }
public static void AddKeyboardCallback(Keys Key, DelegateFunctionCall Function, InputStates InputState, bool PauseMenu = false) { _callbackData.Add(new InputData((int)Key, Function, InputState, InputData.InputTypes.Keyboard, PauseMenu)); }