using System; using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; using UnityEngine.UI; public class MonumentResultController : MonoBehaviour, IPlayerInfoRequre { private List _monuments; [SerializeField] private UIMonumentButton _UIMonumentPrefab; [SerializeField] private Transform _placeHolder; [SerializeField] private TMPro.TextMeshProUGUI _descriptionText; [SerializeField] private Image _icon; [SerializeField] private TMPro.TextMeshProUGUI _score; private PlayerSetup _playerSetup; private void Start() { _monuments = new List(); _monuments = Resources.LoadAll("Monuments/").ToList(); InitPlayerInfo(); InitMonuments(); } public void InitPlayerInfo() { _playerSetup = FindObjectOfType(); } private bool _showFirst = true; private void InitMonuments() { _monuments.ForEach(x => { var newUIMonument = Instantiate(_UIMonumentPrefab, _placeHolder); newUIMonument.Init(x); if (_playerSetup.TryFindMonument(x)) { newUIMonument.Unlock(); if (_showFirst) { _showFirst = false; newUIMonument.SelectMonument(); } } }); } public void SelectMonument(MonumentInfo info) { _icon.sprite = info.Image; _score.SetText(info.Score.ToString()); _descriptionText.SetText(info.Description); } }