Esempio n. 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);
        }
Esempio n. 2
0
 public static string GetJson(DifficultyGroup dg)
 {
     return($@"
     {{
         ""color"": ""{dg.Color.ToHexcode()}"",
         ""name"": ""{dg.Name}"",
         ""precedence"": ""{dg.Precedence}""
     }}");
 }
        public void Display(List <Chart> charts, DifficultyGroup selectedDiff, bool playAnimation = false)
        {
            if (charts.Count == 0)
            {
                Reset();
                return;
            }

            charts.OrderBy(chart => chart.DifficultyGroup.Precedence);
            int diffIndex = 0;

            for (int i = 0; i < charts.Count; i++)
            {
                if (charts[i].DifficultyGroup == selectedDiff)
                {
                    diffIndex = i;
                    mainItem.Set(charts[i]);
                }
            }
            if (diffIndex == charts.Count - 1)
            {
                NextGroup = charts[0].DifficultyGroup;
            }
            else
            {
                NextGroup = charts[diffIndex + 1].DifficultyGroup;
            }

            int j = diffIndex;

            foreach (DifficultyItem item in subItems)
            {
                j++;
                if (j >= charts.Count)
                {
                    j = 0;
                }
                if (j == diffIndex)
                {
                    break;
                }
                item.Set(charts[j]);
            }

            for (int i = charts.Count - 1; i < subItems.Count; i++)
            {
                subItems[i].Reset();
            }

            currentDiffName.text = selectedDiff.Name;

            //TODO: Animation
        }
Esempio n. 4
0
        public void Display(List <Level> levels, Level selectedLevel, DifficultyGroup selectedDiff)
        {
            //Set scroll list data
            List <CellDataBase> displayCells = SortingMethodSelect.Convert(levels, selectedDiff, cellPrefab, folderPrefab);

            scrollRect.SetData(displayCells);
            lastSelectedLevel = selectedLevel;
            //TODO: jump to selected level in scrollrect

            //if playanimation is true then animate the cell's scrolling to the new position
            //else play the entrance animation
        }
Esempio n. 5
0
        public void ChartParse_WithCustomDifficulty_Success(string diff, string expectedChartPath)
        {
            DifficultyGroup dg = JsonUserInput.FromPreset(diff);

            Chart actual = getDummyChart();

            actual.DifficultyGroup = dg;
            actual.ChartPath       = expectedChartPath;
            string json = JsonHelper.GetJson(actual);

            JObject jobj  = JObject.Parse(json);
            Chart   chart = JsonUserInput.ReadChartJson(jobj.CreateReader());

            Assert.That(
                chart.DifficultyGroup == dg &&
                chart.ChartPath == expectedChartPath,
                json
                );
        }
Esempio n. 6
0
        public static (Chart chart, string json) GenerateChart(
            DifficultyGroup dg, string d, float constant,
            string song, string img, string bg,
            string name, string namer, string artist, string artistr,
            string bpm, string charter, string illust,
            string chartpath, string style
            )
        {
            Style s;

            switch (style.ToLower())
            {
            case "conflict":
                s = Style.Conflict;
                break;

            case "light":
            default:
                s = Style.Light;
                break;
            }

            Chart chart = new Chart
            {
                DifficultyGroup = dg,
                Difficulty      = new Difficulty(d),
                Constant        = constant,
                SongPath        = song ?? "base.ogg",
                ImagePath       = img ?? "base.jpg",
                Background      = bg ?? "bg.jpg",
                Name            = name,
                NameRomanized   = namer ?? name,
                Artist          = artist,
                ArtistRomanized = artistr ?? artist,
                Bpm             = bpm,
                Charter         = charter,
                Illustrator     = illust,
                ChartPath       = chartpath ?? JsonUserInput.GetChartPathFromPresetGroup(dg),
                Style           = s
            };

            return(chart, GetJson(chart));
        }
Esempio n. 7
0
 public static string GetChartPathFromPresetGroup(DifficultyGroup group)
 {
     if (group == Past)
     {
         return("0.arc");
     }
     else if (group == Present)
     {
         return("1.arc");
     }
     else if (group == Future)
     {
         return("2.arc");
     }
     else if (group == Beyond)
     {
         return("3.arc");
     }
     throw new System.Exception("Unknown difficulty group");
 }
Esempio n. 8
0
        public void Display(Level selectedLevel, DifficultyGroup selectedDiff)
        {
            //Set selected level data
            if (selectedLevel == null)
            {
                Reset();
            }
            else
            {
                Chart chart = selectedLevel.GetExactChart(selectedDiff);

                selectedTitle.text       = chart.Name;
                selectedArtist.text      = chart.Artist;
                selectedIllustrator.text = chart.Illustrator;
                selectedBpm.text         = "BPM: " + chart.Bpm;
                selectedCharter.text     = "Charter: " + chart.Charter;
                selectedScore.text       = Conversion.ScoreDisplay(chart.PbScore.GetValueOrDefault());
                //TODO: set img of selectedGrade

                string jacketPath = selectedLevel.GetRealPath(chart.ImagePath);
                StartCoroutine(SetJacketCoroutine(jacketPath));
            }
        }
Esempio n. 9
0
    public void SingleStartHost()
    {
        DropdownFix[] fixes  = GameObject.FindObjectsOfType <DropdownFix>();
        int           values = 0;

        for (int i = 0; i < fixes.Length; i++)
        {
            values += fixes[i].value;
        }
        if (values <= 0)
        {
            //Start Game button is now interactable only when player hasn't chosen a preset.
            return;
        }
        //Note(Thompson): Player is always index 1.
        //Note(Thompson): Obtain the A.I. level difficulty.
        GameMetricLogger.instance.levelDifficulty = fixes[0].value;
        //Note(Thompson): Check if the Player dropdown value is 5. If not, and is above 0, return difficulty equation used. Else, return a full range of custom equations used.
        GameMetricLogger.SetDifficultyEquation(ConvertCustomToEquations(fixes[1].value, fixes[1].options[fixes[1].value].text));
        GameMetricLogger.SetPlayerName("Player");


        if (this.attributePanelGroup != null)
        {
            this.attributePanelGroup.alpha          = 0f;
            this.attributePanelGroup.blocksRaycasts = false;
            this.attributePanelGroup.interactable   = false;
        }

        GameObject minimapCameraObject = GameObject.FindGameObjectWithTag("Minimap");
        Camera     minimapCamera       = minimapCameraObject.GetComponent <Camera>();

        if (minimapCamera != null && !minimapCamera.enabled)
        {
            minimapCamera.enabled = true;
        }

        if (this.playerObject != null)
        {
            this.playerObject.SetActive(true);
        }

        if (this.AIPlayer != null)
        {
            //AI attribute manager.
            AIAttributeManager attributeManager = this.AIPlayer.GetComponentInChildren <AIAttributeManager>();
            if (attributeManager != null)
            {
                Debug.Log("It works!");
            }

            //AI Unit spawning.
            GameObject obj = MonoBehaviour.Instantiate(this.AIUnitPrefab) as GameObject;
            obj.transform.SetParent(this.AIUnits.transform);
            obj.transform.position = this.GetStartPosition().position;
            AIUnit unit = obj.GetComponent <AIUnit>();

            //AI manager spawning.
            AIManager AImanager = this.AIPlayer.GetComponentInChildren <AIManager>();
            if (AImanager != null)
            {
                unit.unitManager = AImanager;

                if (attributeManager != null && attributeManager.attributePanelUI != null)
                {
                    DifficultyGroup group = attributeManager.attributePanelUI.aiCalibrationDifficulty;
                    AImanager.UpdateDifficulty(group.GetDifficulty());
                }

                unit.SetTeam(AImanager.teamFaction);
                AImanager.Activate();
            }
        }

        this.playerUmbrellaObject = GameObject.FindGameObjectWithTag("Player");
        if (this.playerUmbrellaObject != null)
        {
            this.HumanPlayer = this.playerUmbrellaObject;
            Transform unitUmbrellaTransform = this.playerUmbrellaObject.transform.GetChild(0);
            this.HumanUnits = unitUmbrellaTransform.gameObject;
        }

        SetupPlayerUnits();

        if (!this.isNetworkActive)
        {
            this.StartHost();
        }

        this.enablePauseGameMenu = true;
        this.notReady            = false;

        if (Taskbar.Instance != null)
        {
            Taskbar.Instance.ShowTaskbar(true);
        }

        GameMetricLogger.SetGameLogger(GameLoggerOptions.StartGameMetrics);
        GameMetricLogger.SetGameLogger(GameLoggerOptions.GameIsPlaying);
        GameMetricLogger.EnableLoggerHotkey();
    }
Esempio n. 10
0
 public DifficultyItemData(Chart chart)
 {
     (internalDiff, isPlus) = Conversion.CcToDifficulty(chart.Constant);
     displayDiff            = chart.Difficulty;
     diffGroup = chart.DifficultyGroup;
 }
Esempio n. 11
0
 public static List <CellDataBase> Convert(List <Level> levels, DifficultyGroup diff, GameObject cellPrefab, GameObject folderPrefab)
 {
     return(currentGroupMethod.Convert(levels, cellPrefab, diff, currentSortMethod, folderPrefab));
 }