void FixedUpdate() { if (instance.currState == GameManager.gameState.playing) { // Movement if (SimpleInput.GetAxisRaw("Horizontal") > 0) { this.Clockwise.Execute(this.gameObject); Animation.SetBool("Running", true); } else if (SimpleInput.GetAxisRaw("Horizontal") < 0) { this.CounterClockwise.Execute(this.gameObject); Animation.SetBool("Running", true); } // Battle if (SimpleInput.GetButton("Jump")) { this.Shoot.Execute(this.gameObject); this.GetComponent <AudioSource>().Play(); } if (SimpleInput.GetAxisRaw("Horizontal") == 0) { Animation.SetBool("Running", false); } } }
private void OnTriggerStay2D(Collider2D collision) { if (collision.gameObject.CompareTag("Player") && SimpleInput.GetButton("Fire1") && elevatorDoor.level == elevatorDoor.elevator.currentLevel && elevatorDoor.elevator.currentLevel == elevatorDoor.elevator.destinationLevel) { elevatorDoor.open = true; } }
void Update() { if (SimpleInput.GetAxis("Horizontal") != 0 || SimpleInput.GetAxis("Vertical") != 0) { SendMovementInfo(SimpleInput.GetAxis("Horizontal"), SimpleInput.GetAxis("Vertical")); if (Mathf.Abs(SimpleInput.GetAxis("Horizontal")) > 0.85f || Mathf.Abs(SimpleInput.GetAxis("Vertical")) > 0.85f) { SendBoostInfo(1); } else { SendBoostInfo(0); } } if (SimpleInput.GetButton("Fire")) { SendShootingInfo(); } if (SimpleInput.GetButtonDown("Powerup")) { SendPowerupInfo(); } //if (SimpleInput.GetButton("Boost")) //{ // SendBoostInfo(1); //} else if (SimpleInput.GetButtonUp("Boost")) //{ // SendBoostInfo(0); //} }
private void InputDetection() { var horizontal = SimpleInput.GetAxis("Horizontal"); if (horizontal < 0f) { state.HideShield(); state.MoveLeft(); } else if (horizontal > 0f) { state.HideShield(); state.MoveRight(); } else if (horizontal == 0f) { state.GetIdle(); } var vertical = SimpleInput.GetAxis("Vertical"); if (SimpleInput.GetButton("Jump") || vertical > 0f) { state.MoveUp(); } else if (vertical < 0f) { state.MoveDown(); } if (SimpleInput.GetButton("Fire1")) { state.HideShield(); state.UseWeapon(); } else { if (SimpleInput.GetButtonDown("Fire2")) { state.UseShield(); } else if (SimpleInput.GetButtonUp("Fire2")) { state.HideShield(); } } if (SimpleInput.GetButton("Jump")) { GameManager.S.PauseUnpause(); } if (Application.platform == RuntimePlatform.Android) { if (Input.GetKeyDown(KeyCode.Escape)) { GameManager.S.PauseUnpause(); } } }
void Update() { if (isPlayer) { if ((SimpleInput.GetButton("Fire1") || SimpleInput.GetKey(KeyCode.A))) { Shoot(); } } }
private void controlCart() { if (SimpleInput.GetButton("Left")) { if (this.transform.position.z < leftMax) { moveDirection = Vector3.Lerp(moveDirection, Vector3.left * Speed, Time.deltaTime * 5); rotatingAngle = Mathf.Lerp(rotatingAngle, 90, Time.deltaTime * 5); } else { moveDirection = Vector3.Lerp(moveDirection, Vector3.zero, Time.deltaTime * 20); rotatingAngle = Mathf.Lerp(rotatingAngle, 0, Time.deltaTime * 20); } } else if (SimpleInput.GetButton("Right")) { if (this.transform.position.z > rightMin) { moveDirection = Vector3.Lerp(moveDirection, Vector3.right * Speed, Time.deltaTime * 5); rotatingAngle = Mathf.Lerp(rotatingAngle, -90, Time.deltaTime * 5); } else { moveDirection = Vector3.Lerp(moveDirection, Vector3.zero, Time.deltaTime * 20); rotatingAngle = Mathf.Lerp(rotatingAngle, 0, Time.deltaTime * 20); } } else { moveDirection = Vector3.Lerp(moveDirection, Vector3.zero, Time.deltaTime * 20); rotatingAngle = Mathf.Lerp(rotatingAngle, 0, Time.deltaTime * 20); } this.transform.Translate(moveDirection); foreach (Transform wheel in wheels) { wheel.Rotate(Vector3.forward, rotatingAngle); } if (Input.GetKeyDown(KeyCode.Space)) { setPropColors(); } }
private void FixedUpdate() { pointsScreen.SetActive(!StaticClass.disableInput && SimpleInput.GetButton("Points Screen")); if (StaticClass.disableInput) { Move(0, false, false); } else { vertical = SimpleInput.GetAxis("Vertical"); Move(SimpleInput.GetAxis("Horizontal"), SimpleInput.GetButton("Jump"), SimpleInput.GetButton("Run")); if (SimpleInput.GetButtonUp("Fire2")) { Drop(); GetComponent <AudioSource>().PlayOneShot(openSound); } } }
private void OnTriggerStay2D(Collider2D collision) { Camera.main.GetComponent <CameraScript>().TxtAction.text = "Ascensseur"; if (collision.gameObject.CompareTag("Player") && SimpleInput.GetButton("Fire1")) { GameObject inHand = collision.gameObject.GetComponent <Player>().inHand; if (inHand != null) { ElevatorCard card = inHand.GetComponent <ElevatorCard>(); if (card != null) { elevatorPanel.SetActive(true); return; } } } Camera.main.GetComponent <CameraScript>().TxtAction.text += "\nNécessite un pass"; }
/// <summary> /// Find user input. Should put this in its own class but im lazy /// </summary> private void MyInput() { x = SimpleInput.GetAxisRaw("Horizontal"); y = SimpleInput.GetAxisRaw("Vertical"); jumping = SimpleInput.GetButton("Jump"); crouching = SimpleInput.GetButton("Crouch"); if (SimpleInput.GetKeyDown(KeyCode.Q)) { DamagePlayer(); } //Crouching if (SimpleInput.GetButtonDown("Crouch")) { StartCrouch(); } if (SimpleInput.GetButtonUp("Crouch")) { StopCrouch(); } }
public void Update() { // The slider should have a default value of the minimum launch force. m_AimSlider.value = m_MinLaunchForce; // If the max force has been exceeded and the shell hasn't yet been launched... if (m_CurrentLaunchForce >= m_MaxLaunchForce && !m_Fired) { // ... use the max force and launch the shell. m_CurrentLaunchForce = m_MaxLaunchForce; Fire(m_CurrentLaunchForce, 1); } // Otherwise, if the fire button has just started being pressed... else if (SimpleInput.GetButtonDown(m_FireButton)) { // ... reset the fired flag and reset the launch force. m_Fired = false; m_CurrentLaunchForce = m_MinLaunchForce; // Change the clip to the charging clip and start it playing. //m_ShootingAudio.clip = m_ChargingClip; //m_ShootingAudio.Play (); } // Otherwise, if the fire button is being held and the shell hasn't been launched yet... else if (SimpleInput.GetButton(m_FireButton) && !m_Fired) { // Increment the launch force and update the slider. m_CurrentLaunchForce += m_ChargeSpeed * Time.deltaTime; m_AimSlider.value = m_CurrentLaunchForce; } // Otherwise, if the fire button is released and the shell hasn't been launched yet... else if (SimpleInput.GetButtonUp(m_FireButton) && !m_Fired) { // ... launch the shell. Fire(m_CurrentLaunchForce, 1); } }
// Update is called once per frame void Update() { time += Time.deltaTime; if (SimpleInput.GetButton("Fire")) { if (Time.time - lastfired > 1 / Firerate && Bullets > 0) { lastfired = Time.time; shoot = true; Instantiate(Bullet, new Vector3(Gunpoint.transform.position.x, Gunpoint.transform.position.y, 0), Quaternion.identity); Muzzle.Play(); Bullets--; manager.Shoot(2); } } if (SimpleInput.GetButton("Rocket")) { if (time > Missilerate && Missiles > 0) { shoot = true; Instantiate(Missile, Gunpoint.transform.position, Quaternion.identity); time = 0f; Missiles--; manager.Shoot(1); } } if (SimpleInput.GetButtonUp("Fire")) { shoot = false; Muzzle.Stop(); } if (SimpleInput.GetButtonUp("Rocket")) { shoot = false; } animator.SetBool("Shoot", shoot); }
void Update() { //if (!GameStates.gameActive) return; // Get device type if (SystemInfo.deviceType == DeviceType.Desktop) { // Input for keyboard (mostly for testing purposes) float horizontal = Input.GetAxisRaw("Horizontal"); if (Input.GetMouseButton(0)) { ps.Aim(); //if (OnStateChange != null) OnStateChange(PlayerStates.firingWeapon); } else if (Input.GetMouseButtonUp(0)) { ps.StopAim(); } if ((Input.GetKeyDown(KeyCode.Space)) || (Input.GetMouseButtonDown(1))) { if (OnStateChange != null) { OnStateChange(PlayerStates.jump); } } if (horizontal != 0f) { if (horizontal < 0f) { if (OnStateChange != null) { OnStateChange(PlayerStates.left); } facingRight = !facingRight; } else { if (OnStateChange != null) { OnStateChange(PlayerStates.right); } facingRight = !facingRight; } } else { if (OnStateChange != null) { OnStateChange(PlayerStates.idle); } } } else if (SystemInfo.deviceType == DeviceType.Handheld) { // Mobile input if (SimpleInput.GetButton("Attack")) { ps.Aim(); //if (OnStateChange != null) OnStateChange(PlayerStates.firingWeapon); } else if (SimpleInput.GetButtonUp("Attack")) { ps.StopAim(); } if (SimpleInput.GetButtonDown("Jump")) { if (OnStateChange != null) { OnStateChange(PlayerStates.jump); } } if (SimpleInput.GetButton("Left")) { if (OnStateChange != null) { OnStateChange(PlayerStates.left); } } else if (SimpleInput.GetButton("Right")) { if (OnStateChange != null) { OnStateChange(PlayerStates.right); } } else { if (OnStateChange != null) { OnStateChange(PlayerStates.idle); } } } }
protected void updateSelfAgentFromInput() { #region get control input float inputHorizontal = SimpleInput.GetAxis("Horizontal"); float inputVertical = SimpleInput.GetAxis("Vertical"); float aimInputHorizontal = SimpleInput.GetAxis("HorizontalAim"); float aimInputVertical = SimpleInput.GetAxis("VerticalAim"); Vector3 aimDirection = getDirectionRelativeToCamera(new Vector3(aimInputVertical, 0, -aimInputHorizontal)); bool runPressed = SimpleInput.GetButton("Run"); bool crouchPressed = SimpleInput.GetButtonDown("Crouch"); bool dodge = SimpleInput.GetButtonDown("Dodge"); bool rifle = SimpleInput.GetButtonDown("Rifle"); bool pistol = SimpleInput.GetButtonDown("Pistol"); #endregion #region control agent from input #region movment control if (rifle) { m_selfAgent.togglePrimaryWeapon(); } if (pistol) { m_selfAgent.togglepSecondaryWeapon(); } if (crouchPressed) { m_selfAgent.toggleHide(); m_crouched = !m_crouched; } if (dodge) { m_selfAgent.dodgeAttack(getDirectionRelativeToCamera((new Vector3(inputVertical, 0, -inputHorizontal).normalized) * 1.5f)); } if (runPressed) { if (m_selfAgent.isCrouched()) { m_selfAgent.toggleHide(); } m_selfAgent.moveCharacter(getDirectionRelativeToCamera((new Vector3(inputVertical, 0, -inputHorizontal).normalized) * 1.5f)); } else { if (m_crouched && !m_selfAgent.isCrouched()) { m_selfAgent.toggleHide(); } m_selfAgent.moveCharacter(getDirectionRelativeToCamera(new Vector3(inputVertical, 0, -inputHorizontal).normalized)); } #endregion #region aiming and fire control if (aimDirection.normalized.magnitude > 0) { m_selfAgent.aimWeapon(); m_targetFinder.updateTargetFinder(aimDirection, this.transform.position); m_selfAgent.setTargetPoint(m_targetFinder.getCalculatedTargetPosition()); if (m_targetFinder.canFireAtTargetAgent()) { m_selfAgent.pullTrigger(); } else { m_selfAgent.releaseTrigger(); } } else { m_selfAgent.stopAiming(); m_selfAgent.releaseTrigger(); m_targetFinder.disableTargetIndicator(); } #endregion #endregion }
public void Evaluate(string buttonName) { pressed = SimpleInput.GetButtonDown(buttonName); held = SimpleInput.GetButton(buttonName); released = SimpleInput.GetButtonUp(buttonName); }
private void OnTriggerStay2D(Collider2D collision) { if (dropped && collision.gameObject.CompareTag("Player") && collision.gameObject.GetComponent <Player>().inHand == null && SimpleInput.GetButton("Fire1")) { dropped = false; GetComponent <SpriteRenderer>().sprite = pickedSprite; transform.parent = collision.gameObject.transform; transform.localPosition = Vector2.zero; collision.gameObject.GetComponent <Player>().inHand = gameObject; GetComponent <Rigidbody2D>().simulated = false; } }
public bool ActionButtonPressed() { return(SimpleInput.GetButton("Action")); }