Пример #1
0
 public void InitBy(MTJSONObject js)
 {
     StartStateName = js.GetString(TrackGameStateName);
     LvId           = js.GetString(TrackLvId);
     trackMode      = js.GetString("trackMode");
     Win            = js.GetString(TrackWin);
 }
Пример #2
0
    private void GetFriendsCallback(IResult result)
    {
        if (debugInfo)
        {
            FacebookHelperDebug("GetFriendsCallback");
        }
        if (result == null)
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetFriendsCallback Null Response\n");
            }
            return;
        }

        if (!string.IsNullOrEmpty(result.Error))
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetFriendsCallback Error Response:\n" + result.Error);
            }
        }
        else if (result.Cancelled)
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetFriendsCallback Cancelled Response:\n" + result.RawResult);
            }
        }
        else if (!string.IsNullOrEmpty(result.RawResult))
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetFriendsCallback Success Response:\n" + result.RawResult);
            }
            MTJSONObject mtJson = MTJSON.Deserialize(result.RawResult);
            {// friend
                List <MTJSONObject> friends = mtJson.Get("data").list;
                //UserModel user = GameManager.Instance.User;
                //for(int i = 0; i < friends.Count; i++)
                //{
                //    MTJSONObject friendJson = friends[i];
                //    FriendModel friendModel = user.GetFriendModel(friendJson.GetString("id", ""), true);
                //    friendModel.Name = friendJson.GetString("name", "");

                //    AddDownloadPictureId(friendModel.Id);
                //}
                //Tracker.Instance.FacebookGameFriendsCount(_currFacebookId, friends.Count);
            }
        }
        else
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetFriendsCallback Empty Response\n");
            }
        }
    }
Пример #3
0
    private void GetInviteFriendsCallback(IResult result)
    {
        if (debugInfo)
        {
            FacebookHelperDebug("GetInviteFriendsCallback");
        }
        if (result == null)
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetInviteFriendsCallback Null Response\n");
            }
            return;
        }

        if (!string.IsNullOrEmpty(result.Error))
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetInviteFriendsCallback Error Response:\n" + result.Error);
            }
        }
        else if (result.Cancelled)
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetInviteFriendsCallback Cancelled Response:\n" + result.RawResult);
            }
        }
        else if (!string.IsNullOrEmpty(result.RawResult))
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetInviteFriendsCallback Success Response:\n" + result.RawResult);
            }
            MTJSONObject mtJson = MTJSON.Deserialize(result.RawResult);
            {// friend
                List <MTJSONObject> friends = mtJson.Get("data").list;
                _inviteFriends.Clear();
                for (int i = 0; i < friends.Count; i++)
                {
                    string id = friends[i].GetString("id", "");
                    if (id.Length > 0)
                    {
                        _inviteFriends.Add(id);
                    }
                }
            }
        }
        else
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetInviteFriendsCallback Empty Response\n");
            }
        }
    }
Пример #4
0
    public MTJSONObject ToJson()
    {
        var js = MTJSONObject.CreateDict();

        js.Add(TrackGameStateName, StartStateName);
        js.Add(TrackLvId, LvId);
        js.Add("trackMode", trackMode);
        js.Add(TrackWin, Win);

        return(js);
    }
Пример #5
0
    void LoadSetting()
    {
        var    bt      = File.ReadAllBytes(GetPath());
        string content = MTXXTea.DecryptToString(bt, SKEY); //File.ReadAllText(GetPath());
        // Debug.Log("get content " + content);
        MTJSONObject setJs = MTJSON.Deserialize(content);

        totalCoin = setJs.GetInt(SettingEnum.totalCoin.ToString(), 0);
        //Debug.Log("get totoal coin " + totalCoin);
        recordCoin = setJs.GetInt(SettingEnum.recordCoin.ToString(), 0);

        recordScore = setJs.GetInt(SettingEnum.recordScore.ToString(), 0);
        recordBomb  = setJs.GetInt(SettingEnum.recordBomb.ToString(), 0);
        recordRound = setJs.GetInt(SettingEnum.recordRound.ToString(), 0);
        recordMatch = setJs.GetInt(SettingEnum.recordMatch.ToString(), 0);
    }
Пример #6
0
    private void GetFriendsCallback(IResult result)
    {
        FacebookHelperDebug("GetFriendsCallback");
        if (result == null)
        {
            FacebookHelperDebug("GetFriendsCallback Null Response\n");
            return;
        }

        if (!string.IsNullOrEmpty(result.Error))
        {
            FacebookHelperDebug("GetFriendsCallback Error Response:\n" + result.Error);
        }
        else if (result.Cancelled)
        {
            FacebookHelperDebug("GetFriendsCallback Cancelled Response:\n" + result.RawResult);
        }
        else if (!string.IsNullOrEmpty(result.RawResult))
        {
            ShowInvite();
            FacebookHelperDebug("GetFriendsCallback Success Response:\n" + result.RawResult);

            MTJSONObject mtJson = MTJSON.Deserialize(result.RawResult);
            {// friend
                List <MTJSONObject> friends = mtJson.Get("data").list;

                for (int i = 0; i < friends.Count; i++)
                {
                    MTJSONObject friendJson  = friends[i];
                    FriendModel  friendModel = _user.GetFriendModel(friendJson.GetString("id", ""), true);
                    friendModel.Name = friendJson.GetString("name", "");
                    FacebookInviteMgr.current.AddIcon(friendModel);

                    AddDownloadPictureId(friendModel.Id);
                }
                // Tracker.Instance.FacebookGameFriendsCount(_currFacebookId, friends.Count);
            }
        }
        else
        {
            FacebookHelperDebug("GetFriendsCallback Empty Response\n");
        }
    }
Пример #7
0
    public void SaveToFile()
    {
        MTJSONObject setJs = MTJSONObject.CreateDict();

        setJs.Set(SettingEnum.totalCoin.ToString(), totalCoin);

        setJs.Set(SettingEnum.recordCoin.ToString(), recordCoin);

        setJs.Set(SettingEnum.recordScore.ToString(), recordScore);

        setJs.Set(SettingEnum.recordBomb.ToString(), recordBomb);
        setJs.Set(SettingEnum.recordRound.ToString(), recordRound);
        setJs.Set(SettingEnum.recordMatch.ToString(), recordMatch);



        var bt = MTXXTea.Encrypt(setJs.ToString(), SKEY);

        File.WriteAllBytes(GetPath(), bt);
    }
Пример #8
0
    public MTJSONObject SerializeToJson(bool justSyncData)
    {
        MTJSONObject res = MTJSONObject.CreateDict();

        res.Set("id", _id);
        res.Set("name", _name);
        res.Set("maxLevel", _maxLevel);

        // levels
        var          levelsEnum = _levels.GetEnumerator();
        MTJSONObject levelsJson = MTJSONObject.CreateDict();

        while (levelsEnum.MoveNext())
        {
            var current = levelsEnum.Current;
            levelsJson.Set(current.Key.ToString(), current.Value);
        }
        res.Set("levels", levelsJson);

        return(res);
    }
Пример #9
0
    public void DeserializeFromJson(MTJSONObject curJson, bool sync)
    {
        Id       = curJson.GetString("id", Id);
        Name     = curJson.GetString("name", Name);
        MaxLevel = curJson.GetInt("maxLevel", MaxLevel);

        //  levels
        MTJSONObject levelsJson = curJson.Get("levels");

        if (levelsJson != null)
        {
            if (!sync)
            {
                _levels.Clear();
            }

            if (levelsJson.count > 0)
            {
                var itemEnum = levelsJson.dict.GetEnumerator();
                while (itemEnum.MoveNext())
                {
                    string curKey    = itemEnum.Current.Key;
                    int    curValue  = itemEnum.Current.Value.i;
                    int    curKeyInt = Convert.ToInt32(curKey);

                    if (!_levels.ContainsKey(curKeyInt))
                    {
                        _levels.Add(curKeyInt, curValue);
                    }
                    else
                    {
                        _levels[curKeyInt] = curValue;
                    }
                }
            }
        }
    }
Пример #10
0
        IEnumerator sendLoop()
        {
            while (true)
            {
                yield return(new WaitForSeconds(_lastSucc ? sendInterval : retryDelay));

                if (_queue == null)
                {
                    LoadQueue();
                }

                if (_queue == null || _queue.Count == 0)
                {
                    continue;
                }

                PurchaseBillingItem item = _queue [0];

                // sign
                string sign = MTSecurity.Md5Sum(item.message + signKey);
                Debug.Log("[MTPBHelper] Sending check: " + item.message + "," + item.iapKey);
                Dictionary <string, string> headers = new Dictionary <string, string> ();
                headers ["sign"]         = sign;
                headers ["Content-Type"] = "application/json";
                byte[] bytes = System.Text.Encoding.UTF8.GetBytes(item.message);
#pragma warning disable CS0618 // 类型或成员已过时
                WWW www = new WWW(baseUrl, bytes, headers);
                yield return(www);

                if (www.error != null)
                {
                    Debug.Log("[MTPBHelper] send Error: " + www.error);
                    _lastSucc = false;
                }
                else                     // success, remove from queue
                {
                    _queue.RemoveAt(0);
                    _queueDirty = true;
                    _lastSucc   = true;

                    int code = 1;
                    if (www.text == null)
                    {
                        Debug.LogError("[MTPBHelper] www.text = null");
                    }
                    else
                    {
                        MTJSONObject jObject = MTJSON.Deserialize(www.text);
                        if (jObject == null)
                        {
                            Debug.LogError("[MTPBHelper] JSON Object (www.text) = null");
                            code = 2;
                            AddKey(new PurchaseResult(item.iapKey, code));
                        }
                        else
                        {
                            jObject = jObject.Get("ret_status");
                            if (jObject == null)
                            {
                                Debug.LogError("[MTPBHelper] ret_status = null, www.text = " + www.text);
                                code = 3;
                                AddKey(new PurchaseResult(item.iapKey, code));
                            }
                            else
                            {
                                Debug.Log("[MTPBHelper] send Succ  code = " + code);
                                code = jObject.i;
                                AddKey(new PurchaseResult(item.iapKey, code));
                            }
                        }
                    }
                    OnCheckFinished(code, item.iapKey);
                }
            }
        }
Пример #11
0
 public void ClearRequests()
 {
     if (IsLoggedIn)
     {
         FB.API("me/apprequests", HttpMethod.GET, delegate(IGraphResult result)
         {
             if (debugInfo)
             {
                 FacebookHelperDebug("ClearRequests");
             }
             if (result == null)
             {
                 if (debugInfo)
                 {
                     FacebookHelperDebug("ClearRequests Null Response\n");
                 }
             }
             else
             {
                 if (!string.IsNullOrEmpty(result.Error))
                 {
                     if (debugInfo)
                     {
                         FacebookHelperDebug("ClearRequests Error Response:\n" + result.Error);
                     }
                 }
                 else if (result.Cancelled)
                 {
                     if (debugInfo)
                     {
                         FacebookHelperDebug("ClearRequests Cancelled Response:\n" + result.RawResult);
                     }
                 }
                 else if (!string.IsNullOrEmpty(result.RawResult))
                 {
                     if (debugInfo)
                     {
                         FacebookHelperDebug("ClearRequests Success Response:\n" + result.RawResult);
                     }
                     MTJSONObject mtJson         = MTJSON.Deserialize(result.RawResult);
                     List <MTJSONObject> friends = mtJson.Get("data").list;
                     for (int i = 0; i < friends.Count; i++)
                     {
                         string id = friends[i].GetString("id", "");
                         if (id.Length > 0)
                         {
                             FB.API(id, HttpMethod.DELETE, delegate(IGraphResult deleteResult)
                             {
                                 if (debugInfo)
                                 {
                                     FacebookHelperDebug("DeleteRequests" + id);
                                 }
                                 if (deleteResult == null)
                                 {
                                     if (debugInfo)
                                     {
                                         FacebookHelperDebug("DeleteRequests Null Response\n" + id);
                                     }
                                 }
                                 else
                                 {
                                     if (!string.IsNullOrEmpty(deleteResult.Error))
                                     {
                                         if (debugInfo)
                                         {
                                             FacebookHelperDebug("DeleteRequests Error Response:\n" + deleteResult.Error + ", id = " + id);
                                         }
                                     }
                                     else if (deleteResult.Cancelled)
                                     {
                                         if (debugInfo)
                                         {
                                             FacebookHelperDebug("DeleteRequests Cancelled Response:\n" + deleteResult.RawResult + ", id = " + id);
                                         }
                                     }
                                     else if (!string.IsNullOrEmpty(deleteResult.RawResult))
                                     {
                                         if (debugInfo)
                                         {
                                             FacebookHelperDebug("DeleteRequests Success Response:\n" + deleteResult.RawResult + ", id = " + id);
                                         }
                                     }
                                     else
                                     {
                                         if (debugInfo)
                                         {
                                             FacebookHelperDebug("DeleteRequests Empty Response\n" + id);
                                         }
                                     }
                                 }
                             });
                         }
                     }
                 }
                 else
                 {
                     if (debugInfo)
                     {
                         FacebookHelperDebug("ClearRequests Empty Response\n");
                     }
                 }
             }
         });
     }
 }
Пример #12
0
    private void GetInviteFriendsCallback(IResult result)
    {
        if (debugInfo)
        {
            FacebookHelperDebug("GetInviteFriendsCallback");
        }
        if (result == null)
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetInviteFriendsCallback Null Response\n");
            }
            return;
        }

        if (!string.IsNullOrEmpty(result.Error))
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetInviteFriendsCallback Error Response:\n" + result.Error);
            }
        }
        else if (result.Cancelled)
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetInviteFriendsCallback Cancelled Response:\n" + result.RawResult);
            }
        }
        else if (!string.IsNullOrEmpty(result.RawResult))
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetInviteFriendsCallback Success Response:\n" + result.RawResult);
            }
            MTJSONObject mtJson = MTJSON.Deserialize(result.RawResult);
            {// friend
                List <MTJSONObject> friends = mtJson.Get("data").list;
                _inviteFriends.Clear();
                for (int i = 0; i < friends.Count; i++)
                {
                    MTJSONObject friendJson  = friends[i];
                    FriendModel  friendModel = _user.GetFriendModel(friendJson.GetString("id", ""), true);
                    friendModel.Name = friendJson.GetString("name", "");
                    FacebookInviteMgr.current.AddIcon(friendModel);

                    AddDownloadPictureId(friendModel.Id);

                    //string id = friends[i].GetString("id", "");
                    //if (id.Length > 0)
                    //{
                    //    _inviteFriends.Add(id);
                    //}
                }
            }
        }
        else
        {
            if (debugInfo)
            {
                FacebookHelperDebug("GetInviteFriendsCallback Empty Response\n");
            }
        }
    }