Beispiel #1
0
    private void ProcessTouch(Vector3 position)
    {
        if (Paused)
        {
            return;
        }

        if (_fallManager.Falling)
        {
            return;
        }

        if (_movementLock > 0)
        {
            return;
        }

        var hit2D = Physics2D.Raycast(position, Vector2.zero);

        if (hit2D.collider == null)
        {
            if (_selectedTouchPoint == null)
            {
                return;
            }

            _selectedTouchPoint.DetectTouch(false);
            _selectedTouchPoint = null;

            return;
        }

        AudioManager.Instance.PlaySound(Sounds.Click);

        var touchPointGameObject = hit2D.collider.gameObject;

        if (!touchPointGameObject.CompareTag("TouchPoint"))
        {
            return;
        }

        if (_selectedTouchPoint != null)
        {
            _selectedTouchPoint.DetectTouch(false);
        }

        var touchPoint = touchPointGameObject.GetComponent <TouchPoint>();

        touchPoint.DetectTouch(true);

        _selectedTouchPoint = touchPoint;
    }