示例#1
0
    /**
     * Add links between the given block and all the blocks it is in-contact with.
     */
    protected void LinkBlock(GameObject editorBlock)
    {
        Block block = editorBlock.GetComponent <Block>();

        // Find all the pips on the game object and check for collisions with other pips.
        // If we find any then we are linked to the blocks that own those pips.
        foreach (var feedbackCollider in feedbackBlock.GetComponentsInChildren <PipCollider>())
        {
            var otherPip = feedbackCollider.GetOtherPip();
            if (otherPip == null)
            {
                continue;
            }

            var otherBlock = otherPip.GetComponentInParent <Block>();
            if (otherBlock == null)
            {
                continue;
            }

            block.AddLink(otherBlock);
            otherBlock.AddLink(block);
        }
    }