Files
ichni_Official/Assets/Scripts/UI/Prepare/PrepareUIPage.cs

76 lines
2.8 KiB
C#
Raw Normal View History

2025-06-06 10:14:55 -04:00
using System.Collections;
using System.Collections.Generic;
2025-06-14 14:42:49 -04:00
using System.Linq;
using Ichni.Menu;
using Ichni.Story;
using TMPro;
2025-06-06 10:14:55 -04:00
using UnityEngine;
using UnityEngine.UI;
namespace Ichni.UI
{
2025-06-14 14:42:49 -04:00
public partial class PrepareUIPage : UIPageBase
2025-06-06 10:14:55 -04:00
{
public Button enterGameButton;
2025-06-14 14:42:49 -04:00
public Button switchDifficultyButton;
public string songName;
public List<string> difficulties;
public string difficultyName;
private ChapterSelectionUnit chapter;
private SongItemData songItem;
private DifficultyData difficultyData;
}
public partial class PrepareUIPage
{
public void SetUpPrepareUIPage(string songName)
{
chapter = ChapterSelectionManager.instance.chapters
.FirstOrDefault(c => c.chapterIndex == ChapterSelectionManager.instance.currentChapter);
songItem = chapter.songs.FirstOrDefault(s => s.songName == songName);
this.songName = songName;
this.difficulties = new List<string>();
foreach (DifficultyData difficulty in songItem.difficultyDataList)
{
this.difficulties.Add(difficulty.difficultyName);
}
this.difficultyName = difficulties[0];
difficultyData = songItem.difficultyDataList.FirstOrDefault(d => d.difficultyName == difficultyName);
switchDifficultyButton.GetComponentInChildren<TMP_Text>().text = difficultyName + " Lv." + difficultyData.difficultyValue;
switchDifficultyButton.GetComponentInChildren<TMP_Text>().color = difficultyData.color;
}
public void SwitchDifficulty()
{
int currentIndex = difficulties.IndexOf(difficultyName);
int nextIndex = (currentIndex + 1) % difficulties.Count;
difficultyName = difficulties[nextIndex];
difficultyData = songItem.difficultyDataList
.FirstOrDefault(d => d.difficultyName == difficultyName);
switchDifficultyButton.GetComponentInChildren<TMP_Text>().text = difficultyName + " Lv." + difficultyData.difficultyValue;
switchDifficultyButton.GetComponentInChildren<TMP_Text>().color = difficultyData.color;
}
public void EnterGame()
{
InformationTransistor.instance.SetInformation(
ChapterSelectionManager.instance.currentChapter,
songItem.songName,
songItem.composer,
difficultyName,
songItem.illustratorName,
difficultyData.displayDifficultyName,
difficultyData.color, songItem.albumIllustrationCover,
chapter.chapterSwitch, songItem.songSwitch);
MenuManager.instance.TestEnterGame();
}
2025-06-06 10:14:55 -04:00
}
}