100 lines
3.2 KiB
C#
100 lines
3.2 KiB
C#
using DG.Tweening;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class PrizesPanel : InfoPanel
|
|
{
|
|
[Header("Картинки")]
|
|
[SerializeField] private float recordDuration;
|
|
[SerializeField] private float recordOpenY;
|
|
[SerializeField] private float recordCloseY;
|
|
[SerializeField] private float recordDelay;
|
|
|
|
[Header("Генерация")]
|
|
[SerializeField] private RectTransform table;
|
|
[SerializeField] private PrizeRecord recordPrefab;
|
|
|
|
[Header("Отладочное")]
|
|
[SerializeField] private List<Sprite> icons;
|
|
[SerializeField] private List<string> names;
|
|
[SerializeField] private List<string> prizes;
|
|
[SerializeField] private List<Sprite> prizeicons;
|
|
|
|
private List<PrizeRecord> records;
|
|
|
|
public override float closeDelay => (Mathf.Max(infoDuration, buttonDuration, titleDuration)
|
|
+ records.Count * recordDelay
|
|
+ titleDuration) / closeSpeedMultiplier;
|
|
|
|
protected override void InitializeBeforeOpen()
|
|
{
|
|
// Очистить макет
|
|
for (int i = table.childCount - 1; i >= 0; i--)
|
|
{
|
|
Destroy(table.GetChild(i).gameObject);
|
|
}
|
|
records?.Clear();
|
|
records = new List<PrizeRecord>();
|
|
|
|
// Сгенерировать призы
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
PrizeRecord record = Instantiate(recordPrefab, table);
|
|
record.Init(i + 1, icons[i], names[i], prizes[i], prizeicons[i]);
|
|
records.Add(record);
|
|
}
|
|
}
|
|
|
|
protected override Sequence GetOpenSequence(float delay)
|
|
{
|
|
Sequence seq = DOTween.Sequence();
|
|
float t = 0;
|
|
|
|
seq.AppendInterval(delay);
|
|
seq.Append(root.DOAnchorPos(Vector2.zero, titleDuration));
|
|
seq.Append(titleSign.DOAnchorPosY(titleOpenY, titleDuration));
|
|
t = delay + titleDuration * 2 - timeOffset;
|
|
|
|
seq.Insert(t, button.DOAnchorPosX(buttonOpenX, buttonDuration));
|
|
seq.Insert(t + buttonDuration - timeOffset, info.DOAnchorPosX(infoOpenX, infoDuration).SetEase(Ease.OutBack));
|
|
|
|
t += recordDelay;
|
|
for (int i = records.Count - 1; i >= 0; i--)
|
|
{
|
|
var image = records[i].movableGroup;
|
|
seq.Insert(t, image.DOAnchorPosY(recordOpenY, recordDuration));
|
|
t += recordDelay;
|
|
}
|
|
|
|
return seq;
|
|
}
|
|
|
|
protected override Sequence GetCloseSequence(Vector2 position)
|
|
{
|
|
Sequence seq = DOTween.Sequence();
|
|
|
|
seq.Join(info.DOAnchorPosX(infoCloseX, infoDuration));
|
|
seq.Join(button.DOAnchorPosX(buttonCloseX, buttonDuration));
|
|
seq.Join(titleSign.DOAnchorPosY(titleCloseY, titleDuration));
|
|
|
|
float time = 0;
|
|
if (records != null)
|
|
{
|
|
for (int i = 0; i < records.Count; i++)
|
|
{
|
|
var image = records[i].movableGroup;
|
|
seq.Insert(time, image.DOAnchorPosY(recordCloseY, recordDuration));
|
|
time += recordDelay;
|
|
}
|
|
}
|
|
|
|
seq.Append(root.DOAnchorPos(position, titleDuration * 4));
|
|
seq.timeScale = closeSpeedMultiplier;
|
|
|
|
return seq;
|
|
}
|
|
|
|
public override void Initialize()
|
|
{
|
|
}
|
|
} |