Menu基本完成
This commit is contained in:
@@ -32,7 +32,9 @@ namespace Ichni
|
||||
ThemeBundleManager.instance.LoadThemeBundles(new List<string>(){"departure_to_multiverse"});
|
||||
Observable.EveryUpdate().Where(_ => ThemeBundleManager.instance.waitingBundleAmount.Value == 0).First().Subscribe(_ =>
|
||||
{
|
||||
Load("Chapter1", "Chaos Zone", "Hard");
|
||||
Load(InformationTransistor.instance.chapterName,
|
||||
InformationTransistor.instance.songName,
|
||||
InformationTransistor.instance.difficultyName);
|
||||
});
|
||||
|
||||
Observable.EveryUpdate()
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Ichni
|
||||
|
||||
public ChapterSelectionUIPage chapterSelectionUIPage;
|
||||
public List<ChapterSelectionUnit> chapters;
|
||||
|
||||
public string currentChapter;
|
||||
}
|
||||
|
||||
public partial class ChapterSelectionManager
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using AK.Wwise;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
namespace Ichni.Menu
|
||||
{
|
||||
@@ -28,13 +29,13 @@ namespace Ichni.Menu
|
||||
{
|
||||
if(song.difficultyDataList.All(d => d.difficultyName != "Easy"))
|
||||
{
|
||||
song.difficultyDataList.Add(new DifficultyData("Easy","", "",
|
||||
song.difficultyDataList.Add(new DifficultyData("Easy","", 0, "",
|
||||
new Color(0f, 0.7f, 0.2f, 1f)));
|
||||
}
|
||||
|
||||
if (song.difficultyDataList.All(d => d.difficultyName != "Hard"))
|
||||
{
|
||||
song.difficultyDataList.Add(new DifficultyData("Hard", "", "",
|
||||
song.difficultyDataList.Add(new DifficultyData("Hard", "", 0, "",
|
||||
new Color(1f, 0.2f, 0.2f, 1f)));
|
||||
}
|
||||
}
|
||||
@@ -52,8 +53,8 @@ namespace Ichni.Menu
|
||||
[FoldoutGroup("$songName")]
|
||||
public string displaySongName;
|
||||
|
||||
[FoldoutGroup("$songName")]
|
||||
public string author;
|
||||
[FormerlySerializedAs("author")] [FoldoutGroup("$songName")]
|
||||
public string composer;
|
||||
|
||||
[FoldoutGroup("$songName")]
|
||||
public bool isNewSong;
|
||||
@@ -82,15 +83,16 @@ namespace Ichni.Menu
|
||||
{
|
||||
public string difficultyName;
|
||||
public string displayDifficultyName;
|
||||
|
||||
public int difficultyValue;
|
||||
public string designerName;
|
||||
public Color color;
|
||||
|
||||
public DifficultyData(string difficultyName, string displayDifficultyName, string designerName, Color color)
|
||||
public DifficultyData(string difficultyName, string displayDifficultyName, int difficultyValue, string designerName, Color color)
|
||||
{
|
||||
this.difficultyName = difficultyName;
|
||||
this.displayDifficultyName = displayDifficultyName;
|
||||
this.designerName = designerName;
|
||||
this.difficultyValue = difficultyValue;
|
||||
this.color = color;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,18 +25,18 @@ namespace Ichni
|
||||
public Switch chapterSwitch;
|
||||
public Switch musicSwitch;
|
||||
|
||||
private void Start()
|
||||
private void Awake()
|
||||
{
|
||||
if (instance!=null && instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
else
|
||||
if (instance == null)
|
||||
{
|
||||
instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
isReturnedFromGame = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetInformation(string chapterName, string songName, string composerName,
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using AK.Wwise;
|
||||
using Ichni.Story.UI;
|
||||
using Ichni.UI;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
@@ -14,7 +15,12 @@ namespace Ichni
|
||||
{
|
||||
public static MenuManager instance;
|
||||
|
||||
[FormerlySerializedAs("preparePage")] public PrepareUIPage prepareUIPage;
|
||||
public StartUIPage startUIPage;
|
||||
public ChapterSelectionUIPage chapterSelectionUIPage;
|
||||
public StoryUIPage storyUIPage;
|
||||
public DialogUIPage dialogUIPage;
|
||||
public SongSelectionUIPage songSelectionUIPage;
|
||||
public PrepareUIPage prepareUIPage;
|
||||
}
|
||||
|
||||
public partial class MenuManager
|
||||
@@ -36,21 +42,8 @@ namespace Ichni
|
||||
|
||||
public partial class MenuManager
|
||||
{
|
||||
public Sprite testSprite;
|
||||
public Switch testChapterSwitch;
|
||||
public Switch testMusicSwitch;
|
||||
|
||||
public void TestEnterGame()
|
||||
{
|
||||
InformationTransistor.instance.SetInformation(
|
||||
"Chapter 1",
|
||||
"Chaos Zone",
|
||||
"s/a_荒しそら & LaRin",
|
||||
"Hard",
|
||||
"None",
|
||||
"Trader",
|
||||
Color.red, testSprite,testChapterSwitch, testMusicSwitch);
|
||||
|
||||
asyncOperation.allowSceneActivation = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame;
|
||||
using Ichni.UI;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -10,6 +11,8 @@ namespace Ichni.Menu
|
||||
public partial class SongSelectionManager : SerializedMonoBehaviour
|
||||
{
|
||||
public static SongSelectionManager instance;
|
||||
|
||||
public SongSelectionUIPage songSelectionUIPage;
|
||||
|
||||
|
||||
private void Awake()
|
||||
|
||||
8
Assets/Scripts/Saving.meta
Normal file
8
Assets/Scripts/Saving.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81811d9d9c15b884592f7264eb06fad2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -41,7 +41,7 @@ namespace Ichni.Story
|
||||
|
||||
public void SetDialog(string dialogName)
|
||||
{
|
||||
string chapter = StoryManager.instance.currentChapter;
|
||||
string chapter = ChapterSelectionManager.instance.currentChapter;
|
||||
TextAsset dialog = Resources.Load<TextAsset>("Story/" + chapter + "/Dialogs/" + dialogName);
|
||||
SetDialog(new List<TextAsset> { dialog });
|
||||
}
|
||||
|
||||
@@ -14,8 +14,7 @@ namespace Ichni.Story
|
||||
|
||||
[FormerlySerializedAs("storylineDisplay")] public Storyline storyline;
|
||||
public StoryUIPage storyUIPage;
|
||||
|
||||
public string currentChapter;
|
||||
|
||||
public Dictionary<string, StoryData> storyDatas;
|
||||
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace Ichni.Story.UI
|
||||
|
||||
button.onClick.AddListener(() =>
|
||||
{
|
||||
MenuManager.instance.prepareUIPage.SetUpPrepareUIPage(songName);
|
||||
MenuManager.instance.prepareUIPage.FadeIn();
|
||||
});
|
||||
|
||||
@@ -44,7 +45,7 @@ namespace Ichni.Story.UI
|
||||
{
|
||||
SongStatusSave songStatusSave = GameSaveManager.instance.SongSaveModule.songStatusSaves[songName];
|
||||
|
||||
string chapter = StoryManager.instance.currentChapter;
|
||||
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)
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Ichni.Story.UI
|
||||
int cIndex = index; // Capture the current index for the listener
|
||||
|
||||
GameObject choiceButton = Instantiate(choiceButtonPrefab, container);
|
||||
choiceButton.GetComponentInChildren<Localize>().SetTerm(StoryManager.instance.currentChapter + "/" + choice.choiceText);
|
||||
choiceButton.GetComponentInChildren<Localize>().SetTerm(ChapterSelectionManager.instance.currentChapter + "/" + choice.choiceText);
|
||||
choiceButton.GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
DialogManager.instance.PlayNextDialogParagraph(choice.nextDialogName);
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace Ichni.Story
|
||||
{
|
||||
DialogTextUI dialogTextUI = Instantiate(textPrefab, dialogContentContainer).GetComponent<DialogTextUI>();
|
||||
dialogTextUI.speakerNameText.SetTerm("Characters/" + speakerName);
|
||||
dialogTextUI.contentText.SetTerm(StoryManager.instance.currentChapter +"/" +content);
|
||||
dialogTextUI.contentText.SetTerm(ChapterSelectionManager.instance.currentChapter +"/" +content);
|
||||
dialogTexts.Add(dialogTextUI);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.UI
|
||||
namespace Ichni.Story.UI
|
||||
{
|
||||
public class StoryUIPage : UIPageBase
|
||||
{
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Ichni.Story.UI
|
||||
//TutorialBlockUI t0 = GenerateTutorialBlock(new Vector2(200, -400), "ZakoCurse 0");
|
||||
//TextBlockUI b1 = GenerateTextBlock("Departure_P1_A", new Vector2(1000, -400), StoryBlockState.Current);
|
||||
|
||||
SetUpStoryline(StoryManager.instance.currentChapter);
|
||||
SetUpStoryline(ChapterSelectionManager.instance.currentChapter);
|
||||
|
||||
/*GenerateTextBlock("Departure_P1_A", new Vector2(1000, -400), StoryBlockState.Current);
|
||||
GenerateTextBlock("Departure_P2_A", new Vector2(1500, -400), StoryBlockState.Current);
|
||||
@@ -60,7 +60,7 @@ namespace Ichni.Story.UI
|
||||
public TutorialBlockUI GenerateTutorialBlock(string blockName, Vector2 position, StoryBlockState state)
|
||||
{
|
||||
TutorialBlockUI block = Instantiate(tutorialBlockPrefab, content).GetComponent<TutorialBlockUI>();
|
||||
StoryData storyData = StoryManager.instance.storyDatas[StoryManager.instance.currentChapter];
|
||||
StoryData storyData = StoryManager.instance.storyDatas[ChapterSelectionManager.instance.currentChapter];
|
||||
TutorialBlockData blockData = storyData.tutorialBlockDatas.FirstOrDefault(data => data.blockName == blockName);
|
||||
|
||||
if (blockData == null) throw new KeyNotFoundException("There is no block with name " + blockName);
|
||||
@@ -76,7 +76,7 @@ namespace Ichni.Story.UI
|
||||
public DialogBlockUI GenerateDialogBlock(string blockName, Vector2 position, StoryBlockState state)
|
||||
{
|
||||
DialogBlockUI block = Instantiate(dialogBlockPrefab, content).GetComponent<DialogBlockUI>();
|
||||
StoryData storyData = StoryManager.instance.storyDatas[StoryManager.instance.currentChapter];
|
||||
StoryData storyData = StoryManager.instance.storyDatas[ChapterSelectionManager.instance.currentChapter];
|
||||
DialogBlockData blockData = storyData.dialogBlockDatas.FirstOrDefault(data => data.blockName == blockName);
|
||||
|
||||
if (blockData == null) throw new KeyNotFoundException("There is no block with name " + blockName);
|
||||
@@ -92,7 +92,7 @@ namespace Ichni.Story.UI
|
||||
public SongBlockUI GenerateSongBlock(string blockName, Vector2 position, StoryBlockState state)
|
||||
{
|
||||
SongBlockUI block = Instantiate(musicBlockPrefab, content).GetComponent<SongBlockUI>();
|
||||
StoryData storyData = StoryManager.instance.storyDatas[StoryManager.instance.currentChapter];
|
||||
StoryData storyData = StoryManager.instance.storyDatas[ChapterSelectionManager.instance.currentChapter];
|
||||
SongBlockData blockData = storyData.songBlockDatas.FirstOrDefault(data => data.blockName == blockName);
|
||||
|
||||
if (blockData == null) throw new KeyNotFoundException("There is no block with name " + blockName);
|
||||
@@ -243,7 +243,7 @@ namespace Ichni.Story.UI
|
||||
{
|
||||
ClearStoryline();
|
||||
|
||||
StoryData storyData = StoryManager.instance.storyDatas[StoryManager.instance.currentChapter];
|
||||
StoryData storyData = StoryManager.instance.storyDatas[ChapterSelectionManager.instance.currentChapter];
|
||||
List<InitialBlockData> initialBlocks = storyData.initialBlocks;
|
||||
|
||||
foreach (InitialBlockData blockData in initialBlocks)
|
||||
@@ -273,7 +273,7 @@ namespace Ichni.Story.UI
|
||||
}
|
||||
|
||||
SetUpBackground();
|
||||
SaveStoryline(StoryManager.instance.currentChapter);
|
||||
SaveStoryline(ChapterSelectionManager.instance.currentChapter);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ using Ichni.Story;
|
||||
using Sirenix.OdinInspector;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.UI
|
||||
@@ -15,8 +16,11 @@ namespace Ichni.UI
|
||||
{
|
||||
public RectTransform content;
|
||||
public LayoutElement layoutElement;
|
||||
public Button button;
|
||||
|
||||
[FormerlySerializedAs("button")] public Button expandButton;
|
||||
public Button enterStorylineButton;
|
||||
public Button enterSongSelectionButton;
|
||||
|
||||
public string chapterName;
|
||||
public bool isExpanded;
|
||||
public bool isDuringAnimation;
|
||||
|
||||
@@ -40,7 +44,12 @@ namespace Ichni.UI
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
button.onClick.AddListener(() =>
|
||||
|
||||
}
|
||||
|
||||
public void Initialize(ChapterSelectionUnit chapter)
|
||||
{
|
||||
expandButton.onClick.AddListener(() =>
|
||||
{
|
||||
if (isDuringAnimation)
|
||||
{
|
||||
@@ -49,21 +58,38 @@ namespace Ichni.UI
|
||||
|
||||
if (isExpanded)
|
||||
{
|
||||
Collapse();
|
||||
Shrink();
|
||||
}
|
||||
else
|
||||
{
|
||||
Expand();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void Initialize(ChapterSelectionUnit chapter)
|
||||
{
|
||||
|
||||
enterStorylineButton.onClick.AddListener(() =>
|
||||
{
|
||||
if (isDuringAnimation)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ChapterSelectionManager.instance.chapterSelectionUIPage.FadeOut();
|
||||
StoryManager.instance.storyUIPage.FadeIn();
|
||||
});
|
||||
|
||||
enterSongSelectionButton.onClick.AddListener(() =>
|
||||
{
|
||||
if (isDuringAnimation)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ChapterSelectionManager.instance.chapterSelectionUIPage.FadeOut();
|
||||
SongSelectionManager.instance.songSelectionUIPage.FadeIn();
|
||||
});
|
||||
}
|
||||
|
||||
public void Expand()
|
||||
private void Expand()
|
||||
{
|
||||
isExpanded = true;
|
||||
|
||||
@@ -98,42 +124,43 @@ namespace Ichni.UI
|
||||
expandSequence.Play();
|
||||
}
|
||||
|
||||
public void Collapse()
|
||||
private void Shrink()
|
||||
{
|
||||
isExpanded = false;
|
||||
|
||||
Sequence collapseSequence = DOTween.Sequence();
|
||||
Sequence shrinkSequence = DOTween.Sequence();
|
||||
|
||||
collapseSequence.Append(bottomTip.DOFade(0f, 0.4f));
|
||||
collapseSequence.Join(upperTip.DOFade(0f, 0.4f));
|
||||
shrinkSequence.Append(bottomTip.DOFade(0f, 0.4f));
|
||||
shrinkSequence.Join(upperTip.DOFade(0f, 0.4f));
|
||||
|
||||
collapseSequence.Append(expansionInfos.GetComponent<CanvasGroup>().DOFade(0, 0.4f)
|
||||
shrinkSequence.Append(expansionInfos.GetComponent<CanvasGroup>().DOFade(0, 0.4f)
|
||||
.OnComplete(()=>
|
||||
{
|
||||
expansionInfos.gameObject.SetActive(false);
|
||||
}));
|
||||
collapseSequence.Join(expansionFunctions.GetComponent<CanvasGroup>().DOFade(0, 0.4f)
|
||||
shrinkSequence.Join(expansionFunctions.GetComponent<CanvasGroup>().DOFade(0, 0.4f)
|
||||
.OnComplete(() =>
|
||||
{
|
||||
expansionFunctions.gameObject.SetActive(false);
|
||||
}));
|
||||
|
||||
collapseSequence.Append(titleRect.DOSizeDelta(new Vector2(322, 100), 0.4f));
|
||||
shrinkSequence.Append(titleRect.DOSizeDelta(new Vector2(322, 100), 0.4f).SetEase(Ease.InQuad));
|
||||
|
||||
collapseSequence.Append(expansionBackground.DOSizeDelta(new Vector2(322, 826), 0.4f)
|
||||
shrinkSequence.Append(expansionBackground.DOSizeDelta(new Vector2(322, 826), 0.4f)
|
||||
.SetEase(Ease.InQuad)
|
||||
.OnComplete(() =>
|
||||
{
|
||||
expansionBackground.gameObject.SetActive(false);
|
||||
}));
|
||||
|
||||
collapseSequence.Join(DOTween.To(() => layoutElement.preferredWidth,
|
||||
x => layoutElement.preferredWidth = x, 322, 0.4f));
|
||||
collapseSequence.Join(avatarMask.rectTransform.DOSizeDelta(new Vector2(322, 826), 0.4f));
|
||||
shrinkSequence.Join(DOTween.To(() => layoutElement.preferredWidth,
|
||||
x => layoutElement.preferredWidth = x, 322, 0.4f).SetEase(Ease.InQuad));
|
||||
shrinkSequence.Join(avatarMask.rectTransform.DOSizeDelta(new Vector2(322, 826), 0.4f).SetEase(Ease.InQuad));
|
||||
|
||||
collapseSequence.OnStart(() => isDuringAnimation = true);
|
||||
collapseSequence.OnComplete(() => isDuringAnimation = false);
|
||||
shrinkSequence.OnStart(() => isDuringAnimation = true);
|
||||
shrinkSequence.OnComplete(() => isDuringAnimation = false);
|
||||
|
||||
collapseSequence.Play();
|
||||
shrinkSequence.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ namespace Ichni.UI
|
||||
{
|
||||
ChapterSelectionUI item = Instantiate(chapterSelectionUIPrefab, chapterContainer).GetComponent<ChapterSelectionUI>();
|
||||
item.Initialize(chapter);
|
||||
item.chapterName = chapter.chapterName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,76 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Ichni.Menu;
|
||||
using Ichni.Story;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.UI
|
||||
{
|
||||
public class PrepareUIPage : UIPageBase
|
||||
public partial class PrepareUIPage : UIPageBase
|
||||
{
|
||||
public Button enterGameButton;
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
35
Assets/Scripts/UI/SongSelection/SongSelectionTabUI.cs
Normal file
35
Assets/Scripts/UI/SongSelection/SongSelectionTabUI.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Menu.UI
|
||||
{
|
||||
public class SongSelectionTabUI : MonoBehaviour
|
||||
{
|
||||
public SongItemData connectedSong;
|
||||
public TMP_Text songNameText;
|
||||
public Button switchDifficultyButton;
|
||||
public string currentDifficultyName;
|
||||
|
||||
public void SetUpTab(SongItemData song)
|
||||
{
|
||||
connectedSong = song;
|
||||
songNameText.text = song.songName;
|
||||
currentDifficultyName = song.difficultyDataList[0].difficultyName;
|
||||
switchDifficultyButton.GetComponentInChildren<TMP_Text>().text = currentDifficultyName + " Lv." + song.difficultyDataList[0].difficultyValue;
|
||||
switchDifficultyButton.GetComponentInChildren<TMP_Text>().color = song.difficultyDataList[0].color;
|
||||
|
||||
switchDifficultyButton.onClick.AddListener(() =>
|
||||
{
|
||||
int currentIndex = song.difficultyDataList.FindIndex(d => d.difficultyName == currentDifficultyName);
|
||||
int nextIndex = (currentIndex + 1) % song.difficultyDataList.Count;
|
||||
currentDifficultyName = song.difficultyDataList[nextIndex].difficultyName;
|
||||
|
||||
switchDifficultyButton.GetComponentInChildren<TMP_Text>().text = currentDifficultyName + " Lv." + song.difficultyDataList[nextIndex].difficultyValue;
|
||||
switchDifficultyButton.GetComponentInChildren<TMP_Text>().color = song.difficultyDataList[nextIndex].color;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/SongSelection/SongSelectionTabUI.cs.meta
Normal file
11
Assets/Scripts/UI/SongSelection/SongSelectionTabUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e65fe538f854fc041a6bc0065c5959b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,11 +1,42 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.Menu;
|
||||
using Ichni.Menu.UI;
|
||||
using Ichni.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.UI
|
||||
{
|
||||
public class SongSelectionUIPage : UIPageBase
|
||||
{
|
||||
public GameObject songSelectionTabPrefab;
|
||||
public RectTransform songSelectionTabContainer;
|
||||
public List<SongSelectionTabUI> songSelectionTabs;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GenerateSongTabs();
|
||||
}
|
||||
|
||||
public void GenerateSongTabs()
|
||||
{
|
||||
string chapter = ChapterSelectionManager.instance.currentChapter;
|
||||
ChapterSelectionUnit chapterUnit = ChapterSelectionManager.instance.chapters.Find(c => c.chapterIndex == chapter);
|
||||
foreach (SongItemData song in chapterUnit.songs)
|
||||
{
|
||||
SongSelectionTabUI tab = Instantiate(songSelectionTabPrefab, songSelectionTabContainer).GetComponent<SongSelectionTabUI>();
|
||||
tab.SetUpTab(song);
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearTabs()
|
||||
{
|
||||
foreach (SongSelectionTabUI tab in songSelectionTabs)
|
||||
{
|
||||
Destroy(tab.gameObject);
|
||||
}
|
||||
songSelectionTabs.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user