// Update is called once per frame private void Update() { if (AppData.GetCurrentTiltType() == AppData.GroundTiltType.None) { return; } #if UNITY_EDITOR if (Input.GetKeyDown(KeyCode.Space) && jellySprite.IsGrounded(layerMask, 1)) { #else if (jellySprite.IsGrounded(layerMask, 2) && ((AppData.GetCurrentTiltType() == AppData.GroundTiltType.Touch && LeanTouch.Fingers.Count >= 2) || (AppData.GetCurrentTiltType() == AppData.GroundTiltType.Gyro && LeanTouch.Fingers.Count >= 1))) { #endif jumpRegistered = true; } }
// Update is called once per frame void Update() { Debug.DrawLine(transform.position, new Vector2(transform.position.x, transform.position.y - 20f), Color.green); if (jelly.IsGrounded(groundLayer, 1)) { if (tempDelay >= 0f) { tempDelay -= Time.deltaTime; } else { isGrounded = true; tempDelay = dropDelay; } } else if (isGrounded) { if (!Physics2D.Raycast(transform.position, Vector2.down, 20f, groundLayer)) { if (tempDelay >= 0f) { tempDelay -= Time.deltaTime; } else { isGrounded = false; StopDrag(); tempDelay = dropDelay; } } } CheckForMouseDown(); if (startDrag) { print("dragging = " + startDrag); Dragging(); CheckForMouseUp(); } // else if (Input.GetMouseButtonDown(0) && !jelly.IsGrounded(groundLayer, 2) && Camera.main.ScreenToWorldPoint(Input.mousePosition).y < transform.position.y){ // // mPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); // Vector2 slamForce = transform.position - mPos; // jelly.AddForce(-slamForce * 3f); // } }
/// <summary> /// Update this instance. /// </summary> void Update() { m_BounceTimer -= Time.deltaTime; // Randomly bounce around if (m_BounceTimer < 0.0f && m_JellySprite.IsGrounded(m_GroundLayer, 2)) { Vector2 jumpVector = Vector2.zero; jumpVector.x = UnityEngine.Random.Range(m_MinJumpVector.x, m_MaxJumpVector.x); jumpVector.y = UnityEngine.Random.Range(m_MinJumpVector.y, m_MaxJumpVector.y); jumpVector.Normalize(); m_JellySprite.AddForce(jumpVector * UnityEngine.Random.Range(m_MinJumpForce, m_MaxJumpForce)); m_BounceTimer = UnityEngine.Random.Range(m_MinBounceTime, m_MaxBounceTime); } }
protected override bool Grounded() { return(_jelly.IsGrounded(GroundLayers, 2)); }
public bool IsGrounded() { return(jelly.IsGrounded(LayerMask.GetMask("Floor"), 1)); }
/// <summary> /// Update this instance. /// </summary> void Update() { grounded = m_JellySprite.IsGrounded(m_GroundLayer, 1); //speed = Vector2.SqrMagnitude ((( Vector2)transform.localPosition ) - exexPos); //exexPos = exPos; //exPos = transform.localPosition; if (lastJump > 0) { lastJump -= Time.deltaTime; } if (grounded) { if (inJump) { MusicProc.doEvent(ActionEvent.Landed); } inJump = false; } else { inJump = true; } bool left = false; bool right = false; foreach (Touch t in Input.touches) { if (t.position.x > center) { right = true; } else { left = true; } } if (Input.GetKey(KeyCode.RightArrow)) { right = true; } if (Input.GetKey(KeyCode.LeftArrow)) { left = true; } if (left && right) { if (lastJump <= 0 && grounded) { //m_JellySprite.AddForce(Vector2.up * 10000); m_JellySprite.AddForce(Vector3.up * 10000); // - m_JellySprite.WhereIsGround2D(m_GroundLayer)*500); lastJump = 0.5f; MusicProc.doEvent(ActionEvent.Jump); } } else if (right) { //jumpVector += Vector2.right * 150; cx += rotSpeed * Time.deltaTime; if (cx > 1) { cx = 1; } } else if (left) { cx -= rotSpeed * Time.deltaTime; if (cx < -1) { cx = -1; } } else if (cx < 0) { cx += Time.deltaTime * rotSpeed; if (cx >= 0) { cx = 0; } } else if (cx > 0) { cx -= Time.deltaTime * rotSpeed; if (cx <= 0) { cx = 0; } } //Camera.main.transform.rotation = Quaternion.Euler(0, 0, cx * maxAngle); Physics2D.gravity = new Vector2(Mathf.Sin(cx) * gravity, -Mathf.Cos(cx) * gravity); if (Input.GetKeyDown(KeyCode.Escape)) { Application.LoadLevel("menu"); } }