Пример #1
0
    private IEnumerator LoadDataCoroutine()
    {
        WWW www = null;

        try {
            www = WebConnector.GetInitialData();
        } catch (Exception e) {
            Debug.Log("exception: " + e);
        }
        yield return(www);

        if (!string.IsNullOrEmpty(www.error))
        {
            Debug.Log("www error: " + www.error);

            PanelLoading.GetComponent <PanelLoading>().JustDo  = () => { PrepareLoading(); };
            PanelLoading.GetComponent <PanelLoading>().TextTop = "Internet connection required. (" + www.error + ")";
            PanelLoading.GetComponent <PanelLoading>().TextTap = "Tap to retry";
        }
        else
        {
            JSONNode n = JSONNode.Parse(www.text);

            if (HasGoodVersion(n))
            {
                ParseInitialData(n);
            }
            else
            {
                PanelLoading.GetComponent <PanelLoading>().JustDo = () => { Application.OpenURL("https://play.google.com/store/apps/details?id=com.kprojekt.fingerofgod"); };
                string headlines = n["thisVersionHeadlines"].Value;
                PanelLoading.GetComponent <PanelLoading>().TextTop = "There is new version with: " + headlines;
                PanelLoading.GetComponent <PanelLoading>().TextTap = "Tap to update";
            }
        }
    }