Пример #1
0
    public IEnumerator Extra(int num, int amount, ExtraCallback callBack = null)
    {
        if (num <= 0 || isDrawing || amount <= 0)
        {
            yield return(null);
        }
        isDrawing = true;
        mResult   = null;
        string url = string.Format("{0}?num={1}&amount={2}", DrawExtraURL, num, amount);

        using (UnityWebRequest webReqest = UnityWebRequest.Get(url))
        {
            yield return(webReqest.SendWebRequest());

            if (webReqest.isNetworkError)
            {
                Debug.Log("网络连接错误");
            }
            isDrawing = false;
            string value = webReqest.downloadHandler.text;
            mResult = PersonInfo.ToPersionInfo(value);
            List <List <PersonInfo> > typeList = null;
            if (!mCurrentInfos.TryGetValue(EType.eExtra, out typeList))
            {
                typeList = new List <List <PersonInfo> >();
                typeList.Add(new List <PersonInfo>());
                mCurrentInfos.Add(EType.eExtra, typeList);
            }
            typeList[0].AddRange(mResult);
            callBack?.Invoke(mResult, ExtraInfo.FromString(value));
        }
    }