73 lines
2.6 KiB
C#
73 lines
2.6 KiB
C#
using DG.Tweening;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class RulesPanel : InfoPanel
|
|
{
|
|
[Header("Описание")]
|
|
[SerializeField] private RectTransform descriptionSign;
|
|
[SerializeField] private float descriptionOpenY, descriptionCloseY, descriptionDuration;
|
|
|
|
[Header("Картинки")]
|
|
[SerializeField] private List<RectTransform> images;
|
|
[SerializeField] private float ruleImageDuration, ruleImageOpenY, ruleImageCloseY, ruleImageDelay;
|
|
|
|
public override float closeDelay => ((images.Count * ruleImageDelay)
|
|
+ infoDuration
|
|
+ buttonDuration
|
|
+ descriptionDuration
|
|
+ (titleDuration * 2)
|
|
- (timeOffset * 4)) / closeSpeedMultiplier;
|
|
|
|
protected override Sequence GetOpenSequence(float delay)
|
|
{
|
|
Sequence seq = DOTween.Sequence();
|
|
seq.AppendInterval(delay);
|
|
seq.Append(root.DOAnchorPos(Vector2.zero, titleDuration));
|
|
seq.Append(titleSign.DOAnchorPosY(titleOpenY, titleDuration));
|
|
|
|
float t = delay + titleDuration * 2 - timeOffset;
|
|
|
|
seq.Insert(t, descriptionSign.DOAnchorPosY(descriptionOpenY, descriptionDuration));
|
|
seq.Insert(t, button.DOAnchorPosX(buttonOpenX, buttonDuration));
|
|
seq.Insert(t + buttonDuration - timeOffset, info.DOAnchorPosX(infoOpenX, infoDuration).SetEase(Ease.OutBack));
|
|
|
|
t += ruleImageDelay;
|
|
for (int i = 0; i < images.Count; i++)
|
|
{
|
|
var image = images[i];
|
|
seq.Insert(t, image.DOAnchorPosY(ruleImageOpenY, ruleImageDuration));
|
|
t += ruleImageDelay;
|
|
}
|
|
|
|
return seq;
|
|
}
|
|
|
|
protected override Sequence GetCloseSequence(Vector2 position)
|
|
{
|
|
Sequence seq = DOTween.Sequence();
|
|
float time = 0;
|
|
|
|
for (int i = images.Count - 1; i >= 0; i--)
|
|
{
|
|
var image = images[i];
|
|
seq.Insert(time, image.DOAnchorPosY(ruleImageCloseY, ruleImageDuration));
|
|
time += ruleImageDelay;
|
|
}
|
|
|
|
seq.Insert(time, info.DOAnchorPosX(infoCloseX, infoDuration));
|
|
time += infoDuration - timeOffset;
|
|
|
|
seq.Insert(time, button.DOAnchorPosX(buttonCloseX, buttonDuration));
|
|
time += buttonDuration - timeOffset;
|
|
|
|
seq.Insert(time, descriptionSign.DOAnchorPosY(descriptionCloseY, descriptionDuration));
|
|
time += descriptionDuration - timeOffset;
|
|
|
|
seq.Insert(time, titleSign.DOAnchorPosY(titleCloseY, titleDuration));
|
|
seq.Append(root.DOAnchorPos(position, titleDuration * 4));
|
|
|
|
seq.timeScale = closeSpeedMultiplier;
|
|
return seq;
|
|
}
|
|
} |