コード例 #1
0
    void onGetNoticesSuccess(string jsonData)
    {
        NoticeModel.Instance.hasGotNotice = true;
        Debug.Log("onGetNoticesSuccess");

        Dictionary <string, object> dataDict = jsonData.dictionaryFromJson();

        if (dataDict == null || !dataDict.ContainsKey("notice"))
        {
            return;
        }

        List <object> noticeObjList = dataDict["notice"] as List <object>;

        if (noticeObjList == null)
        {
            return;
        }

        string arrayJson = noticeObjList.toJson();

        NoticeModel.Instance.notices = NoticeData.listFromJson <NoticeData>(arrayJson);
        Debug.Log("Get " + NoticeModel.Instance.notices.Count + " Notices.");

        NoticeModel.Instance.filterByLevel();

        if (NoticeModel.Instance.notices.Count > 0 && HttpRequestService.getUserID() != -1)
        {
            string userIdStr = Language.Get("USER_ID_KEY") + HttpRequestService.getUserID().ToString();
            NoticeModel.Instance.notices[NoticeModel.Instance.notices.Count - 1].desc += "\n" + userIdStr;
        }

        // popup automatically
        //NoticeModel.Instance.PopupIfNecessary();
    }
コード例 #2
0
    private IEnumerator DoWWW()
    {
        WWWForm form = new WWWForm();

        form.AddField("cmd", "getNotice");
        form.AddField("lang", "zh");

        WWW getData = new WWW(AppSettings.gameServerUrl, form);

        yield return(getData);

        if (getData.error == null)
        {
            string            jsonStr = getData.text;
            List <NoticeData> notices = NoticeData.listFromJson <NoticeData>(jsonStr);

            NoticeData data = notices[0];
            //var oneNotice = noticeList[0];
            //List<object> x = noticeList;

            /*
             * foreach (Dictionary<string, object> dict in noticeList)
             * {
             *      Debug.Log ("fail");
             * }
             */

            /*
             * foreach (var oneNotice in noticeList)
             * {
             *      Debug.Log(oneNotice.ToString());
             * }
             */

            Debug.Log(data.desc);
            Debug.Log(getData.error);

            //newVersionPanelFsm.SendEvent("Has New Version");
        }
        else
        {
            Debug.Log("success");
            Debug.Log(getData.text);

            /*
             * if (getData.text != "1")
             * {
             *      newVersionPanelFsm.SendEvent("Has New Version");
             *      appUrl = getData.text;
             * }
             */
        }
    }