コード例 #1
0
    List <Unit[]> getSurroundingMatch4s(Unit u)
    {
        List <Unit[]> candidatesGroups = new List <Unit[]> ();

        Unit[] topRightGroup    = BoardUtilities.getmatch4Units_towards_onTable(u, new Vector2Int(1, 1), unitsTable);
        Unit[] topleftGroup     = BoardUtilities.getmatch4Units_towards_onTable(u, new Vector2Int(-1, 1), unitsTable);
        Unit[] bottomRightGroup = BoardUtilities.getmatch4Units_towards_onTable(u, new Vector2Int(1, -1), unitsTable);
        Unit[] bottomLeftGroup  = BoardUtilities.getmatch4Units_towards_onTable(u, new Vector2Int(-1, -1), unitsTable);

        if (topRightGroup != null)
        {
            candidatesGroups.Add(topRightGroup);
        }
        if (topleftGroup != null)
        {
            candidatesGroups.Add(topleftGroup);
        }
        if (bottomRightGroup != null)
        {
            candidatesGroups.Add(bottomRightGroup);
        }
        if (bottomLeftGroup != null)
        {
            candidatesGroups.Add(bottomLeftGroup);
        }

        return(candidatesGroups);
    }
コード例 #2
0
ファイル: BoardMatch.cs プロジェクト: maax2013/2018test1
    void addAllMatch4s_OnBoard_ToGroup(Unit[,] uTable, List <Unit[]> candidatesGroups)
    {
        List <Unit> allUnitsList = BoardUtilities.getAllUnitsList_onTable(uTable);

        while (allUnitsList.Count > 0)
        {
            Unit   tempU            = allUnitsList [0];
            Unit[] match4s_TopRight = BoardUtilities.getmatch4Units_towards_onTable(tempU, new Vector2Int(1, 1), uTable);
            if (match4s_TopRight != null)
            {
                candidatesGroups.Add(match4s_TopRight);
                foreach (Unit U in match4s_TopRight)
                {
                    //					U.testMark (true);//----------------------------
                    U.BelongingBlocks++;
                }
                BoardUtilities.remove_UnitsInSmallList_FromLargeList(match4s_TopRight, allUnitsList);
            }
            else
            {
                BoardUtilities.tryRemoveFromGroup(tempU, allUnitsList);
            }
        }
    }