73 lines
2.7 KiB
C#
73 lines
2.7 KiB
C#
using DG.Tweening;
|
|
using Spine.Unity;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class MiniBattlePassSecondPanel : MiniBattlePassPanel
|
|
{
|
|
//TMP_Text text_num;
|
|
TMP_Text text_num1;
|
|
Transform spineRoot;
|
|
SkeletonGraphic spine;
|
|
RewardItemNew reward;
|
|
protected override MiniBattlePassType Type => MiniBattlePassType.Dive;
|
|
|
|
protected override int showCount => 5;
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
reward = transform.Find("root/total_prize/bg/reward").GetComponent<RewardItemNew>();
|
|
spineRoot = transform.Find("root/ScrollView/Viewport/Content/spineRoot");
|
|
spine = transform.Find("root/ScrollView/Viewport/Content/spineRoot/spine").GetComponent<SkeletonGraphic>();
|
|
|
|
//text_num = transform.Find("root/total_prize/bg/reward/text_num").GetComponent<TMP_Text>();
|
|
text_num1 = transform.Find("root/total_prize/reward/text_num").GetComponent<TMP_Text>();
|
|
}
|
|
protected override void Start()
|
|
{
|
|
reward.SetData(miniBP.ItemShow[0], $"x{ConvertTools.GetNumberString(miniBP.ItemCountShow[0])}", true);
|
|
//text_num.text = $"x{miniBP.ItemCountShow[0]}";
|
|
text_num1.text = $"x{ConvertTools.GetNumberString(miniBP.ItemCountShow[1])}";
|
|
base.Start();
|
|
}
|
|
|
|
protected override void JumpToIndex()
|
|
{
|
|
int index = miniBP.Data.showIndex;
|
|
float startPos = ((index - 2) * 1f / (miniBPItemDatas.Count - showCount));
|
|
if (startPos > 1f) startPos = 1f;
|
|
if (startPos < 0f) startPos = 0f;
|
|
scrollRect.verticalNormalizedPosition = startPos;
|
|
int spineIndex = miniBP.Data.showIndex;
|
|
if (spineIndex < miniBPItemDatas.Count - 1)
|
|
{
|
|
spineIndex++;
|
|
}
|
|
spineRoot.localPosition = new Vector3(spineRoot.localPosition.x, spineIndex * itemHeight, 0);
|
|
if (miniBP.rewardIndex > index)
|
|
{
|
|
miniBP.SetOldLevel();
|
|
float endPos = ((miniBP.rewardIndex - 2) * 1f / (miniBPItemDatas.Count - showCount));
|
|
if (endPos > 1f) endPos = 1f;
|
|
if (endPos < 0f) endPos = 0f;
|
|
spine.AnimationState.SetAnimation(0, "swimming_move", true);
|
|
scrollRect.DOVerticalNormalizedPos(endPos, 1).SetEase(Ease.Linear);
|
|
spineIndex = miniBP.rewardIndex;
|
|
if (spineIndex < miniBPItemDatas.Count - 1)
|
|
{
|
|
spineIndex++;
|
|
}
|
|
spineRoot.DOLocalMoveY(spineIndex * itemHeight, 1).OnComplete(() =>
|
|
{
|
|
spine.AnimationState.SetAnimation(0, "swimming_idle", true);
|
|
});
|
|
}
|
|
else
|
|
{
|
|
spine.AnimationState.SetAnimation(0, "swimming_idle", true);
|
|
}
|
|
}
|
|
}
|
|
|
|
|