2022-07-14 16:19:51 +03:00
|
|
|
using System.Collections;
|
2022-03-12 18:06:55 +01:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class PatchNotesMenu : BaseMenu
|
|
|
|
|
{
|
2022-11-21 18:08:37 +02:00
|
|
|
[SerializeField] private InputManager _inputManager = default;
|
|
|
|
|
[SerializeField] private BaseMenu[] _menues = default;
|
|
|
|
|
[SerializeField] private PromptsInput[] _prompts = default;
|
|
|
|
|
[SerializeField] private RectTransform _scrollView = default;
|
|
|
|
|
[SerializeField] private RectTransform _patchNotes = default;
|
|
|
|
|
private readonly int _scrollSpeed = 350;
|
|
|
|
|
private int _previousMenuIndex = 0;
|
|
|
|
|
private float bottomScrollLimit = 0.0f;
|
2022-03-12 18:06:55 +01:00
|
|
|
|
2022-11-21 18:08:37 +02:00
|
|
|
public void Back()
|
|
|
|
|
{
|
|
|
|
|
_inputManager.CurrentPrompts = _prompts[_previousMenuIndex];
|
|
|
|
|
OpenMenuHideCurrent(_menues[_previousMenuIndex]);
|
|
|
|
|
}
|
2022-03-12 18:06:55 +01:00
|
|
|
|
2022-11-21 18:08:37 +02:00
|
|
|
public void SetPreviousMenuIndex(int index)
|
|
|
|
|
{
|
|
|
|
|
_previousMenuIndex = index;
|
|
|
|
|
}
|
2022-04-19 14:06:41 +02:00
|
|
|
|
2022-11-21 18:08:37 +02:00
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
Scroll();
|
|
|
|
|
}
|
2022-04-19 14:06:41 +02:00
|
|
|
|
2022-11-21 18:08:37 +02:00
|
|
|
private void Scroll()
|
|
|
|
|
{
|
|
|
|
|
float movement = (_inputManager.NavigationInput.y * Time.deltaTime * _scrollSpeed) * -1;
|
|
|
|
|
if (movement < 0 && _scrollView.anchoredPosition.y > 0 || movement > 0 && _scrollView.anchoredPosition.y <= bottomScrollLimit)
|
|
|
|
|
{
|
|
|
|
|
_scrollView.anchoredPosition += new Vector2(0.0f, movement);
|
|
|
|
|
if (_scrollView.anchoredPosition.y < 0.0f)
|
|
|
|
|
{
|
|
|
|
|
_scrollView.anchoredPosition = new Vector2(0.0f, 0.0f);
|
|
|
|
|
}
|
|
|
|
|
else if (_scrollView.anchoredPosition.y > bottomScrollLimit)
|
|
|
|
|
{
|
|
|
|
|
_scrollView.anchoredPosition = new Vector2(0.0f, bottomScrollLimit);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-19 14:29:23 +02:00
|
|
|
|
2022-11-21 18:08:37 +02:00
|
|
|
void OnEnable()
|
|
|
|
|
{
|
|
|
|
|
_scrollView.anchoredPosition = Vector2.zero;
|
|
|
|
|
}
|
2022-07-14 16:19:51 +03:00
|
|
|
|
2022-11-21 18:08:37 +02:00
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
StartCoroutine(SetUpPatchNotesCoroutine());
|
|
|
|
|
}
|
2022-07-14 16:19:51 +03:00
|
|
|
|
2022-11-21 18:08:37 +02:00
|
|
|
IEnumerator SetUpPatchNotesCoroutine()
|
|
|
|
|
{
|
|
|
|
|
yield return null;
|
|
|
|
|
_patchNotes.anchoredPosition = new Vector2(0.0f, -(_patchNotes.rect.height / 2.0f));
|
|
|
|
|
bottomScrollLimit = _patchNotes.rect.height - 300.0f;
|
|
|
|
|
_scrollView.anchoredPosition = Vector2.zero;
|
|
|
|
|
}
|
2022-03-12 18:06:55 +01:00
|
|
|
}
|