using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; public class ReplaysMenu : BaseMenu { [SerializeField] private BaseMenu _replayIncompatibleMenu = default; [SerializeField] private RectTransform _scrollView = default; [SerializeField] private RectTransform _replaysGroup = default; [SerializeField] private GameObject _replayPrefab = default; [SerializeField] private GameObject _noReplaysFound = default; private readonly List _replayCards = new(); private ReplayCard _currentReplayCard; void Start() { _replaysGroup.anchoredPosition = new Vector2(0.0f, _replaysGroup.anchoredPosition.y); if (ReplayManager.Instance.ReplayAmount > 0) { for (int i = 0; i < ReplayManager.Instance.ReplayAmount; i++) { ReplayCard replayCard = Instantiate(_replayPrefab, _replaysGroup).transform.GetChild(0).GetComponent(); replayCard.SetData(ReplayManager.Instance.GetReplayData(i)); int index = i; if (index == ReplayManager.Instance.ReplayAmount - 1 && index > 0) replayCard.Initialize(index, this, _replaysGroup, _replayCards[index - 1].GetComponent(), true); else replayCard.Initialize(index, this, _replaysGroup); _replayCards.Add(replayCard); } } else _noReplaysFound.SetActive(true); StartCoroutine(SetUpScrollViewCoroutine()); } public void LoadReplayMatch(int index) { _currentReplayCard = _replayCards[index]; if (_currentReplayCard.ReplayData.version.Trim() == ReplayManager.Instance.VersionNumber) { SceneSettings.IsOnline = false; SceneSettings.SceneSettingsDecide = true; SceneSettings.IsTrainingMode = false; SceneSettings.ReplayIndex = index; ReplayManager.Instance.SetReplay(); SceneManager.LoadScene(1); } else { _currentReplayCard.GetComponent().Rebind(); _replayIncompatibleMenu.Show(); } } public void CloseIncompatible() => _currentReplayCard.GetComponent