2025-06-09 04:52:14 -04:00
|
|
|
using System;
|
2025-06-06 10:14:55 -04:00
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
2025-06-09 04:52:14 -04:00
|
|
|
using DG.Tweening;
|
2025-06-06 10:14:55 -04:00
|
|
|
using Ichni.Menu;
|
|
|
|
|
using Ichni.Story;
|
2025-06-09 04:52:14 -04:00
|
|
|
using Sirenix.OdinInspector;
|
2025-06-06 10:14:55 -04:00
|
|
|
using TMPro;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
namespace Ichni.UI
|
|
|
|
|
{
|
|
|
|
|
public class ChapterSelectionUI : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public RectTransform content;
|
2025-06-09 04:52:14 -04:00
|
|
|
public LayoutElement layoutElement;
|
|
|
|
|
public Button button;
|
|
|
|
|
|
|
|
|
|
public bool isExpanded;
|
|
|
|
|
public bool isDuringAnimation;
|
|
|
|
|
|
|
|
|
|
[Title("闭合内容")]
|
|
|
|
|
public Image bottomTip;
|
|
|
|
|
public Image upperTip;
|
|
|
|
|
public Image leftProgressBarBase;
|
|
|
|
|
public Image leftProgressBarFill;
|
2025-06-06 10:14:55 -04:00
|
|
|
public Image avatar;
|
2025-06-09 04:52:14 -04:00
|
|
|
public Image avatarMask;
|
|
|
|
|
public TMP_Text decorationChapterText0;
|
|
|
|
|
public TMP_Text decorationChapterText1;
|
|
|
|
|
public TMP_Text progressText;
|
|
|
|
|
public RectTransform titleRect;
|
|
|
|
|
public TMP_Text titleText;
|
|
|
|
|
|
|
|
|
|
[Title("展开内容")]
|
|
|
|
|
public RectTransform expansionBackground;
|
|
|
|
|
public RectTransform expansionFunctions;
|
|
|
|
|
public RectTransform expansionInfos;
|
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
button.onClick.AddListener(() =>
|
|
|
|
|
{
|
|
|
|
|
if (isDuringAnimation)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isExpanded)
|
|
|
|
|
{
|
|
|
|
|
Collapse();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Expand();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-06-06 10:14:55 -04:00
|
|
|
|
|
|
|
|
public void Initialize(ChapterSelectionUnit chapter)
|
|
|
|
|
{
|
2025-06-09 04:52:14 -04:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Expand()
|
|
|
|
|
{
|
|
|
|
|
isExpanded = true;
|
|
|
|
|
|
|
|
|
|
Sequence expandSequence = DOTween.Sequence();
|
|
|
|
|
|
|
|
|
|
expandSequence.Append(expansionBackground.DOSizeDelta(new Vector2(1147, 826), 0.4f)
|
|
|
|
|
.OnStart(() =>
|
|
|
|
|
{
|
|
|
|
|
expansionBackground.gameObject.SetActive(true);
|
|
|
|
|
}));
|
|
|
|
|
expandSequence.Join(DOTween.To(() => layoutElement.preferredWidth,
|
|
|
|
|
x => layoutElement.preferredWidth = x, 1147, 0.4f));
|
|
|
|
|
expandSequence.Join(avatarMask.rectTransform.DOSizeDelta(new Vector2(1147, 826), 0.4f));
|
|
|
|
|
expandSequence.Append(titleRect.DOSizeDelta(new Vector2(0, 100), 0.4f));
|
|
|
|
|
expandSequence.Append(expansionInfos.GetComponent<CanvasGroup>().DOFade(1, 0.4f)
|
|
|
|
|
.OnStart(()=>
|
|
|
|
|
{
|
|
|
|
|
expansionInfos.gameObject.SetActive(true);
|
|
|
|
|
}));
|
|
|
|
|
expandSequence.Join(expansionFunctions.GetComponent<CanvasGroup>().DOFade(1, 0.4f)
|
|
|
|
|
.OnStart(() =>
|
|
|
|
|
{
|
|
|
|
|
expansionFunctions.gameObject.SetActive(true);
|
|
|
|
|
}));
|
2025-06-06 10:14:55 -04:00
|
|
|
|
2025-06-09 04:52:14 -04:00
|
|
|
expandSequence.Append(bottomTip.DOFade(1f, 0.4f));
|
|
|
|
|
expandSequence.Join(upperTip.DOFade(1f, 0.4f));
|
2025-06-06 10:14:55 -04:00
|
|
|
|
2025-06-09 04:52:14 -04:00
|
|
|
expandSequence.OnStart(() => isDuringAnimation = true);
|
|
|
|
|
expandSequence.OnComplete(() => isDuringAnimation = false);
|
|
|
|
|
|
|
|
|
|
expandSequence.Play();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Collapse()
|
|
|
|
|
{
|
|
|
|
|
isExpanded = false;
|
|
|
|
|
|
|
|
|
|
Sequence collapseSequence = DOTween.Sequence();
|
|
|
|
|
|
|
|
|
|
collapseSequence.Append(bottomTip.DOFade(0f, 0.4f));
|
|
|
|
|
collapseSequence.Join(upperTip.DOFade(0f, 0.4f));
|
|
|
|
|
|
|
|
|
|
collapseSequence.Append(expansionInfos.GetComponent<CanvasGroup>().DOFade(0, 0.4f)
|
|
|
|
|
.OnComplete(()=>
|
|
|
|
|
{
|
|
|
|
|
expansionInfos.gameObject.SetActive(false);
|
|
|
|
|
}));
|
|
|
|
|
collapseSequence.Join(expansionFunctions.GetComponent<CanvasGroup>().DOFade(0, 0.4f)
|
|
|
|
|
.OnComplete(() =>
|
|
|
|
|
{
|
|
|
|
|
expansionFunctions.gameObject.SetActive(false);
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
collapseSequence.Append(titleRect.DOSizeDelta(new Vector2(322, 100), 0.4f));
|
|
|
|
|
|
|
|
|
|
collapseSequence.Append(expansionBackground.DOSizeDelta(new Vector2(322, 826), 0.4f)
|
|
|
|
|
.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));
|
|
|
|
|
|
|
|
|
|
collapseSequence.OnStart(() => isDuringAnimation = true);
|
|
|
|
|
collapseSequence.OnComplete(() => isDuringAnimation = false);
|
|
|
|
|
|
|
|
|
|
collapseSequence.Play();
|
2025-06-06 10:14:55 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|