Esempio n. 1
0
    public bool BreakBlock()
    {
        if (blocks.Count > 0)
        {
            BucketBlock lastBlock = blocks[blocks.Count - 1];
            blockStackTotalHeight      -= lastBlock.blockHeight;
            nextBlockRelativePosition.y = blockStackTotalHeight;
            GameObject.Destroy(lastBlock.gameObject);
            blocks.RemoveAt(blocks.Count - 1);
            return(true);
        }

        return(false);
    }
Esempio n. 2
0
    public void ConnectWithBlock(FallingBlock block)
    {
        // Remove the falling block component and add the bucket block component
        GameObject blockObj    = block.gameObject;
        float      blockHeight = block.blockHeight;

        Object.Destroy(block);
        BucketBlock newBlock = blockObj.AddComponent <BucketBlock>();

        newBlock.blockHeight = blockHeight;

        // Add this to the blocks list
        blocks.Add(newBlock);
        newBlock.transform.position = blockStackParent.transform.position + nextBlockRelativePosition + new Vector3(0, 0.5f * blockHeight, 0);
        newBlock.transform.parent   = blockStackParent;
        nextBlockRelativePosition   = new Vector3(nextBlockRelativePosition.x, nextBlockRelativePosition.y + blockHeight, nextBlockRelativePosition.z);
        blockStackTotalHeight      += blockHeight;
    }