/// <summary> /// Reads player input and sets the appropriate info for the movement startegy to use. /// </summary> private void ReadPlayerInput() { // Determine horizontal movement // First we attempt to use Input.GetAxisRaw in case the player is using a controller. // We use GetAxisRaw to avoid Unity's automatic smoothing to enable the player to stop on a dime. // Multiply the input by our movement speed to allow controller users to input analog movement horizontalMovement = Input.GetAxisRaw("Horizontal") * movementSpeed; // If no axis movement was detected, read the keys with out custom keybinding if (horizontalMovement == 0) { if (keyBinding.GetKey("Left") && !keyBinding.GetKey("Right")) { horizontalMovement = -movementSpeed; } else if (!keyBinding.GetKey("Left") && keyBinding.GetKey("Right")) { horizontalMovement = movementSpeed; } } // Determine if player wants to jump // We only want to change jump if it is already false, changing its value when its true can result in missed inputs if (!jump) { jump = keyBinding.GetKeyDown("Jump"); } // Check if the current animal should be switched, using the same method as with jumps if (!switchAnimal) { switchAnimal = keyBinding.GetKeyDown("Switch"); } }
void ChangeKeyBinding(KeyBinding k) { this.moveLeft = k.GetKey("moveLeft"); this.moveRight = k.GetKey("moveRight"); this.dodge = k.GetKey("dodge"); this.attack = k.GetKey("attack"); this.block = k.GetKey("block"); this.firstAbility = k.GetKey("firstAbility"); this.secondAbility = k.GetKey("secondAbility"); this.thirdAbility = k.GetKey("thirdAbility"); this.rageMode = k.GetKey("rageMode"); }
public override void UpdateInput() { if (BattleEntity.GameInPause) { Cursor.visible = true; return; } if (MouseInputEnabled && BattleEntity.Instance != null && !BattleEntity.Instance.IsGameOver) { Cursor.visible = false; AimPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); } else { Cursor.visible = true; } Vector2 moveAxis = Vector2.zero; if (KeyBinding.GetKey(ActionKey.MoveToLeft)) { moveAxis.x = -1; } else if (KeyBinding.GetKey(ActionKey.MoveToRight)) { moveAxis.x = 1; } else { moveAxis.x = 0; } MoveAxis = moveAxis; }
// emulate CrewHatchController, which uses LateUpdate(), not Update() private void LateUpdate() { if (hijack) { considerHijack(); } if (Mouse.CheckButtons(Mouse.GetAllMouseButtonsDown(), Mouse.Buttons.Left) && FlightUIModeController.Instance.Mode != FlightUIMode.ORBITAL) { modclick = modkey.GetKey(); if ((modclick || useCTI) && Physics.Raycast(FlightCamera.fetch.mainCamera.ScreenPointToRay(Input.mousePosition), out hit, RAYCAST_DIST, 1 << LAYER_PARTTRIGGER, QueryTriggerInteraction.Collide)) { if (hit.collider.CompareTag(TAG_AIRLOCK)) { if (InputLockManager.IsAllLocked(ControlTypes.KEYBOARDINPUT)) { Debug.Log("[AirlockPlus] INFO: " + (modclick?"mod+":"") + "click detected on airlock, but input lock is active."); Debug.Log(InputLockManager.PrintLockStack()); } else { Debug.Log("[AirlockPlus] INFO: " + (modclick?"mod+":"") + "click detected on airlock, standing by to hijack CrewHatchDialog."); airlock = hit.collider; hijack = true; chd = null; frame = 0; } } } } }
// Start is called before the first frame update void Start() { moveL = KeyBinding.GetKey(Control.MoveLeft); moveR = KeyBinding.GetKey(Control.MoveRight); jumpButton = KeyBinding.GetKey(Control.Jump); transf = this.GetComponent <Transform>(); rigid = this.GetComponent <Rigidbody2D>(); spriteRen = this.GetComponent <SpriteRenderer>(); }
// Update is called once per frame void Update() { Vector3 delta = new Vector2(); if (Input.GetKey(KeyBinding.GetKey(KeyBinding.Control.MoveLeft))) { delta.x -= spd * Time.deltaTime; } if (Input.GetKey(KeyBinding.GetKey(KeyBinding.Control.MoveRight))) { delta.x += spd * Time.deltaTime; } this.GetComponent <Transform>().position += delta; }
// Start is called before the first frame update void Start() { abilitiesCode = new KeyCode[4]; abilitiesCode[0] = KeyBinding.GetKey(Control.Ability1); abilitiesCode[1] = KeyBinding.GetKey(Control.Ability2); abilitiesCode[2] = KeyBinding.GetKey(Control.Ability3); abilitiesCode[3] = KeyBinding.GetKey(Control.Ability4); abilities = new Ability[4]; for (int i = 0; i < type.Length; i++) { if (type[i] != Ability.specificType.None) { abilities[i] = Ability.AddAbility(type[i], gameObject); } } }
// Start is called before the first frame update void Start() { moveL = KeyBinding.GetKey(Control.MoveLeft); moveR = KeyBinding.GetKey(Control.MoveRight); jumpButton = KeyBinding.GetKey(Control.Jump); transf = this.GetComponent <Transform>(); rigid = this.GetComponent <Rigidbody2D>(); spriteRen = GetComponent <SpriteRenderer>(); //Set def momentum if (Input.GetKey(moveL)) { momentumDelta -= spd; } if (Input.GetKey(moveR)) { momentumDelta += spd; } }
void Control() { if (Input.GetKey(keys.GetKey("Up")) && onAttack.GetAttackState() != AttackState.Attacking) { moveVector.y = 1; } else if (Input.GetKey(keys.GetKey("Down")) && onAttack.GetAttackState() != AttackState.Attacking) { moveVector.y = -1; } else { moveVector.y = 0; } if (Input.GetKey(keys.GetKey("Left")) && onAttack.GetAttackState() != AttackState.Attacking) { moveVector.x = -1; } else if (Input.GetKey(keys.GetKey("Right")) && onAttack.GetAttackState() != AttackState.Attacking) { moveVector.x = 1; } else { moveVector.x = 0; } if (Input.GetKey(keys.GetKey("Dash")) && dashCon == Dash.Nope) { dashCon = Dash.Dashing; } if (Input.GetKey(keys.GetKey("Attack1")) && onAttack.GetAttackState() == AttackState.Nope) { if (melee) { onAttack.AttackMelee(attackDirection); } //onAttack.SetAttackState(AttackState.Attacking); } }
void Control() { if (Input.GetKey(keys.GetKey("Up")) && onAttack.GetAttackState() != AttackState.Attacking) { moveVector.y = 1; } else if (Input.GetKey(keys.GetKey("Down")) && onAttack.GetAttackState() != AttackState.Attacking) { moveVector.y = -1; } else { moveVector.y = 0; } if (Input.GetKey(keys.GetKey("Left")) && onAttack.GetAttackState() != AttackState.Attacking) { moveVector.x = -1; } else if (Input.GetKey(keys.GetKey("Right")) && onAttack.GetAttackState() != AttackState.Attacking) { moveVector.x = 1; } else { moveVector.x = 0; } if (Input.GetKey(keys.GetKey("Dash")) && moveState == MoveState.Nope && gameObject.GetComponent <Player>().currentStamina > 0) { gameObject.GetComponent <Player>().UpdateStamina(-20); moveState = MoveState.Dashing; } if (Input.GetKey(keys.GetKey("Attack1")) && onAttack.GetAttackState() == AttackState.Nope) { onAttack.SetAttackState(AttackState.Attacking); } }