Пример #1
0
        private Collapse GenerateNewItems(IEnumerable <int> columns)
        {
            var collapse = new Collapse();

            //find how many null values the column has
            foreach (int column in columns)
            {
                var emptyCells = board.GetEmptyCellsOnColumn(column);
                foreach (var cell in emptyCells)
                {
                    var prefab = GetRandomItemPrefab();
                    var item   = ((GameObject)Instantiate(prefab.gameObject, spawnPoints[column], Quaternion.identity)).GetComponent <Item>();

                    item.transform.SetParent(board.transform);

                    cell.SetItem(item);

                    if (board.rows - cell.Row > collapse.MaxDistance)
                    {
                        collapse.MaxDistance = board.rows - cell.Row;
                    }

                    collapse.AddCell(cell);
                }
            }

            return(collapse);
        }