Example #1
0
    private IEnumerator WaitForRequest(WWWData wwwdata)
    {
        yield return(wwwdata.www);

        // check for errors

        if (wwwdata.www.error == null)
        {
            //Variant jsonstring = JSON.Load(wwwdata.www.text);
            wwwdata.recvFunc(wwwdata.www.text);
        }
        else
        {
            if (wwwdata.retry && wwwdata.retryCount > 0)
            {
                wwwdata.retryCount--;
                //Debug.Log("WWW Error: " + wwwdata.www.error + " Retry Count:" + wwwdata.retryCount);
                StartCoroutine(WaitForRequest(wwwdata));
            }
            else
            {
                //Debug.Log("WWW Error: " + wwwdata.www.error + " Retry Fail");
                wwwdata.failFunc(wwwdata.www.error);
            }
        }
    }
Example #2
0
    public void Get(string param, Action <string> recvFunc, Action <string> failFunc, bool retry = true)
    {
        WWWData wwwData = new WWWData();

        wwwData.retryCount = MAX_RETRY;
        wwwData.retry      = retry;
        wwwData.recvFunc   = recvFunc;
        wwwData.failFunc   = failFunc;
        wwwData.www        = new WWW(param);
        StartCoroutine(WaitForRequest(wwwData));
    }
Example #3
0
    public static string parseJson(string[] dataString)
    {
        LitJson.JsonData json  = new LitJson.JsonData();
        string[]         lines = dataString;

        if (lines.Length > 1)
        {
            string[] columnNames = WWWData.SplitWithDoubleQuote(lines[0], ',');

            int count = 0;
            for (int i = 0; i < columnNames.Length; i++)
            {
                if (columnNames[i] == string.Empty ||
                    columnNames[i].Contains("\r"))
                {
                    break;
                }
                count++;
            }

            for (int i = 1; i < lines.Length; i++)
            {
                LitJson.JsonData dic = new LitJson.JsonData();
                dic.SetJsonType(LitJson.JsonType.Object);

                string[] value = WWWData.SplitWithDoubleQuote(lines[i], ',');
                for (int j = 0; j < count; j++)
                {
                    string val = "";
                    try
                    {
                        val = value[j];
                    }
                    catch
                    {
                        Debug.LogError("Utils::parseJson error / line is " + lines[i]);
                    }
                    if (string.IsNullOrEmpty(val) == false)
                    {
                        dic[columnNames[j]] = val;
                    }
                }

                json.Add(dic);
            }
        }

        return(json.ToJson());
    }
Example #4
0
    public static void RequestReadFromGoogleDrive(string key, int id, Callback OnDone)
    {
        GameObject Obj  = Camera.main.gameObject;
        WWWData    data = Obj.AddComponent <WWWData>();

        if (useResources == false)
        {
            // if (UTIL.DownloadGoogleDocsDirectly())
            {
                m_requestedData.Add(data);
                data.StartDownload(key, id, OnDone);
            }
            // else
            {
                // load from patch
                //  Object patched = DataMgr.instance.GetData(GameDefine.Name_OfPatchFile[(int)GameDefine.EnumPatchFile.GoogleDataTable], id.ToString()); //PatchManager.GetPatchItem( id.ToString());
                // if (patched != null)
                //  {
                //     data.dataString = (patched as TextAsset).text;
                // }
                //  else
                {
                    // error!!!
                    // load from resources
                    // data.dataString = (GetConfigData ( id) as TextAsset).text;
                    //       throw new System.Exception("WWWData::RequestReadFromGoogleDrive error. id is " + id);
                }
                //  OnDone(data);
            }
        }
        else
        {
            data.dataString = (GetConfigData(id) as TextAsset).text;
            OnDone(data);
        }
    }
Example #5
0
    void LoadData()
    {
        // 독스가 생기면 추가해 줘야됨.
        WWWData.RequestReadFromGoogleDrive((int)DocsDown.DocsNumber.Sound, (WWWData docs) =>
        {
            SoundSCV[] infos = Utils.GetInstance_Docs <SoundSCV[]>(docs.Lines);
            if (infos.Length > 0)
            {
                //m_tutorialTable = SetTutorialData(infos);

                for (int i = 0; i < infos.Length; i++)
                {
                    SoundInfo data = new SoundInfo(infos[i]);
                    m_SoundTable.Add(data);
                }
                // GameDefine.IsLoadAssetBundleOK = true;
            }
        });

        WWWData.RequestReadFromGoogleDrive((int)DocsDown.DocsNumber.StoryUIDesine, (WWWData docs) =>
        {
            StoryUIDesineCSV[] infos = Utils.GetInstance_Docs <StoryUIDesineCSV[]>(docs.Lines);
            if (infos.Length > 0)
            {
                for (int i = 0; i < infos.Length; i++)
                {
                    StoryUIDesineInfo data = new StoryUIDesineInfo(infos[i]);
                    m_StoryUIDesineTable.Add(data);
                }
                //  GameDefine.IsLoadDataDocs = true;
            }
        });

        WWWData.RequestReadFromGoogleDrive((int)DocsDown.DocsNumber.Talk, (WWWData docs) =>
        {
            TalkCSV[] infos = Utils.GetInstance_Docs <TalkCSV[]>(docs.Lines);
            if (infos.Length > 0)
            {
                for (int i = 0; i < infos.Length; i++)
                {
                    TalkInfo data = new TalkInfo(infos[i]);
                    m_TalkTable.Add(data);
                }
                // GameDefine.IsLoadDataDocs = true;
            }
        });

        WWWData.RequestReadFromGoogleDrive((int)DocsDown.DocsNumber.StageMapSetting, (WWWData docs) =>
        {
            StageMapSettingCSV[] infos = Utils.GetInstance_Docs <StageMapSettingCSV[]>(docs.Lines);
            if (infos.Length > 0)
            {
                for (int i = 0; i < infos.Length; i++)
                {
                    StageMapSettingInfo data = new StageMapSettingInfo(infos[i]);
                    m_StageMapSettingTable.Add(data);
                }
                GameDefine.IsLoadDataDocs = true;
            }
        });
    }