Добавить таймеры и шкалы прогресса, расширить призовую систему и контроль остатков, восстановить настройки и обновить таблицу призов главного меню.
103 lines
3.3 KiB
C#
103 lines
3.3 KiB
C#
using DG.Tweening;
|
|
using CharacterSystem;
|
|
using PrizeSystem;
|
|
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;
|
|
|
|
private readonly List<PrizeRecord> _records = new();
|
|
|
|
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();
|
|
|
|
Character[] characters = CharactersController.GetCharactersArray();
|
|
List<PrizeSet> prizeSets = PrizeSystemManager.PrizeContainer?.Sets;
|
|
|
|
for (int i = 0; i < characters.Length; i++)
|
|
{
|
|
PrizeRecord record = Instantiate(recordPrefab, table);
|
|
IReadOnlyList<Prize> characterPrizes = i < (prizeSets?.Count ?? 0)
|
|
? prizeSets[i]?.Prizes
|
|
: null;
|
|
|
|
record.Init(
|
|
i + 1,
|
|
characters[i].visualModule.iconSmall,
|
|
characters[i].characterName,
|
|
characterPrizes);
|
|
_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;
|
|
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()
|
|
{
|
|
}
|
|
}
|