예제 #1
0
    float HandleHarborDetection()
    {
        if (_harbor != null)
        {
            float distance = Vector2.Distance(_harbor.center,
                                              collider.center);

            if (distance > _harbor.radius + collider.radius)
            {
                _harbor.SetIndicatorVisibility(false);
                _harbor = null;

                return(-1);
            }

            return(distance);
        }
        else
        {
            List <QTCircleCollider> found = QuadTreeCircleManager.instance.Retrieve(collider);

            if (found.Count > 0)
            {
                _harbor = (Harbor)found[0];
                _harbor.SetIndicatorVisibility(true);
                _isAtRange = false;

                return(Vector2.Distance(_harbor.center,
                                        collider.center));
            }

            return(-1);
        }
    }