You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
2.4 KiB
85 lines
2.4 KiB
using UnityEngine; |
|
using UnityEngine.EventSystems; |
|
using UnityEngine.UI; |
|
using TMPro; |
|
|
|
public class NotEnoughDialog : BaseDialog |
|
{ |
|
[SerializeField] private GameObject _gemsIcon; |
|
[SerializeField] private GameObject _coinsIcon; |
|
|
|
[SerializeField] private Button _buttonExit; |
|
[SerializeField] private Button _buttonToStore; |
|
|
|
[SerializeField] private TextMeshProUGUI _header; |
|
[SerializeField] private TextMeshProUGUI _info; |
|
|
|
Shop.ShopType _type = Shop.ShopType.Coins; |
|
|
|
//----------------------------------------------------------------------------------------- |
|
void Start () |
|
{ |
|
m_type = DialogType.NOT_ENOUGH; |
|
} |
|
|
|
//----------------------------------------------------------------------------------------- |
|
public void Init(Shop.ShopType type) |
|
{ |
|
_type = type; |
|
|
|
InitTexts(); |
|
InitButtons(); |
|
|
|
if (_type == Shop.ShopType.Coins) |
|
_gemsIcon.SetActive(false); |
|
else if (_type == Shop.ShopType.Gems) |
|
_coinsIcon.SetActive(false); |
|
} |
|
|
|
//----------------------------------------------------------------------------------------- |
|
private void InitButtons() |
|
{ |
|
if (_buttonExit) |
|
_buttonExit.onClick.AddListener(ButtonPress); |
|
|
|
if (_buttonToStore) |
|
_buttonToStore.onClick.AddListener(ButtonPress); |
|
} |
|
|
|
//----------------------------------------------------------------------------------------- |
|
private void InitTexts() |
|
{ |
|
if (_header) |
|
{ |
|
int txtId = 120; |
|
if (_type == Shop.ShopType.Coins) |
|
txtId = 121; |
|
|
|
_header.text = GlobalsVar.gGameTextMng.GetGameText(txtId).ToUpper(); |
|
} |
|
|
|
if (_info) |
|
_info.text = GlobalsVar.gGameTextMng.GetGameText(122); |
|
} |
|
|
|
//----------------------------------------------------------------------------------------- |
|
private void ButtonPress() |
|
{ |
|
GameObject currentClickedObj = EventSystem.current.currentSelectedGameObject; |
|
if (currentClickedObj == _buttonExit.gameObject) |
|
HideDialog(); |
|
else if (currentClickedObj == _buttonToStore.gameObject) |
|
{ |
|
if (GlobalsVar.gScreenSelector) |
|
GlobalsVar.gScreenSelector.SetScreen(2); |
|
|
|
HideDialog(); |
|
} |
|
} |
|
|
|
//----------------------------------------------------------------------------------------- |
|
public override void Update () |
|
{ |
|
base.Update(); |
|
} |
|
}
|
|
|