Files
SimUL/Assets/Scripts/UIElements/JobItemUITemplate.cs
T
vova 612b793677 Implement player education parameter
Enable job offer according to Player education
2023-05-01 19:40:14 +03:00

46 lines
1.1 KiB
C#

using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class JobItemUITemplate : MonoBehaviour, IPointerEnterHandler
{
[SerializeField]
private TextMeshProUGUI _descreiption;
[SerializeField]
private TextMeshProUGUI _sallary;
[SerializeField]
private Image _icon;
[SerializeField]
private Button _button;
private JobSelectorUI _parent;
private JobInfoSO _item;
public JobInfoSO Item=> _item;
public void SetItem(JobSelectorUI parent,JobInfoSO item)
{
_item= item;
_parent = parent;
_descreiption.text = item.Description;
_sallary.text = $"{item.Salary}$";
_icon.sprite = item.Icon;
_button.enabled = Player.Instance.Education>=item.MinimumEducationSkill;
}
public void Click()
{
if (_button.enabled)
{
_parent.OnItemSelected(this);
}
}
public void OnPointerEnter(PointerEventData eventData)
{
if (!_button.enabled) { print("Not enough education"); }
}
}