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.
97 lines
2.9 KiB
97 lines
2.9 KiB
using System.Collections.Generic; |
|
using UnityEngine; |
|
|
|
public class BaseBoard : MonoBehaviour |
|
{ |
|
List<GameObject> m_dialogs = new List<GameObject>(); |
|
|
|
//----------------------------------------------------------------------------------------- |
|
void Start () |
|
{ |
|
|
|
} |
|
|
|
//------------------------------------------------------------------ |
|
public virtual void ApplaySafeAreaHudShift() |
|
{ |
|
|
|
} |
|
|
|
//----------------------------------------------------------------------------------------- |
|
public int DialogsCount |
|
{ |
|
get { return m_dialogs.Count; } |
|
} |
|
|
|
//----------------------------------------------------------------------------------------- |
|
public virtual void Update () |
|
{ |
|
CommonFunctions.CheckTestKeyPressed(); |
|
} |
|
|
|
//----------------------------------------------------------------------------------------- |
|
public GameObject StartDialog(string dlgName) |
|
{ |
|
GameObject backObj = GameObject.FindGameObjectWithTag("BackForInterface"); |
|
if (!backObj) |
|
return null; |
|
|
|
MainMenu menu = this as MainMenu; |
|
if (!menu) |
|
Time.timeScale = 0f; |
|
|
|
GameObject dlgObj = Instantiate(Resources.Load("prefabs/Dialogs/" + dlgName) as GameObject); |
|
dlgObj.transform.SetParent(backObj.transform); |
|
dlgObj.transform.SetAsLastSibling(); |
|
dlgObj.transform.localScale = Vector3.one; |
|
dlgObj.transform.localPosition = Vector3.zero; |
|
|
|
m_dialogs.Add(dlgObj); |
|
return dlgObj; |
|
} |
|
|
|
//----------------------------------------------------------------------------------------- |
|
public void StartNoInternetDialogIfNeed() |
|
{ |
|
if (GlobalsVar.gRealPurchasesWasInitialized) |
|
return; |
|
|
|
GameObject noInternetDlg = StartDialog("NoInternetDialog"); |
|
noInternetDlg.GetComponent<NoInternetDialog>().Init(); |
|
} |
|
|
|
//------------------------------------------------------------------ |
|
public GameObject GetDialogByType(DialogType type) |
|
{ |
|
foreach (GameObject dialogObj in m_dialogs) |
|
{ |
|
BaseDialog dialog = dialogObj.GetComponent<BaseDialog>(); |
|
if (!dialog) |
|
CommonFunctions.myassert(false, "Dialog component not found!"); |
|
|
|
if (dialog.Type == type) |
|
return dialogObj; |
|
} |
|
|
|
return null; |
|
} |
|
|
|
//----------------------------------------------------------------------------------------- |
|
public void CloseWaitDlg() |
|
{ |
|
GameObject dlg = GetDialogByType(DialogType.WAIT_DIALOG); |
|
if (dlg) |
|
{ |
|
RemoveDialog(dlg); |
|
Destroy(dlg); |
|
} |
|
} |
|
|
|
//----------------------------------------------------------------------------------------- |
|
public void RemoveDialog(GameObject dlgObj) |
|
{ |
|
Time.timeScale = 1f; |
|
if (m_dialogs.Contains(dlgObj)) |
|
m_dialogs.Remove(dlgObj); |
|
} |
|
}
|
|
|