private void GamePlayInputs() { if (GameManager.instance.status == GameStatus.GamePlay) { //Rotate Player To Left if (SwipeManager.IsSwipingLeft() && myCollision.canTurn) { EventManager.TriggerEvent(EventManager.instance.RotateLeftButton); } //Rotate Player To Right else if (SwipeManager.IsSwipingRight() && myCollision.canTurn) { EventManager.TriggerEvent(EventManager.instance.RotateRightButton); } //Jump Player else if (SwipeManager.IsSwipingUp()) { EventManager.TriggerEvent(EventManager.instance.JumpButton); } else if (SwipeManager.IsSwipingDown()) { EventManager.TriggerEvent(EventManager.instance.CrouchButton); } else if (Input.GetMouseButton(0)) { EventManager.TriggerEvent(EventManager.instance.MoveButton); } } }
// Update is called once per frame void Update() { if (SwipeManager.IsSwipingLeft()) { // do something Debug.Log("LEFT"); } if (SwipeManager.IsSwipingRight()) { // do something Debug.Log("RIGHT"); } if (SwipeManager.IsSwipingDown()) { // do something Debug.Log("DOWN"); } if (SwipeManager.IsSwipingUp()) { // do something Debug.Log("UP"); } if (SwipeManager.IsSwipingDownLeft()) { // do something Debug.Log("DownLeft"); } }
void Update() { if (autoDetectSwipes) { DetectSwipe(); } if (GameManager.instance.inRun) { if (SwipeManager.IsSwipingUp()) { GameManager.instance.MovePlayer("2"); } if (SwipeManager.IsSwipingDown()) { GameManager.instance.MovePlayer("8"); } if (SwipeManager.IsSwipingLeft()) { GameManager.instance.MovePlayer("4"); } if (SwipeManager.IsSwipingRight()) { GameManager.instance.MovePlayer("6"); } } }
void Jump() { if (Input.GetKeyDown(KeyCode.Space) || SwipeManager.IsSwipingUp()) { if (Mathf.Abs(myRigidbody.velocity.y) > Mathf.Epsilon) { return; } Vector3 jumpVelocityToAdd = new Vector3(0f, jumpSpeed, 0f); myRigidbody.velocity += jumpVelocityToAdd; } bool isJumping = Mathf.Abs(myRigidbody.velocity.y) > Mathf.Epsilon; animator.SetBool("Jump", isJumping); }
void MoveOnSwipe() { if (SwipeManager.IsSwipingUp()) { if (Time.time > nextJump) { nextJump = Time.time + jumpRate; myRigidBody.velocity = new Vector3(myRigidBody.velocity.x, 5f, 0f); } } if (SwipeManager.IsSwiping()) { //shooting //isFire=true; /*Debug.Log("tragem tragem tragem "); * if(Time.time>nextFire){ * nextFire=Time.time+fireRate; * myAnim.Play("WalkAndFire"); * Instantiate(bullet,bulletSpawn.position,bulletSpawn.rotation); * * }/* */ } //} if (SwipeManager.IsSwipingLeft()) { moveSpeed = moveSpeed - 1; if (moveSpeed <= 1) { moveSpeed = 1; } } if (SwipeManager.IsSwipingRight()) { moveSpeed = moveSpeed + 1; if (moveSpeed >= 10) { moveSpeed = 10; } } }
public Vector3 inputToDirection() { if (Input.GetKeyDown(KeyCode.A) || SwipeManager.IsSwipingLeft()) { direction = Vector3.left; return(Vector3.left); } else if (Input.GetKeyDown(KeyCode.D) || SwipeManager.IsSwipingRight()) { direction = Vector3.right; return(Vector3.right); } else if (Input.GetKeyDown(KeyCode.S) || SwipeManager.IsSwipingDown()) { direction = Vector3.down; return(Vector3.down); } else if (Input.GetKeyDown(KeyCode.W) || SwipeManager.IsSwipingUp()) { direction = Vector3.up; return(Vector3.up); } return(Vector3.zero); }
// Update is called once per frame void Update() { #if UNITY_EDITOR if (Input.GetMouseButtonDown(0)) { Ray ray = _cam.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; if (Physics.Raycast(ray, out hitInfo, 3f, _layer)) { if (hitInfo.collider.GetComponent <JointScript>() != null) { _cacheJointScript = hitInfo.collider.GetComponent <JointScript>(); hitTarget = true; holding = true; } } if (hitTarget) { _cacheJointScript.Grabbed(); _camScript.SetAnchorTransformTarget(_cacheJointScript.ReturnAnchorTransform()); } } if (Input.GetMouseButtonUp(0)) { hitTarget = false; } if (holding) { if (Input.GetKeyDown(KeyCode.Space)) { Debug.Log("Swiped UP"); if (_raycastController.IsHit()) { _cacheJointScript.Release(_raycastController.ReturnHitVectorPoint()); } else { _cacheJointScript.Release(_camScript.ReturnVectorPoint()); } holding = false; _cacheJointScript = null; } } #endif if (Input.touchCount > 0) { var touch = Input.GetTouch(0); Ray ray = _cam.ScreenPointToRay(Input.GetTouch(0).position); RaycastHit hit; if (Physics.Raycast(ray, out hit, 3, _layer)) { if (hit.collider.GetComponent <JointScript>() != null) { _cacheJointScript = hit.collider.GetComponent <JointScript>(); hitTarget = true; holding = true; } } if (hitTarget) { if (SwipeManager.IsSwipingDown() || SwipeManager.IsSwipingDownLeft() || SwipeManager.IsSwipingDownRight()) { _cacheJointScript.Grabbed(); _camScript.SetAnchorTransformTarget(_cacheJointScript.ReturnAnchorTransform()); } } if (touch.phase == TouchPhase.Ended) { hitTarget = false; } if (holding) { if (SwipeManager.IsSwipingUp() || SwipeManager.IsSwipingUpLeft() || SwipeManager.IsSwipingUpRight()) { Debug.Log("Swiped UP"); if (_raycastController.IsHit()) { _cacheJointScript.Release(_raycastController.ReturnHitVectorPoint(), true); } else { _cacheJointScript.Release(_camScript.ReturnVectorPoint()); } holding = false; _cacheJointScript = null; } } } }
private void Update() { if (CardGameManager.Instance.ModalCanvas != null || editor.searchResults.inputField.isFocused) { return; } if (CardViewer.Instance.Zoom && CardViewer.Instance.ZoomTime > 0.5f && SwipeManager.DetectSwipe()) { if (SwipeManager.IsSwipingUp()) { SelectEditorDown(); } else if (SwipeManager.IsSwipingDown()) { SelectEditorUp(); } if (SwipeManager.IsSwipingRight()) { SelectResultsLeft(); } else if (SwipeManager.IsSwipingLeft()) { SelectResultsRight(); } } if (Inputs.IsVertical) { if (Inputs.IsDown && !Inputs.WasDown) { SelectResultsDown(); } else if (Inputs.IsUp && !Inputs.WasUp) { SelectResultsUp(); } } else if (Inputs.IsHorizontal) { if (Inputs.IsLeft && !Inputs.WasLeft) { SelectResultsLeft(); } else if (Inputs.IsRight && !Inputs.WasRight) { SelectResultsRight(); } } if (Inputs.IsPageVertical) { if (Inputs.IsPageDown && !Inputs.WasPageDown) { SelectEditorDown(); } else if (Inputs.IsPageUp && !Inputs.WasPageUp) { SelectEditorUp(); } } else if (Inputs.IsPageHorizontal) { if (Inputs.IsPageLeft && !Inputs.WasPageLeft) { SelectEditorLeft(); } else if (Inputs.IsPageRight && !Inputs.WasPageRight) { SelectEditorRight(); } } }
void Update() { if (CardGameManager.Instance.ModalCanvas != null || editor.searchResults.inputField.isFocused) { return; } if (CardViewer.Instance.Zoom && CardViewer.Instance.ZoomTime > 0.5f && SwipeManager.DetectSwipe()) { if (SwipeManager.IsSwipingUp()) { SelectEditorDown(); } else if (SwipeManager.IsSwipingDown()) { SelectEditorUp(); } if (SwipeManager.IsSwipingRight()) { SelectResultsLeft(); } else if (SwipeManager.IsSwipingLeft()) { SelectResultsRight(); } } if (Input.GetButtonDown(Inputs.Vertical) || Input.GetAxis(Inputs.Vertical) != 0) { if (Input.GetAxis(Inputs.Vertical) < 0 && !_wasDown) { SelectResultsDown(); } else if (Input.GetAxis(Inputs.Vertical) > 0 && !_wasUp) { SelectResultsUp(); } } else if (Input.GetButtonDown(Inputs.Horizontal) || Input.GetAxis(Inputs.Horizontal) != 0) { if (Input.GetAxis(Inputs.Horizontal) < 0 && !_wasLeft) { SelectResultsLeft(); } else if (Input.GetAxis(Inputs.Horizontal) > 0 && !_wasRight) { SelectResultsRight(); } } if (Input.GetButtonDown(Inputs.PageVertical) || Input.GetAxis(Inputs.PageVertical) != 0) { if (Input.GetAxis(Inputs.PageVertical) < 0 && !_wasPageDown) { SelectEditorDown(); } else if (Input.GetAxis(Inputs.PageVertical) > 0 && !_wasPageUp) { SelectEditorUp(); } } else if ((Input.GetButtonDown(Inputs.PageHorizontal) || Input.GetAxis(Inputs.PageHorizontal) != 0)) { if (Input.GetAxis(Inputs.PageHorizontal) < 0 && !_wasPageLeft) { SelectEditorLeft(); } else if (Input.GetAxis(Inputs.PageHorizontal) > 0 && !_wasPageRight) { SelectEditorRight(); } } _wasDown = Input.GetAxis(Inputs.Vertical) < 0; _wasUp = Input.GetAxis(Inputs.Vertical) > 0; _wasLeft = Input.GetAxis(Inputs.Horizontal) < 0; _wasRight = Input.GetAxis(Inputs.Horizontal) > 0; _wasPageDown = Input.GetAxis(Inputs.PageVertical) < 0; _wasPageUp = Input.GetAxis(Inputs.PageVertical) > 0; _wasPageLeft = Input.GetAxis(Inputs.PageHorizontal) < 0; _wasPageRight = Input.GetAxis(Inputs.PageHorizontal) > 0; }
void Update() { if (MovementActive) { if (target != null && (Vector2)mTransform.position != target.WorldPosition) { MovementTo(target.WorldPosition); } #if UNITY_EDITOR || UNITY_WEBG || UNITY_WEBGL || UNITY_WEBGL_API if (Input.GetKeyDown(KeyCode.UpArrow)) { nextTarget = WorldGrid.Instance.CheckMovementRoom(target, 0, 1); direction = PlayerDirection.Up; } if (Input.GetKeyDown(KeyCode.DownArrow)) { nextTarget = WorldGrid.Instance.CheckMovementRoom(target, 0, -1); direction = PlayerDirection.Down; } if (Input.GetKeyDown(KeyCode.RightArrow)) { nextTarget = WorldGrid.Instance.CheckMovementRoom(target, 1, 0); direction = PlayerDirection.Right; } if (Input.GetKeyDown(KeyCode.LeftArrow)) { nextTarget = WorldGrid.Instance.CheckMovementRoom(target, -1, 0); direction = PlayerDirection.Left; } #else if (SwipeManager.IsSwipingUp()) { nextTarget = WorldGrid.Instance.CheckMovementRoom(currentPosition, 0, 1); direction = PlayerDirection.Up; } if (SwipeManager.IsSwipingDown()) { nextTarget = WorldGrid.Instance.CheckMovementRoom(currentPosition, 0, -1); direction = PlayerDirection.Down; } if (SwipeManager.IsSwipingRight()) { nextTarget = WorldGrid.Instance.CheckMovementRoom(currentPosition, 1, 0); direction = PlayerDirection.Right; } if (SwipeManager.IsSwipingLeft()) { nextTarget = WorldGrid.Instance.CheckMovementRoom(currentPosition, -1, 0); direction = PlayerDirection.Left; } #endif if (nextTarget != null && nextTarget != target && (Vector2)mTransform.position == target.WorldPosition) { if (currentPosition.Edges[(int)direction]) { target = nextTarget; } } } }
void Update() { if (CardGameManager.TopMenuCanvas != null || editor.searchResults.nameInputField.isFocused) { return; } if (CardInfoViewer.Instance.zoomPanel.gameObject.activeSelf && SwipeManager.DetectSwipe()) { if (SwipeManager.IsSwipingDown()) { SelectUp(); } else if (SwipeManager.IsSwipingUp()) { SelectDown(); } else if (SwipeManager.IsSwipingRight()) { SelectLeft(); } else if (SwipeManager.IsSwipingLeft()) { SelectRight(); } } if (Input.anyKeyDown) { if (Input.GetButtonDown(Inputs.Vertical)) { if (Input.GetAxis(Inputs.Vertical) > 0) { SelectUp(); } else { SelectDown(); } } else if (Input.GetButtonDown(Inputs.Horizontal)) { if (Input.GetAxis(Inputs.Horizontal) > 0) { SelectRight(); } else { SelectLeft(); } } else if (Input.GetButtonDown(Inputs.Column)) { if (Input.GetAxis(Inputs.Column) > 0) { ShiftRight(); } else { ShiftLeft(); } } else if (Input.GetButtonDown(Inputs.Page) && !CardInfoViewer.Instance.IsVisible) { if (Input.GetAxis(Inputs.Page) > 0) { PageRight(); } else { PageLeft(); } } } }