Super Knight : Enter the Dungeon
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.
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
public class PopupMessage : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public Button btnBG;
|
|
|
|
|
public Text txtTitle;
|
|
|
|
|
public Text txtDesc;
|
|
|
|
|
public List<Button> listBtn;
|
|
|
|
|
public List<Text> listBtnTxt;
|
|
|
|
|
public Timer timer;
|
|
|
|
|
|
|
|
|
|
System.Action<string> OnResult;
|
|
|
|
|
public void Setting(System.Action<string> OnResult, List<string> listTxt, float duration = 0)
|
|
|
|
|
{
|
|
|
|
|
this.OnResult = OnResult;
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
|
|
txtTitle.text = listTxt[i++];
|
|
|
|
|
txtDesc.text = listTxt[i++];
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < listBtn.Count; j++, i++)
|
|
|
|
|
{
|
|
|
|
|
listBtnTxt[j].text = i < listTxt.Count ? listTxt[i] : string.Empty;
|
|
|
|
|
listBtn[j].gameObject.SetActive(listBtnTxt[j].text != string.Empty);
|
|
|
|
|
}
|
|
|
|
|
btnBG.interactable = listTxt.Count < 4;
|
|
|
|
|
|
|
|
|
|
transform.SetAsFirstSibling();
|
|
|
|
|
|
|
|
|
|
if (0 < duration)
|
|
|
|
|
{
|
|
|
|
|
Invoke("OnClickBG", duration);
|
|
|
|
|
if (timer != null)
|
|
|
|
|
timer.OnInitialized(duration, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gameObject.SetActive(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnClick(Text SELECT)
|
|
|
|
|
{
|
|
|
|
|
if (OnResult != null)
|
|
|
|
|
{
|
|
|
|
|
OnResult(SELECT.text);
|
|
|
|
|
OnResult = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gameObject.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
public void OnClickBG()
|
|
|
|
|
{
|
|
|
|
|
if (OnResult != null)
|
|
|
|
|
{
|
|
|
|
|
OnResult(string.Empty);
|
|
|
|
|
OnResult = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gameObject.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
public void OnTimeOut()
|
|
|
|
|
{
|
|
|
|
|
OnResult = null;
|
|
|
|
|
gameObject.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
}
|