using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; using UnityEngine.UI; public class MonumentResultController : MonoBehaviour { private List _monuments; [SerializeField] private UIMonumentButton _UIMonumentPrefab; [SerializeField] private Transform _placeHolder; [SerializeField] private Transform _miniPlaceholder; [SerializeField] private TMPro.TextMeshProUGUI _descriptionText; [SerializeField] private TMPro.TextMeshProUGUI _score; [SerializeField] private Image _icon; private Dictionary _miniModels = new Dictionary(); private GameObject _lastMiniModel; private void Start() { _monuments = new List(); _monuments = Resources.LoadAll("Monuments/").ToList(); InitMonuments(); } private bool _showFirst = true; private void InitMonuments() { _monuments.ForEach(x => { var newUIMonument = Instantiate(_UIMonumentPrefab, _placeHolder); newUIMonument.Init(x); var newMiniModel = Instantiate(x.MiniModel, _miniPlaceholder); newMiniModel.SetActive(false); _miniModels.Add(x, newMiniModel); if (PlayerSetup.Instance.TryFindMonument(x)) { newUIMonument.Unlock(); if (_showFirst) { _showFirst = false; newUIMonument.SelectMonument(); } } else { newUIMonument.Lock(); } }); } public void SelectMonument(MonumentInfo info) { if (_lastMiniModel) _lastMiniModel.SetActive(false); _miniModels[info].SetActive(true); _lastMiniModel = _miniModels[info]; _icon.sprite = info.Image; _descriptionText.SetText(info.Description); } }