Пример #1
0
        public List <CellDataBase> Convert(
            List <Level> toDisplay, GameObject cellPrefab,
            DifficultyGroup selectedDiff,
            SortLevelMethod sortMethod, GameObject folderPrefab)
        {
            this.folderPrefab = folderPrefab;

            List <LevelCellData> difficultyMatchLevelCells = new List <LevelCellData>();
            List <LevelCellData> otherLevelCells           = new List <LevelCellData>();

            if (toDisplay.Count == 0)
            {
                return(null);
            }

            foreach (Level level in toDisplay)
            {
                Chart matchingChart = null;
                foreach (Chart chart in level.Charts)
                {
                    if (chart.DifficultyGroup == selectedDiff)
                    {
                        matchingChart = chart;
                    }
                }

                if (matchingChart != null)
                {
                    difficultyMatchLevelCells.Add(new LevelCellData
                    {
                        prefab = cellPrefab,
                        chart  = matchingChart,
                        level  = level,
                    });
                }
                else
                {
                    otherLevelCells.Add(new LevelCellData
                    {
                        prefab = cellPrefab,
                        level  = level,
                        chart  = level.GetClosestChart(selectedDiff),
                    });
                }
            }

            List <CellDataBase> result = GroupCells(difficultyMatchLevelCells, sortMethod);
            List <CellDataBase> otherDifficultiesGroup = GroupCells(otherLevelCells, sortMethod);

            SongFolderData otherDifficultiesFolder = new SongFolderData
            {
                title    = "Other Difficulties",
                children = otherDifficultiesGroup,
                prefab   = folderPrefab
            };

            result.Add(otherDifficultiesFolder);

            return(result);
        }
Пример #2
0
        public override void SetCellData(CellDataBase cellDataBase)
        {
            hoverOverlay.enabled = false;
            SongFolderData folderData = cellDataBase as SongFolderData;

            title.text = folderData.title;
            count.text = cellDataBase.children.Count.ToString();
        }
Пример #3
0
        protected override List <CellDataBase> GroupCells(List <LevelCellData> cells, SortLevelMethod sortMethod)
        {
            if (cells.Count == 0)
            {
                return(cells.ToList <CellDataBase>());
            }

            List <(int, bool, List <LevelCellData>)> groups = new List <(int, bool, List <LevelCellData>)>();

            cells = cells
                    .OrderBy(cell =>
            {
                float cc = cell.chart.Constant;
                (int diff, bool isPlus) = Conversion.CcToDifficulty(cc);
                return(isPlus ? diff + 0.1f : diff);
            })
                    .ThenBy(cell => cell.chart.Name)
                    .ToList();

            //Sort to folders
            (int cdiff, bool cisPlus) = Conversion.CcToDifficulty(cells[0].chart.Constant);
            groups.Add((cdiff, cisPlus, new List <LevelCellData>()));

            foreach (LevelCellData level in cells)
            {
                (int diff, bool isPlus) = Conversion.CcToDifficulty(level.chart.Constant);
                if (diff != cdiff || cisPlus != isPlus)
                {
                    cdiff   = diff;
                    cisPlus = isPlus;
                    groups.Add((diff, isPlus, new List <LevelCellData>()));
                }
                groups[groups.Count - 1].Item3.Add(level);
            }

            List <CellDataBase> folderCells = new List <CellDataBase>();

            foreach ((int diff, bool isPlus, List <LevelCellData> group) in groups)
            {
                SongFolderData newFolder = CreateFolder(diff, isPlus);
                newFolder.children = sortMethod.Convert(group).ToList <CellDataBase>();
                folderCells.Add(newFolder);
            }

            return(folderCells);
        }