Пример #1
0
 public void SendMessageInSocietyParty(InputField inputField)
 {
     if (!string.IsNullOrEmpty(inputField.text) && !Regex.IsMatch(inputField.text, "^[ \t\r\n\u0200]*$"))
     {
         var Json = new JSONClass();
         Json ["message"] = inputField.text;
         Json ["time"]    = DateTime.UtcNow.ToBinary().ToString();
         string message = Json.ToString();
         ChatManager.Instance.SendChatMessage(message);
     }
     inputField.text = "";
 }
Пример #2
0
    public void SavePlayerLocation()
    {
        JSONClass  playerLocation = new JSONClass();
        GameObject player         = GameObject.FindGameObjectWithTag("Player");

        playerLocation["Coordinates"][-1] = player.transform.position.x.ToString();
        playerLocation["Coordinates"][-1] = player.transform.position.y.ToString();
        playerLocation["Coordinates"][-1] = player.transform.position.z.ToString();

        PlayerPrefs.SetString("SaveLocation", playerLocation.ToString());
        return;
    }
 public void SendMessageInFlatParty(string msg)
 {
     if (!string.IsNullOrEmpty(msg.ToString()) && !Regex.IsMatch(msg.ToString(), "^[ \t\r\n\u0200]*$"))
     {
         var Json = new JSONClass();
         Json ["message"] = msg.ToString();
         Json ["time"]    = DateTime.UtcNow.ToBinary().ToString();
         string message = Json.ToString();
         ChatManager.Instance.SendChatMessage(message);
     }
     msg = "";
 }
Пример #4
0
        private IFizzUserGroup CreateUserGroup(FizzGroupMemberEventData eventData)
        {
            JSONClass userGroupJson = new JSONClass
            {
                { FizzJsonUserGroup.KEY_GROUP_ID, eventData.GroupId },
                { FizzJsonUserGroup.KEY_ROLE, eventData.Role.ToString() },
                { FizzJsonUserGroup.KEY_STATE, eventData.State.ToString() },
                { FizzJsonUserGroup.KEY_CREATED, Utils.GetCurrentUnixTimeStamp() }
            };

            return(new FizzJsonUserGroup(userGroupJson.ToString()));
        }
Пример #5
0
        public static void joinGame()
        {
            JSONClass data = new JSONClass();

            data.Add(ServerTags.TAG, ServerTags.GAME_REQUEST);
            data.Add(DeviceTags.COIN, UserController.getInstance.Coin);
            data.Add(DeviceTags.DISPLAY_NAME, "" + UserController.getInstance.Name);
            data.Add(DeviceTags.PIC, UserController.getInstance.Image);
            data.Add(ServerTags.PLAYER_ID, UserController.getInstance.ID);
            data.Add(DeviceTags.TOTAL_MATCH, "12");
            data.Add(DeviceTags.WON_MATCH, "3");
            appwarp.sendChat(data.ToString());
        }
 public bool SendMessage(string key)
 {
     if (handle == IntPtr.Zero)
     {
         return(false);
     }
     else
     {
         JSONClass node = new JSONClass();
         node["Key"] = key;
         return(DataUtility.SendString(handle, node.ToString()));
     }
 }
Пример #7
0
        public void Save()
        {
            string     FILE_TMP = String.Concat(FILE, ".tmp");
            FileStream strm     = File.Open(FILE_TMP, FileMode.OpenOrCreate);

            byte[] buf = Encoding.UTF8.GetBytes(json.ToString(""));
            strm.BeginWrite(buf, 0, buf.Length, (IAsyncResult result) => {
                strm.EndWrite(result);
                strm.Close();
                File.Copy(FILE_TMP, FILE, true);
                File.Delete(FILE_TMP);
            }, null);
        }
        static void Startup()
        {
            EditorApplication.update -= Startup;

            if (!EditorPrefs.HasKey(keyName))
            {
                JSONNode data = new JSONClass();
                data["active"].AsBool = true;
                EditorPrefs.SetString(keyName, data.ToString());
            }

            Count();
        }
Пример #9
0
        void UpdateSaveStore()
        {
            JSONArray freshArray = new JSONArray();

            saveJSON["keyframes"] = freshArray;

            keyframes.ForEach((key) =>
            {
                freshArray.Add(key.pose);
            });

            saveStore.SetVal(saveJSON.ToString());
        }
Пример #10
0
    public IEnumerator DeleteSocietyInvitations(int InvitationId)
    {
        ScreenAndPopupCall.Instance.LoadingScreen();

        var encoding = new System.Text.UTF8Encoding();

        Dictionary <string, string> postHeader = new Dictionary <string, string> ();


        var jsonElement = new JSONClass();

        jsonElement ["data_type"]     = "delete_society";
        jsonElement ["player_id"]     = PlayerPrefs.GetInt("PlayerId").ToString();
        jsonElement ["invitation_id"] = InvitationId.ToString();

        postHeader.Add("Content-Type", "application/json");
        postHeader.Add("Content-Length", jsonElement.Count.ToString());

        WWW www = new WWW(SocietyLink, encoding.GetBytes(jsonElement.ToString()), postHeader);

        print("jsonDtat is ==>> " + jsonElement.ToString());
        yield return(www);

        if (www.error == null)
        {
            JSONNode _jsnode = Simple_JSON.JSON.Parse(www.text);
            print("_jsnode ==>> " + _jsnode.ToString());
            if (_jsnode ["status"].ToString().Contains("200"))
            {
                print("Success");
                yield return(true);
            }
            else
            {
                yield return(false);
            }
        }
        ScreenAndPopupCall.Instance.LoadingScreenClose();
    }
    public string toJsonString()
    {
        JSONClass json = new JSONClass();

        json.Add("title", new JSONData(title));

        if (responseHandler != null)
        {
            json = responseHandler.addHandlerToJson(json);
        }

        return(json.ToString());
    }
Пример #12
0
        public static void joinGameHello()
        {
            JSONClass data = new JSONClass();

            data.Add(ServerTags.TAG, ServerTags.GAME_REQUEST);
            data.Add(Tags.COIN, PlayerPrefs.GetString(GetPlayerDetailsTags.PLAYER_COIN));
            data.Add(Tags.DISPLAY_NAME, PlayerPrefs.GetString(GetPlayerDetailsTags.PLAYER_NAME));
            data.Add(Tags.PIC, PlayerPrefs.GetString(GetPlayerDetailsTags.PLAYER_IMAGE));
            data.Add(ServerTags.PLAYER_ID, PlayerPrefs.GetString(GetPlayerDetailsTags.PLAYER_ID));
            data.Add(Tags.TOTAL_MATCH, "12");
            data.Add(Tags.WON_MATCH, "3");
            sendChat(data.ToString());
        }
Пример #13
0
        public void JsonClass_Set_EscapeTab()
        {
            // arrange
            var node = new JSONClass();

            node["value"] = new JSONData("\t");


            // act
            var result = node.ToString();

            // assert
            Assert.IsTrue(result.Contains("\\t"));
        }
Пример #14
0
    public void setPosition()
    {
        HTTPRequest request = new HTTPRequest(new Uri("http://run-west.att.io/d9576f027ee8f/6e9234f387c9/9c7023eee2b3b23/in/flow/position"), HTTPMethods.Put, setPositionFinished);

        JSONClass data = new JSONClass();

        data["value"] = position.ToString();

        request.AddHeader("Content-Type", "application/json");
        request.RawData = Encoding.UTF8.GetBytes(data.ToString());
        request.Send();

        moveScreenTo();
    }
    public void SetFeedbackCustomFields(Dictionary <string, string> fields)
    {
        if (fields != null && fields.Count > 0)
        {
            JSONClass json = new JSONClass();

            foreach (string key in fields.Keys)
            {
                json.Add(key, new JSONData(fields[key]));
            }

            _uhSetFeedbackCustomFields(json.ToString());
        }
    }
Пример #16
0
        public void PublishMessage(string channel,
                                   string nick,
                                   string body,
                                   Dictionary <string, string> data,
                                   bool translate,
                                   bool persist,
                                   Action <FizzException> callback)
        {
            IfOpened(() =>
            {
                if (string.IsNullOrEmpty(channel))
                {
                    FizzUtils.DoCallback(ERROR_INVALID_CHANNEL, callback);
                    return;
                }

                try
                {
                    string path    = string.Format(FizzConfig.API_PATH_MESSAGES, channel);
                    JSONClass json = new JSONClass();
                    json[FizzJsonChannelMessage.KEY_NICK]             = nick;
                    json[FizzJsonChannelMessage.KEY_BODY]             = body;
                    json[FizzJsonChannelMessage.KEY_PERSIST].AsBool   = persist;
                    json[FizzJsonChannelMessage.KEY_TRANSLATE].AsBool = translate;

                    string dataStr = string.Empty;
                    if (data != null)
                    {
                        JSONClass dataJson = new JSONClass();
                        foreach (KeyValuePair <string, string> pair in data)
                        {
                            dataJson.Add(pair.Key, new JSONData(pair.Value));
                        }

                        dataStr = dataJson.ToString();
                    }

                    json[FizzJsonChannelMessage.KEY_DATA] = dataStr;

                    _restClient.Post(FizzConfig.API_BASE_URL, path, json.ToString(), (response, ex) =>
                    {
                        FizzUtils.DoCallback(ex, callback);
                    });
                }
                catch (FizzException ex)
                {
                    FizzUtils.DoCallback(ex, callback);
                }
            });
        }
Пример #17
0
    public void SaveClaimRewardsEvents(List <int> EventIds)
    {
        PlayerPrefs.DeleteKey(RewardsString + PlayerPrefs.GetInt("PlayerId"));

        JSONClass arrayJson = new JSONClass();

        EventIds.ForEach(id => {
            var jsonElement    = new JSONClass();
            jsonElement ["Id"] = id.ToString();
            arrayJson.Add(jsonElement);
        });

        PlayerPrefs.SetString(RewardsString + PlayerPrefs.GetInt("PlayerId"), arrayJson.ToString(""));
    }
    public void UpdatePurchasedItem(string sku, double price, UserHookResponseHandler responseHandler)
    {
        JSONClass handlerJson = new JSONClass();

        if (responseHandler != null)
        {
            handlerJson = responseHandler.addHandlerToJson(handlerJson);
        }


        string handlerString = handlerJson.ToString();

        _uhUpdatePurchasedItem(sku, price, handlerString);
    }
Пример #19
0
    Handle(JSONClass node)
    {
        string  node_output = WWW.EscapeURL(node.ToString().Trim());
        string  url         = urlBase + "&json=" + node_output + "&file=optimization/" + node["data"]["session_id"] + ".json";
        WWWForm form        = new WWWForm();

        form.AddField("data", node_output);
        data = new WWW(url, form);
        Debug.Log("Sending data to: " + url);
        if (DoWWW(data) != null)
        {
            StartCoroutine(DoWWW(data));
        }
    }
Пример #20
0
 public Card(JSONClass json)
 {
     if (json == null)
     {
         throw new ArgumentNullException("json");
     }
     JsonString = json.ToString();
     if (json["id"] == null || json["type"] == null || json["viewed"] == null || json["created"] == null || json["updated"] == null)
     {
         throw new ArgumentException("Missing required field(s).");
     }
     ID      = json["id"];
     Type    = json["type"];
     Viewed  = json["viewed"].AsBool;
     Created = json["created"].AsInt;
     Updated = json["updated"].AsInt;
     if (json["extras"] != null)
     {
         Extras = JsonUtils.JSONClassToDictionary(json["extras"].AsObject);
     }
     Categories = new HashSet <CardCategory>();
     if (json["categories"] == null)
     {
         Categories.Add(CardCategory.NO_CATEGORY);
     }
     else
     {
         JSONArray jsonArray = (JSONArray)JSON.Parse(json["categories"].ToString());
         if (jsonArray == null || jsonArray.Count == 0)
         {
             Categories.Add(CardCategory.NO_CATEGORY);
         }
         else
         {
             for (int i = 0; i < jsonArray.Count; i++)
             {
                 CardCategory category = (CardCategory)EnumUtils.TryParse(typeof(CardCategory), jsonArray[i], true, CardCategory.NO_CATEGORY);
                 if (category != CardCategory.NO_CATEGORY)
                 {
                     Categories.Add(category);
                 }
             }
             if (Categories.Count == 0)
             {
                 Categories.Add(CardCategory.NO_CATEGORY);
             }
         }
     }
 }
Пример #21
0
        private static void CreateEditorAssembliesForChildFoldersRecursive(string path, string mainAsmFileName, List <FileInfo> allAsmdefs)
        {
            foreach (var dir in Directory.GetDirectories(path))
            {
                var dirInfo = new DirectoryInfo(dir);

                // if this folder already contains an asmdef, do not touch
                var files = dirInfo.GetFiles();
                if (files.Any(f => f.Extension == ".asmdef"))
                {
                    continue;
                }

                // if the folder is an editor folder
                if (dirInfo.Name == "Editor")
                {
                    // generate an editor asmdef and make it ref the main asmdef
                    var editorAsmFile = new JSONClass();

                    // name
                    var editorAsmFileName = GetAsmdefName(dir, allAsmdefs);
                    editorAsmFile.Add("name", new JSONData(editorAsmFileName));

                    // ref to the main one
                    var refs = new JSONArray();
                    refs.Add(new JSONData(mainAsmFileName));
                    editorAsmFile.Add("references", refs);

                    // only editor
                    editorAsmFile.Add("includePlatforms", new JSONArray()
                    {
                        new JSONData("Editor")
                    });

                    // empty array
                    editorAsmFile.Add("excludePlatforms", new JSONArray());

                    var finalPath = GetAsmdefFinalPath(dir, editorAsmFileName);
                    SaveContentsToFile(editorAsmFile.ToString(), finalPath);

                    allAsmdefs.Add(new FileInfo(finalPath));
                }
                else // if this folder is not an editor
                {
                    // create asmdefs for the children ;)
                    CreateEditorAssembliesForChildFoldersRecursive(dir, mainAsmFileName, allAsmdefs);
                }
            }
        }
Пример #22
0
    private void WriteJsonFile(string fileName, JSONClass jobj)
    {
        Debug.Log("UpdateJsonFile: " + fileName);
        var par1 = Path.Combine(Application.dataPath, "../abFiles");
        var f1   = Path.Combine(par1, fileName);

        Debug.Log("WriteJsonFile: " + f1);
        f1 = f1.Replace("\\", "/");

        if (File.Exists(f1))
        {
            File.Delete(f1);
        }
        File.WriteAllText(f1, jobj.ToString());
    }
Пример #23
0
        public string AsJson()
        {
            JSONClass json = new JSONClass();

            json[ItemTypeKey]         = ItemType;
            json[OrderIdKey]          = OrderId;
            json[PackageNameKey]      = PackageName;
            json[ProductIdKey]        = ProductId;
            json[PurchaseTimeKey]     = new JSONData(Time);
            json[PurchaseStateKey]    = new JSONData(State);
            json[DeveloperPayloadKey] = DeveloperPayload;
            json[PurchaseTokenKey]    = Token;

            return(json.ToString());
        }
Пример #24
0
    void sendArrow(Vector3 position, Vector3 direction)
    {
        var msg = new JSONClass();

// TODO: set unique client name!
        msg.Add("SRC", "client");
        msg.Add("TYPE", "arrow");
        msg["position"]["x"]  = ((int)(position.x * 100)).ToString();
        msg["position"]["y"]  = ((int)(position.y * 100)).ToString();
        msg["position"]["z"]  = ((int)(position.z * 100)).ToString();
        msg["direction"]["x"] = ((int)(direction.x * 100)).ToString();
        msg["direction"]["y"] = ((int)(direction.y * 100)).ToString();
        msg["direction"]["z"] = ((int)(direction.z * 100)).ToString();

        server.SendData(msg.ToString());
    }
Пример #25
0
        public static string makeResponseJson(string code, string requestId, params string[] data)
        {
            JSONClass response = new JSONClass();

            response.Add(ResponseKey.Code, code);
            JSONArray dataArray = new JSONArray();

            foreach (string item in data)
            {
                dataArray.Add(null, item);
            }
            response.Add(ResponseKey.Data, dataArray);
            //response.Add(ResponseKey.Format, dataFormat);
            response.Add(ResponseKey.RequestId, requestId);
            return(response.ToString());
        }
Пример #26
0
    private IEnumerator UploadToServer()
    {
        JSONNode json = new JSONClass();

        json ["id"].AsInt       = 2;
        json ["name"]           = "Chicago Demo";
        json ["elements"].AsInt = quests.Count;

        //Add quests
        JSONArray questArray = new JSONArray();
        int       i          = 0;

        foreach (Quest q in quests)
        {
            JSONNode questNode = new JSONClass();
            questNode["id"].AsInt     = i + 1;
            questNode["name"]         = q.name;
            questNode["object"]       = q.portal;
            questNode["type"].AsInt   = q.type;
            questNode["media"]        = q.media;
            questNode["points"].AsInt = q.points;
            questNode["scale"].AsInt  = 1;
            questNode["map"]          = "yes";
            questNode["pre"]          = q.pre;
            questNode["answer"]       = q.answer;
            questNode["post"]         = q.post;
            questNode["lat"].AsFloat  = q.location.lat;
            questNode["lon"].AsFloat  = q.location.lon;
            questArray[i]             = questNode;
            i++;
        }
        json ["objects"] = questArray;

        Debug.Log(json.ToString());
        //Debug.Log (json.SaveToBase64());
        string url = "http://www.mastercava.it/digitalquest/save_quest.php?data=" + WWW.EscapeURL(Convert.ToBase64String(Encoding.UTF8.GetBytes(json.ToString())));

        Debug.Log(url);
        WWW www = new WWW(url);

        while (!www.isDone)
        {
            SetLoadingBar(www.progress);
            yield return(null);
        }
        SetLoadingBar(1f);
    }
Пример #27
0
    void SaveUserData()
    {
        JSONClass userData = new JSONClass();

        for (int i = 0; i < m_MaterialConfigurations.Count; i++)
        {
            MaterialConfigurationData data = m_MaterialConfigurations[i];
            if (data.m_Material != null)
            {
                userData["mat" + (i + 1).ToString()] = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(data.m_Material));
            }
        }

        AssetImporter ai = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(target));

        ai.userData = userData.ToString();
    }
        void OnGUI()
        {
            if (reviewWindowImage == null)
            {
                var    script = MonoScript.FromScriptableObject(this);
                string path   = Path.GetDirectoryName(AssetDatabase.GetAssetPath(script));
                reviewWindowImage = AssetDatabase.LoadAssetAtPath(path + imagePath, typeof(Texture2D)) as Texture2D;
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(31);
            GUILayout.Label(reviewWindowImage);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(48);
            EditorGUILayout.LabelField("Review Simple IAP System", GUILayout.Width(160));
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Please consider giving us a rating on the");
            EditorGUILayout.LabelField("Unity Asset Store. Your support helps us");
            EditorGUILayout.LabelField("to improve this product. Thank you!");

            GUILayout.Space(20);
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Rate now!"))
            {
                Help.BrowseURL("https://www.assetstore.unity3d.com/#!/content/12343");
                DisableRating();
            }
            if (GUILayout.Button("Later"))
            {
                JSONNode data = new JSONClass();
                data = SimpleJSON.JSON.Parse(EditorPrefs.GetString(keyName));
                data["counter"].AsInt = 5;

                EditorPrefs.SetString(keyName, data.ToString());
                this.Close();
            }
            if (GUILayout.Button("Never"))
            {
                DisableRating();
            }
            EditorGUILayout.EndHorizontal();
        }
    public void UpdatePurchasedItem(string sku, double price, UserHookResponseHandler responseHandler)
    {
        JSONClass handlerJson = new JSONClass();

        if (responseHandler != null)
        {
            handlerJson = responseHandler.addHandlerToJson(handlerJson);
        }


        string handlerString = handlerJson.ToString();

        AndroidJavaClass  doubleClass  = new AndroidJavaClass("java.lang.Double");
        AndroidJavaObject doubleObject = doubleClass.CallStatic <AndroidJavaObject>("valueOf", price);

        getUserHook().CallStatic("updatePurchasedItem", sku, doubleObject, handlerString);
    }
Пример #30
0
        public static string ToJSON(List <IAPCurrency> currency)
        {
            JSONNode  data     = new JSONClass();
            JSONArray curArray = new JSONArray();

            for (int i = 0; i < currency.Count; i++)
            {
                IAPCurrency cur = currency[i];

                curArray[i]["CurrencyCode"]   = new JSONData(cur.name.Substring(0, 2).ToUpper());
                curArray[i]["DisplayName"]    = new JSONData(cur.name);
                curArray[i]["InitialDeposit"] = new JSONData(cur.amount);
            }

            data = curArray;
            return(data.ToString());
        }
Пример #31
0
 /// <summary>
 /// Binds a key to active an InputCommand and saves it to PlayerPrefs.
 /// Note that it will not save to PlayerPrefs if the build is a debug build.
 /// </summary>
 /// <param name="a">The command to bind.</param>
 /// <param name="k">The key to bind the command to.</param>
 public static void BindKey(InputCommand a, KeyCode k)
 {
     Console.Log("Binding " + k + " to " + a);
     a.keyPress = k;
     if (keysPressed.ContainsKey(k))
     {
         keysPressed[k] = a;
     }
     else
     {
         keysPressed.Add(k, a);
     }
     JSONClass bindings = new JSONClass();
     foreach (KeyValuePair<KeyCode, InputCommand> kvp in keysPressed)
     {
         bindings.Add(kvp.Key.ToString(), new JSONData(kvp.Value.ToString()));
     }
     if (!Debug.isDebugBuild)
     {
         PlayerPrefs.SetString("bindings", bindings.ToString());
         PlayerPrefs.Save();
     }
 }
Пример #32
0
 public static void LoadField(JSONClass source, System.Reflection.FieldInfo field, MonoHelper dest)
 {
     if (source == null)
     {
         Console.LogWarning("Cannot find source JSON for " + field.Name + " in " + dest + "!");
         throw new SaveGameException();
     }
     string fieldName = field.Name;
     object value = field.GetValue(dest);
     if (value == null || value is LuaBinding || source[fieldName] == "")
     {
         return;
     }
     try
     {
         if (value is string)
         {
             string result = source[fieldName];
             field.SetValue(dest, result);
         }
         else if (value is double)
         {
             double result = source[fieldName].AsDouble;
             field.SetValue(dest, result);
         }
         else if (value is float)
         {
             float result = source[fieldName].AsFloat;
             field.SetValue(dest, result);
         }
         else if (value is bool)
         {
             bool result = source[fieldName].AsBool;
             field.SetValue(dest, result);
         }
         else if (value is int)
         {
             int result = source[fieldName].AsInt;
             field.SetValue(dest, result);
         }
         else if (value is Color)
         {
             Color result = ConvertColor(source[fieldName].AsObject);
             field.SetValue(dest, result);
         }
         else if (value is Vector4)
         {
             Vector4 result = ConvertVector4(source[fieldName].AsObject);
             field.SetValue(dest, result);
         }
         else if (value is Vector3)
         {
             Vector3 result = ConvertVector3(source[fieldName].AsObject);
             field.SetValue(dest, result);
         }
         else if (value is Vector2)
         {
             Vector2 result = ConvertVector2(source[fieldName].AsObject);
             field.SetValue(dest, result);
         }
         else if (value is AudioClip)
         {
             JSONClass jsonObject = source[fieldName].AsObject;
             AudioClip result = AudioManager.GetClip(jsonObject["name"]);
             field.SetValue(dest, result);
         }
         else if (value is Enum)
         {
             Enum result = ConvertEnum(source[fieldName].AsObject);
             field.SetValue(dest, result);
         }
         else if (value is GameObject)
         {
             string hash = source[OBJECT_ID_JSON_STRING];
             if (hash == null)
             {
                 return;
             }
             MonoHelper helper = MonoHelper.GetMonoHelper(hash);
             if (helper == null || helper.gameObject == null)
             {
                 return;
             }
             field.SetValue(dest, helper.gameObject);
         }
         else if (value is MonoHelper)
         {
             string hash = source[OBJECT_ID_JSON_STRING];
             if (hash == null)
             {
                 return;
             }
             MonoHelper helper = MonoHelper.GetMonoHelper(hash);
             if (helper == null || helper.gameObject == null)
             {
                 return;
             }
             field.SetValue(dest, helper);
         }
         else
         {
             Debug.LogWarning(fieldName + " (" + value.GetType() + "): " + value + ", " + source.ToString());
         }
     }
     catch (Exception ex)
     {
         if (!(ex is InvalidOperationException || ex is ArgumentException))
         {
             throw ex;
         }
     }
 }
Пример #33
0
 private static string GetDefaultBindings()
 {
     JSONClass bindings = new JSONClass();
     KeyCode[] keys = Globals.instance.keys;
     InputCommandName[] actionNames = Globals.instance.actions;
     InputCommand[] actions = new InputCommand[actionNames.Length];
     for (int i = 0; i < actionNames.Length; i++)
     {
         actions[i] = InputCommand.FromEnum(actionNames[i]);
     }
     for (int i = 0; i < keys.Length; i++)
     {
         bindings.Add(keys[i].ToString().ToLower(), new JSONData(actions[i].ToString()));
     }
     return bindings.ToString();
 }
Пример #34
0
    void Update()
    {
        if (dummyMessageTimer >= 0) {
            if(Mathf.Abs(dummyMessageTimer - Time.time) >= 0.3f) {
                string msgJson = "MESG{\"channel_id\": \"0\", \"message\": \"Dummy Text on Editor Mode - " + Time.time + "\", \"user\": {\"image\": \"http://url\", \"name\": \"Sender\"}, \"ts\": 1418979273365, \"scrap_id\": \"\"}";
                _OnMessageReceived(msgJson);
                dummyMessageTimer = Time.time;
            }
        }

        if (dummyChannelListFlag) {
            dummyChannelListFlag = false;
            JSONArray channels = new JSONArray();
            JSONClass channel = new JSONClass();

            channel.Add ("id", new JSONData(1));
            channel.Add ("channel_url", new JSONData("app_prefix.channel_url"));
            channel.Add ("name", new JSONData("Sample"));
            channel.Add ("cover_img_url", new JSONData("http://localhost/image.jpg"));
            channel.Add ("member_count", new JSONData(999));
            channels.Add(channel.ToString());

            channel.Add ("id", new JSONData(2));
            channel.Add ("channel_url", new JSONData("app_prefix.Unity3d"));
            channel.Add ("name", new JSONData("Unity3d"));
            channel.Add ("cover_img_url", new JSONData("http://localhost/image.jpg"));
            channel.Add ("member_count", new JSONData(999));
            channels.Add(channel.ToString());

            channel.Add ("id", new JSONData(3));
            channel.Add ("channel_url", new JSONData("app_prefix.Lobby"));
            channel.Add ("name", new JSONData("Lobby"));
            channel.Add ("cover_img_url", new JSONData("http://localhost/image.jpg"));
            channel.Add ("member_count", new JSONData(999));
            channels.Add(channel.ToString());

            channel.Add ("id", new JSONData(4));
            channel.Add ("channel_url", new JSONData("app_prefix.Cocos2d"));
            channel.Add ("name", new JSONData("Cocos2d"));
            channel.Add ("cover_img_url", new JSONData("http://localhost/image.jpg"));
            channel.Add ("member_count", new JSONData(999));
            channels.Add(channel.ToString());

            channel.Add ("id", new JSONData(5));
            channel.Add ("channel_url", new JSONData("app_prefix.GameInsight"));
            channel.Add ("name", new JSONData("GameInsight"));
            channel.Add ("cover_img_url", new JSONData("http://localhost/image.jpg"));
            channel.Add ("member_count", new JSONData(999));
            channels.Add(channel.ToString());

            channel.Add ("id", new JSONData(6));
            channel.Add ("channel_url", new JSONData("app_prefix.iOS"));
            channel.Add ("name", new JSONData("iOS"));
            channel.Add ("cover_img_url", new JSONData("http://localhost/image.jpg"));
            channel.Add ("member_count", new JSONData(999));
            channels.Add(channel.ToString());

            channel.Add ("id", new JSONData(7));
            channel.Add ("channel_url", new JSONData("app_prefix.Android"));
            channel.Add ("name", new JSONData("Android"));
            channel.Add ("cover_img_url", new JSONData("http://localhost/image.jpg"));
            channel.Add ("member_count", new JSONData(999));
            channels.Add(channel.ToString());

            channel.Add ("id", new JSONData(8));
            channel.Add ("channel_url", new JSONData("app_prefix.News"));
            channel.Add ("name", new JSONData("News"));
            channel.Add ("cover_img_url", new JSONData("http://localhost/image.jpg"));
            channel.Add ("member_count", new JSONData(999));
            channels.Add(channel.ToString());

            channel.Add ("id", new JSONData(9));
            channel.Add ("channel_url", new JSONData("app_prefix.Lobby"));
            channel.Add ("name", new JSONData("Lobby"));
            channel.Add ("cover_img_url", new JSONData("http://localhost/image.jpg"));
            channel.Add ("member_count", new JSONData(999));
            channels.Add(channel.ToString());

            channel.Add ("id", new JSONData(10));
            channel.Add ("channel_url", new JSONData("app_prefix.iPad"));
            channel.Add ("name", new JSONData("iPad"));
            channel.Add ("cover_img_url", new JSONData("http://localhost/image.jpg"));
            channel.Add ("member_count", new JSONData(999));
            channels.Add(channel.ToString());

            _OnQueryChannelList(channels.ToString());
        }
    }