add school
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Assets.Scripts.Interfaces;
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
@@ -24,10 +25,10 @@ public class DialogOptionsUI : MonoBehaviour
|
||||
private DialogTabUITemplate _dialogTabUI;
|
||||
|
||||
private DialogTabUITemplate _selectedTab;
|
||||
private JobItemUITemplate _selectedItem;
|
||||
private IDialogItemUI _selectedItem;
|
||||
private DialogSO _dialogSO;
|
||||
|
||||
public void ShowCategoriesDialog(DialogSO dialogSO, Action onCancel, Action<JobInfoSO> onConfirm)
|
||||
public void ShowCategoriesDialog(DialogSO dialogSO, Action onCancel, Action<IDialogOption> onConfirm)
|
||||
{
|
||||
GameManager.Instance.UI.Freeze();
|
||||
|
||||
@@ -78,7 +79,7 @@ public class DialogOptionsUI : MonoBehaviour
|
||||
{
|
||||
var itemUI = Instantiate(_dialogSO.UITemplate, _itemsContainer);
|
||||
itemUI.gameObject.SetActive(true);
|
||||
itemUI.GetComponent<JobItemUITemplate>().SetItem(this, job);
|
||||
itemUI.GetComponent<IDialogItemUI>().SetItem(this, job);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,9 +87,8 @@ public class DialogOptionsUI : MonoBehaviour
|
||||
{
|
||||
}
|
||||
|
||||
public void OnItemSelected(JobItemUITemplate button)
|
||||
public void OnItemSelected(IDialogItemUI button)
|
||||
{
|
||||
print($"selected job {button.Item.name}");
|
||||
_selectedItem = button;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
using Assets.Scripts.Interfaces;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class EducationItemUI : MonoBehaviour, IDialogItemUI ,IPointerEnterHandler
|
||||
{
|
||||
[SerializeField]
|
||||
private TextMeshProUGUI _description;
|
||||
[SerializeField]
|
||||
private TextMeshProUGUI _duration;
|
||||
[SerializeField]
|
||||
private TextMeshProUGUI _price;
|
||||
[SerializeField]
|
||||
private Image _icon;
|
||||
|
||||
[SerializeField]
|
||||
private Button _button;
|
||||
|
||||
private DialogOptionsUI _parent;
|
||||
private EducationInfoSO _item;
|
||||
public IDialogOption Item => _item;
|
||||
|
||||
public void SetItem(DialogOptionsUI parent,IDialogOption item)
|
||||
{
|
||||
_item= item as EducationInfoSO;
|
||||
_parent = parent;
|
||||
_duration.text = _item.Duration.ToString();
|
||||
_description.text = _item.Description;
|
||||
_price.text = $"{_item.EnrollPrice}$";
|
||||
_icon.sprite = item.Icon;
|
||||
_button.enabled = true;
|
||||
}
|
||||
|
||||
|
||||
public void Click()
|
||||
{
|
||||
if (_button.enabled)
|
||||
{
|
||||
_parent.OnItemSelected(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
if (!_button.enabled) { print("Not enough education"); }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae4f157b0a61c52409c1c86ea3826ab1
|
||||
@@ -18,7 +18,7 @@ public class JobItemUITemplate : MonoBehaviour, IDialogItemUI ,IPointerEnterHan
|
||||
|
||||
private DialogOptionsUI _parent;
|
||||
private JobInfoSO _item;
|
||||
public JobInfoSO Item=> _item;
|
||||
public IDialogOption Item=> _item;
|
||||
|
||||
public void SetItem(DialogOptionsUI parent,IDialogOption item)
|
||||
{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Assets.Scripts.Interfaces;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -27,7 +28,7 @@ public class UISystem : MonoBehaviour
|
||||
timeSlider.ShowTimeSliderDialog(title, description, onCancel, onConfirm);
|
||||
}
|
||||
|
||||
public void ShowTabObtionsDialog(DialogSO dialogSO, Action onCancel, Action<JobInfoSO> onConfirm)
|
||||
public void ShowTabObtionsDialog(DialogSO dialogSO, Action onCancel, Action<IDialogOption> onConfirm)
|
||||
{
|
||||
var dialog = Instantiate(_DialogUIPrefab, transform);
|
||||
dialog.ShowCategoriesDialog(dialogSO, onCancel, onConfirm);
|
||||
|
||||
Reference in New Issue
Block a user