Пример #1
0
    private bool IsGroupValid(List <GameObject> group, List <Vector2> blockBounds)
    {
        //check if existing group
        bool isAlreadyGroup = this.IsGroupAlreadyExist(group);

        //check if the geometry is correct
        List <Vector2> boundsFromGeometry = BoundsUtil.GetBoundsFromGeometry(group);
        bool           areBoundsEqual     = BoundsUtil.AreBoundsSizeEqual(boundsFromGeometry, blockBounds, Block.BlockSize / 4f);

        return(isAlreadyGroup == false && areBoundsEqual);
    }
Пример #2
0
    /// <summary>
    /// Unions blocks from the block list representing blocks whoich can be united.
    /// </summary>
    /// <param name="blocks"></param>
    public void UnionBlocks(List <GameObject> blocks)
    {
        print("UnionBlocks");
        BlockColor color = blocks[0].GetComponent <Block>().color;

        //get Bounds
        List <Vector2> bounds = BoundsUtil.GetBoundsFromGeometry(blocks);

        //Destroy blocks
        for (var iB = 0; iB < blocks.Count; iB++)
        {
            this.blocks.Remove(blocks[iB]);
            Destroy(blocks[iB]);
        }

        //Create unioned Block
        int        widthUnits  = Mathf.RoundToInt((bounds[1].x - bounds[0].x) / this.blockSize);
        int        heightUnits = Mathf.RoundToInt((bounds[1].y - bounds[0].y) / this.blockSize);
        GameObject block       = this.CreateBlock(bounds[1].x, bounds[0].y, widthUnits, heightUnits, false, color);

        //Invalidate
        this.InvalidateRows();
    }