Exemplo n.º 1
0
    void ConnectFromBelow(Tile newParent)
    {
        if (hasSingleParent)
        {
            if (leftParent != null)
            {
                Debug.LogError("left parent not null");
            }

            Debug.Log("Connecting single parent");
            leftParent = newParent;
            leftParent.child = this;
            transform.position = newParent.transform.position + transform.up * (-1.0f * transform.localScale.y + -snapMargin);
            AttachLeftLine( transform.up * 1.0f);
        }
        else
        {
            if (leftParent != null || rightParent != null)
            {
                Debug.LogError("Both parents not null on two parent tile being dragged");
            }

            if (newParent.transform.position.x < transform.position.x)
            {
                ConnectLeftFromBelow(newParent);
            }
            else
            {
                ConnectRightFromBelow(newParent);
            }
        }

        newParent.HideBottomLine();
    }
Exemplo n.º 2
0
    void ConnectFromAbove(Tile newParent)
    {
        if (hasSingleParent)
        {
            if (leftParent != null)
            {
                Debug.LogError("left parent not null");
            }

            Debug.Log("Connecting single parent");
            leftParent = newParent;
            leftParent.child = this;
            newParent.transform.position = transform.position + transform.up * (1.0f * transform.localScale.y + snapMargin);
            AttachLeftLine( transform.up * 1.0f);
        }
        else
        {
            if (leftParent == null && rightParent != null)
            {
                ConnectLeftFromAbove(newParent);
            }
            else if (rightParent == null && leftParent != null)
            {
                ConnectRightFromAbove(newParent);
            }
            else if (leftParent == null && rightParent == null)
            {
                if (newParent.transform.position.x < transform.position.x)
                {
                    ConnectLeftFromAbove(newParent);
                }
                else
                {
                    ConnectRightFromAbove(newParent);
                }
            }
            else
            {
                Debug.LogError("Neither parent null");
            }
        }

        newParent.HideBottomLine();
    }