void DirBall() { //마우스 조종 if (Input.GetMouseButton(0)) { mousePt = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, -Camera.main.transform.position.z)); vecDir = mousePt - trans.position; vecDir = vecDir.normalized; float angle = Mathf.Atan2(vecDir.y, vecDir.x) * 180f / Mathf.PI; if (angle <= 170f && angle >= 10f) { Vector3 angleVec = trans.rotation.eulerAngles; trans.rotation = Quaternion.Euler(angleVec.x, angleVec.y, angle); } state = BALLSTATE.TOUCH; } if (Input.GetMouseButtonUp(0) && state == BALLSTATE.TOUCH) { state = BALLSTATE.MOVE; ArrowObject.SetActive(false); startPosition = trans.position; } }
void SetStateIDLE() { if (_isCheck) { _ballState = BALLSTATE.IDLE; } }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag.Equals("Wall")) { if (_currentMovePower >= 8.0f) { UIManager.instance.ShakeCamera(0.05f, 0.1f); } _currentMovePower -= 2f; Vector3 incomingVector = _currentMovePowerVector; //transform.position - _startMovePos; //입사각 //incomingVector = incomingVector.normalized * _currentMovePower; Vector3 inverseVector = -incomingVector; //입사각의 반대각 Vector3 normalVector = collision.contacts[0].normal; //법선벡터 Vector3 reflectVector = Vector3.Reflect(incomingVector, normalVector); //반사각 myRigidbody.velocity = Vector2.zero; if (_trajectyVelocity != Vector3.zero) // 궤적이 있을경우에는 궤적 방향으로 { myRigidbody.AddForce(_trajectyVelocity, ForceMode2D.Impulse); } else { myRigidbody.AddForce(reflectVector, ForceMode2D.Impulse); } GetComponent <trajectory>().temp = Vector3.zero; _trajectyVelocity = Vector3.zero; Debug.Log(" _currentMovePower : " + _currentMovePower); } if (collision.gameObject.tag.Equals("Ground")) { if (_currentMovePower >= 8.0f) { UIManager.instance.ShakeCamera(0.025f, 0.1f); } _trajectyVelocity = Vector3.zero; if (transform.position.y > collision.transform.position.y) { // 충돌할 경우 슬로우모션 없애주고 Ball 상태 초기화 _ballState = BALLSTATE.IDLE; SetSlowMotionTime(false); if (myRigidbody.velocity != Vector2.zero) { myRigidbody.velocity = Vector2.zero; } _trailCrt = StartCoroutine(Tween.instance.DelayMethod(0.3f, DisableTrail)); } } }
float SetAngle(Collision2D coll) { if (coll.gameObject.tag == "Player" && m_tState[(int)BALLITEM.GRAP].bIsPlay) { m_fColX = Mathf.Abs(BarTrans.position.x - coll.contacts[0].point.x); if (BarTrans.position.x >= coll.contacts[0].point.x) { m_fColX *= -1; } temp.AddForce(Vector2.zero); ArrowObject.SetActive(true); state = BALLSTATE.GRAP; //Debug.Log(m_fColX); } float angle = 0f; Vector2 point = coll.contacts[0].point; temp.AddForce(Vector2.zero); incidence = (Vector3)point - startPosition; normalVec = coll.contacts[0].normal; vecDir = Vector3.Reflect(incidence, normalVec); if (coll.gameObject.tag == "Block" && coll.gameObject.GetComponent <BlockController>().GetBlockID() == 9) { vecDir = new Vector3(Random.Range(0f, 360f), Random.Range(0f, 360f), 0f); } vecDir = vecDir.normalized; startPosition = point; angle = Mathf.Atan2(vecDir.y, vecDir.x) * 180f / Mathf.PI; if (Mathf.Abs(angle) >= 160 || Mathf.Abs(angle) <= 20) { if (angle < 0) { angle += 50; } else { angle -= 50; } } return(m_fTestAngle = angle); }
// direction : true +, flase - IEnumerator SetSlowDurtion(bool direction) { _SlowDurationCount = 0f; ImgDurationEdge.fillAmount = 1f; while (_SlowDurationCount < 1.0f) { _SlowDurationCount = Mathf.Clamp01(_SlowDurationCount + Time.deltaTime / LevelingData.slowDurationTime); if (direction) { objSlowDuration.transform.localScale = new Vector3(1.0f * _SlowDurationCount, 1.0f * _SlowDurationCount, 0f); ImgDurationEdge.fillAmount = 1.0f * _SlowDurationCount; } yield return(null); } SetSlowMotionTime(false); _ballState = BALLSTATE.NONEMOVEING; TouchPower.instance.objStart.SetActive(false); TouchPower.instance.objEnd.SetActive(false); }
private void SetStateEvent(int mouseEvent) { if (mouseEvent == 0) // up { DisableDurationEdge(); Sound.instance.PlayEffSound(SOUND.S_JUMP); if (_isFirstTouch) { WallManager.instance.HideGround(); _isFirstTouch = false; } TouchPower.instance.MovePower = 0f; SetSlowMotionTime(false); if (_ballState == BALLSTATE.IDLE) { _ballState = BALLSTATE.JUMP_ONCE; // 0.1초 딜레이동안 WALL과 충돌중이면 상태를 IDLE로 변경 Invoke("SetStateIDLE", 0.1f); } else if (_ballState == BALLSTATE.JUMP_ONCE) { _ballState = BALLSTATE.JUMP_TWICE; } } else if (mouseEvent == 1) // stay { if (_ballState == BALLSTATE.JUMP_ONCE && _isSlowing == false) { SetSlowMotionTime(true); } } }