Exemplo n.º 1
0
    private static void SetCandy(MatchThree_Cell firstCell, MatchThree_Types types)
    {
        MatchThree_Cell  cell     = firstCell;
        MatchThree_Candy newCandy = types.GetRandomCandy();

        while (!IsFreeCandyPlacement(cell, newCandy.CandyData.Id))
        {
            Destroy(newCandy.gameObject);
            newCandy = types.GetRandomCandy();
        }

        cell.Candy = newCandy;
        cell.Candy.transform.position = cell.transform.position;
    }
Exemplo n.º 2
0
    private void SetupCandiesLine(MatchThree_Cell firstCell, Direction direction)
    {
        MatchThree_Cell cell = firstCell;

        while (cell)
        {
            MatchThree_Candy newCandy = m_Types.GetRandomCandy();
            //пробуем генерить пока не получим разрешенную кoнефетку
            //типов конфеток должно быть 5 или более - иначе возможен вариант вечного цикла
            while (!IsFreeCandyPlacement(cell, newCandy.CandyData.Id))
            {
                Destroy(newCandy.gameObject);
                newCandy = m_Types.GetRandomCandy();
            }

            cell.Candy = newCandy;
            cell.Candy.transform.position = cell.transform.position;
            cell = cell.GetNeighbour(direction);
        }
    }