Beispiel #1
0
    private void HitCircle(CircleController circle)
    {
        this.circle = circle;
        ArrowState  = State.ON_CIRCLE;

        outOfBorder    = false;
        timeSinceStart = 0;

        Vector2 touchPosition  = transform.position;
        Vector2 circleCenter   = circle.gameObject.transform.position;
        Vector2 touchToCenter  = circleCenter - touchPosition;
        Vector2 prevRbVelocity = rb.velocity;

        rb.velocity = Vector2.zero;

        float angleBetVectors = Vector2.Angle(circleCenter - touchPosition, Vector2.right);

        startRotation = Mathf.PI + angleBetVectors * Mathf.Deg2Rad;

        currentRotationX = null;

        Vector2 circleTangent = new Vector2(touchToCenter.y, -touchToCenter.x) / touchToCenter.magnitude;

        float perpArrowAngle = Vector2.Angle(circleTangent, prevRbVelocity);

        if (perpArrowAngle >= 90)
        {
            movingClockwise = true;
        }
        else
        {
            movingClockwise = false;
        }

        // play circle fade out animation
        circle.FadeOut();

        SoundManager.Instance.PlayHit();
        ScoreManager.Instance.DisplayScore(Mathf.FloorToInt(transform.position.y + Camera.main.orthographicSize));
    }