예제 #1
0
    protected virtual bool CheckForDropZone(out DropZone dropZone)
    {
        dropZone = null;
        bool found = false;

        List <Collider2D> allOverlappedColliders = new List <Collider2D>();
        ContactFilter2D   filter = new ContactFilter2D();

        filter.SetLayerMask(dropZoneLayerMask);

        int colliderCount = _collider.OverlapCollider(filter, allOverlappedColliders);

        for (int i = 0; i < colliderCount; i++)
        {
            DropZone candidate = allOverlappedColliders[i].GetComponent <DropZone>();

            if (candidate != null)
            {
                if (candidate.CheckIfAccepted(this))
                {
                    dropZone = candidate;
                    found    = true;
                    break;
                }
            }
        }
        return(found);
    }
예제 #2
0
    protected override bool CheckForDropZone(out DropZone dropZone)
    {
        dropZone = null;
        bool found = false;

        Vector2 topCenterPoint = _spriteRenderer.bounds.center;

        topCenterPoint.y = _spriteRenderer.bounds.max.y + (-19 * (1 / 32f));// - ((ClientAmount - 1) * (38 * (1 / 32f)));

        //Debug.DrawLine(topCenterPoint, topCenterPoint + Vector2.up * 0.5f, Color.yellow, 5f);

        Collider2D[] allColliders  = Physics2D.OverlapPointAll(topCenterPoint, dropZoneLayerMask);
        int          colliderCount = allColliders.Length;

        for (int i = 0; i < colliderCount; i++)
        {
            DropZone candidate = allColliders[i].GetComponent <DropZone_ContractSlot>();

            if (candidate != null)
            {
                if (candidate.CheckIfAccepted(this))
                {
                    dropZone = candidate;
                    found    = true;
                    break;
                }
            }
        }

        for (int i = 0; i < colliderCount; i++)
        {
            DropZone_Board candidate = allColliders[i].GetComponent <DropZone_Board>();
            if (candidate != null)
            {
                if (candidate.CheckIfAccepted(this))
                {
                    if (!found)
                    {
                        dropZone      = candidate;
                        boardDropZone = candidate;
                        found         = true;
                    }
                    else
                    {
                        boardDropZone = candidate;
                    }
                    break;
                }
            }
        }
        if (!found)
        {
            for (int i = 0; i < colliderCount; i++)
            {
                DropZone candidate = allColliders[i].GetComponent <DropZone>();
                if (candidate != null)
                {
                    if (candidate.CheckIfAccepted(this))
                    {
                        if (!found)
                        {
                            dropZone = candidate;
                            found    = true;
                            break;
                        }
                    }
                }
            }
        }

        return(found);
    }