Files
ichni_Official/Assets/Scripts/Story/StoryUI/Blocks/SongBlockUI.cs

76 lines
2.9 KiB
C#
Raw Normal View History

2025-06-13 14:59:58 -04:00
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Ichni.Menu;
using Ichni.RhythmGame;
using TMPro;
using UnityEngine;
using UnityEngine.Serialization;
using UnityEngine.UI;
namespace Ichni.Story.UI
{
public class SongBlockUI : StoryBlockUIBase
{
public string songName;
public Button button;
public TMP_Text songNameText;
public RectTransform beatmapStatusMarkContainer;
public GameObject beatmapStatusMarkPrefab;
public void Initialize(string blockName, Vector2 position, Vector2 positionOffset,
Vector2 size, StoryBlockState state, string songName)
{
base.Initialize(blockName, position, positionOffset, size, state);
this.songName = songName;
songNameText.text = songName;
button.onClick.AddListener(() =>
{
2025-08-11 14:04:06 -04:00
//MenuManager.instance.prepareUIPage.SetUpPrepareUIPage(songName);
//MenuManager.instance.prepareUIPage.FadeIn();
2025-06-13 14:59:58 -04:00
});
SetUpBeatmapStatusMarks();
}
public override StoryBlockSave GetBlockSave()
{
return new SongBlockSave(blockName, blockPosition, state);
}
public void SetUpBeatmapStatusMarks()
{
SongStatusSave songStatusSave = GameSaveManager.instance.SongSaveModule.songStatusSaves[songName];
2025-07-26 04:20:25 -04:00
string chapter = ChapterSelectionManager.instance.currentChapter.chapterIndex;
2025-06-13 14:59:58 -04:00
ChapterSelectionUnit cpt = ChapterSelectionManager.instance.chapters.First(c => c.chapterIndex == chapter);
SongItemData song = cpt.songs.First(s => s.songName == this.songName);
2025-07-26 04:20:25 -04:00
for (var index = 0; index < song.difficultyDataList.Count; index++)
2025-06-13 14:59:58 -04:00
{
2025-07-26 04:20:25 -04:00
var difficulty = song.difficultyDataList[index];
var beatmapSave = songStatusSave.beatmapSaves[index];
if (beatmapSave.isAllPerfect)
2025-06-13 14:59:58 -04:00
{
2025-07-26 04:20:25 -04:00
GameObject mark = Instantiate(beatmapStatusMarkPrefab, beatmapStatusMarkContainer);
mark.GetComponent<Image>().color = difficulty.color;
mark.transform.GetChild(0).GetComponent<TMP_Text>().color = difficulty.color;
mark.transform.GetChild(0).GetComponent<TMP_Text>().text = "AP";
break;
}
if (beatmapSave.isFullCombo)
{
GameObject mark = Instantiate(beatmapStatusMarkPrefab, beatmapStatusMarkContainer);
mark.GetComponent<Image>().color = difficulty.color;
mark.transform.GetChild(0).GetComponent<TMP_Text>().color = difficulty.color;
mark.transform.GetChild(0).GetComponent<TMP_Text>().text = "FC";
break;
2025-06-13 14:59:58 -04:00
}
}
}
}
}