using Michsky.UI.Heat; using Obvious.Soap; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; public class UI_LoadSlotButton : MonoBehaviour { public UnityEvent OnLoadProfile; public PlayerProfile PlayerProfile; private string _ProfileName; [SerializeField] private TextMeshProUGUI _NameText; [SerializeField] private TextMeshProUGUI _DescriptionText; [SerializeField] private ButtonManager _LoadButton; [SerializeField] private Button _DeleteButton; [SerializeField] private ScriptableEventString On_LoadSlot_LoadClicked; [SerializeField] private ScriptableEventString On_LoadSlot_RemoveClicked; public void Initialize(string profileName) { _ProfileName = profileName; _NameText.text = _ProfileName; string text = PlayerProfile.GetMoneyFromProfile(profileName).ToString("F2"); _DescriptionText.text = "1 lvl\n" + text + "$"; if (PlayerProfile.Name.Equals(_ProfileName)) { _NameText.text = _ProfileName + " [Loaded]"; _LoadButton.Interactable(value: false); _DeleteButton.gameObject.SetActive(value: false); } } public void RemoveProfileClicked() { On_LoadSlot_RemoveClicked.Raise(_ProfileName); } public void LoadProfileClicked() { On_LoadSlot_LoadClicked.Raise(_ProfileName); } public void RemoveProfile(string nameToRemove) { if (!(_ProfileName != nameToRemove)) { PlayerProfile.DeleteProfile(_ProfileName); Object.Destroy(base.gameObject); } } public void LoadProfile(string nameToLoad) { if (!(_ProfileName != nameToLoad)) { OnLoadProfile?.Invoke(); PlayerProfile.LoadData(_ProfileName); } } }