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