Esempio n. 1
0
    public static Unit[] getmatch4Units_towards_onTable(Unit u, Vector2Int diagonal, Unit[,] unitsTable)
    {
        Unit linkedUnit_corner = BoardUtilities.getSameIdUnit_Towards_onTable(u, diagonal, unitsTable);
        Unit linkedUnit_side1  = BoardUtilities.getSameIdUnit_Towards_onTable(u, new Vector2Int(diagonal.x, 0), unitsTable);
        Unit linkedUnit_side2  = BoardUtilities.getSameIdUnit_Towards_onTable(u, new Vector2Int(0, diagonal.y), unitsTable);


        if (linkedUnit_corner && linkedUnit_side1 && linkedUnit_side2)
        {
            /*make sure no overlaps*/
            if (linkedUnit_corner.BelongingBlocks < 1 &&
                linkedUnit_side1.BelongingBlocks < 1 &&
                linkedUnit_side2.BelongingBlocks < 1)
            {
                /*make sure to put self in the first slot*/
                Unit[] match4Group = new Unit[] { u, linkedUnit_corner, linkedUnit_side1, linkedUnit_side2 };
                return(match4Group);
            }
        }
        return(null);
    }