예제 #1
0
    private void UpdateLang(SystemLanguage lang)
    {
        _currentLang = lang;

        _spriteAtlas = Resources.Load <SpriteAtlas>(STR_LOCALIZATION_PREFIX + _currentLang.ToString());
        if (_spriteAtlas == null)
        {
            Debug.Log(_currentLang + " language not exist, change Language to English ");
            _currentLang = SystemLanguage.English;
            _spriteAtlas = Resources.Load <SpriteAtlas>(STR_LOCALIZATION_PREFIX + _currentLang.ToString());
        }

        if (_spriteAtlas == null)
        {
            Debug.Log("SpriteAltas not exist" + STR_LOCALIZATION_PREFIX + _currentLang.ToString());
        }

        var currentAsset = Resources.Load <TextAsset>(STR_LOCALIZATION_TEXT + _currentLang.ToString() + "_local");
        var tellAsset    = Resources.Load <TextAsset>(STR_TELLOUT_TEXT + _currentLang.ToString() + "_local");

        currentTextsDict = MTJSON.Deserialize(currentAsset.ToString()).dict;
        if (tellAsset != null)
        {
            var tellDict = MTJSON.Deserialize(tellAsset.ToString()).dict;
            foreach (var p in tellDict)
            {
                if (currentTextsDict.ContainsKey(p.Key))
                {
                    currentTextsDict[p.Key] = p.Value;
                }
            }
        }
    }
예제 #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
 public static string GetEditorText(string key)
 {
     if (_editorDict == null)
     {
         var currentAsset = Resources.Load <TextAsset>(STR_LOCALIZATION_TEXT + "English_local");
         _editorDict = MTJSON.Deserialize(currentAsset.ToString()).dict;
     }
     return(_editorDict[key].s);
 }
예제 #4
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");
            }
        }
    }
예제 #5
0
        protected void BuildMessage(List <TrackItem> items, out string jsonStr, out string sign)
        {
            Dictionary <string, object> json = BuildTrackMessage(items);

            if (json == null)
            {
                jsonStr = "";
                sign    = "";
                return;
            }

            jsonStr = MTJSON.Serialize(json);
            // sign
            sign = MTSecurity.Md5Sum(jsonStr + signKey);
        }
예제 #6
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);
    }
예제 #7
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");
        }
    }
예제 #8
0
        public PurchaseBillingItem(string key, string appId, string userId, string channel, Dictionary <string, object> infos)
        {
            iapKey = key;

            Dictionary <string, object> jObject = new Dictionary <string, object>(3 + infos.Count);

            jObject.Add("appId", appId);
            jObject.Add("userId", userId);
            jObject.Add("channel", channel);
            foreach (string k in infos.Keys)
            {
                if (infos [k] == null)
                {
                    jObject.Add(k, "");
                }
                else
                {
                    jObject.Add(k, infos [k]);
                }
            }
            message = MTJSON.Serialize(jObject);
        }
예제 #9
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);
                }
            }
        }
예제 #10
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");
                     }
                 }
             }
         });
     }
 }
예제 #11
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");
            }
        }
    }