Menu基本完成
This commit is contained in:
@@ -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