79 lines
3.1 KiB
C#
79 lines
3.1 KiB
C#
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(() =>
|
|
{
|
|
MenuManager.instance.prepareUIPage.SetUpPrepareUIPage(songName);
|
|
MenuManager.instance.prepareUIPage.FadeIn();
|
|
});
|
|
|
|
SetUpBeatmapStatusMarks();
|
|
}
|
|
|
|
public override StoryBlockSave GetBlockSave()
|
|
{
|
|
return new SongBlockSave(blockName, blockPosition, state);
|
|
}
|
|
|
|
public void SetUpBeatmapStatusMarks()
|
|
{
|
|
SongStatusSave songStatusSave = GameSaveManager.instance.SongSaveModule.songStatusSaves[songName];
|
|
|
|
string chapter = ChapterSelectionManager.instance.currentChapter;
|
|
ChapterSelectionUnit cpt = ChapterSelectionManager.instance.chapters.First(c => c.chapterIndex == chapter);
|
|
SongItemData song = cpt.songs.First(s => s.songName == this.songName);
|
|
foreach (DifficultyData difficulty in song.difficultyDataList)
|
|
{
|
|
foreach (KeyValuePair<string, BeatmapSave> beatmapSave in songStatusSave.beatmapSaves)
|
|
{
|
|
if (beatmapSave.Key == difficulty.difficultyName)
|
|
{
|
|
if (beatmapSave.Value.isAllPerfect)
|
|
{
|
|
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.Value.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;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |