Beispiel #1
0
    public void SevrerMessageBack(ServerMessageRequest res)
    {
        Debug.Log("获取消息");
        if (res.code == "200")
        {
            if (res.serverMessageList != null && res.serverMessageList.Count > 0)
            {
                for (int i = 0; i < res.serverMessageList.Count; i++)
                {
                    res.serverMessageList[i].receiveTime = 0;
                    if (res.serverMessageList[i].objectList.Count > 0)
                    {
                        switch (res.serverMessageList[i].objectList[i].type)
                        {
                        //物品
                        case 1:
                            Debug.Log(LitJson.JsonMapper.ToJson(res.serverMessageList[i].objectList[i].sD_Pag4U));
                            //res.serverMessageList[i].objectList[i].item;
                            break;

                        //宠物
                        case 2:
                            Debug.Log(LitJson.JsonMapper.ToJson(res.serverMessageList[i].objectList[i].monsterGrowUpAttribute));
                            //res.serverMessageList[i].objectList[i].item ;
                            break;

                        //优惠卷
                        case 3:
                            //Debug.Log();
                            var playerCoupon = res.serverMessageList[i].objectList[i].playerCoupon;
                            var item         = AndaPlayerCouponManager.Instance.PlayerCouponData.FirstOrDefault(o => o.playerCouponIndex == playerCoupon.playerCouponIndex);
                            item.status = playerCoupon.status;
                            if (CallBackUpdateCoupon != null)
                            {
                                CallBackUpdateCoupon(item);
                            }
                            //res.serverMessageList[i].objectList[i].item ;
                            break;

                        default:
                            break;
                        }
                    }
                    serverMessageView.AddContentPanel(res.serverMessageList);
                }
                GetSMMData().AddRange(res.serverMessageList);
                serverMessageView.messageCout.text = GetSMMData().Count(o => o.receiveTime == 0).ToString();
                //消息列表更新
                var json = JsonMapper.ToJson(SMMData);
                PlayerPrefs.SetString("ServerMessage", json);
            }
        }
    }
Beispiel #2
0
    private IEnumerator ExcuteGetServerMessage(string _url, WWWForm _wForm, System.Action <ServerMessageRequest> callback)
    {
        WWW postData = new WWW(_url, _wForm);

        yield return(postData);

        if (postData.error != null)
        {
            Debug.Log(postData.error);
        }
        else
        {
            ServerMessageRequest result = JsonMapper.ToObject <ServerMessageRequest>(postData.text);
            Debug.Log(postData.text);
            callback(result);
        }
    }