Clear() public method

public Clear ( ) : void
return void
Beispiel #1
0
        public void EmitData(Transform transform, bool is_jump, bool move_left, bool is_clouch, float emit_time)
        {
            Vector3    position = transform.position;
            Quaternion rotate   = transform.rotation;
            Vector3    scale    = transform.localScale;

            jsonObject.Clear();
            jsonObject.AddField(POSITION_X, position.x);
            jsonObject.AddField(POSITION_Y, position.y);
            jsonObject.AddField(POSITION_Z, position.z);
            jsonObject.AddField(ROTATE_X, rotate.x);
            jsonObject.AddField(ROTATE_Y, rotate.y);
            jsonObject.AddField(ROTATE_Z, rotate.z);
            jsonObject.AddField(SCALE_X, scale.x);
            jsonObject.AddField(SCALE_Y, scale.y);
            jsonObject.AddField(SCALE_Z, scale.z);
            jsonObject.AddField(MOVE_DIR, move_left);
            jsonObject.AddField(IS_JUMP, is_jump);
            jsonObject.AddField(IS_CLOUCH, is_clouch);
            jsonObject.AddField(EMIT_TIME, emit_time);
            jsonObject.AddField(OWNER_ID, socket.sid);

            socket.Emit("CharactorUpdate", jsonObject);
            lock (emit_mutex)
            {
                emit_wait = false;
                Monitor.Pulse(emit_mutex);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 反序列化
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        private static string Deserialize(string text)
        {
            _json.Clear();          //2010-01-20 清空寄存器
            text = StrEncode(text); //转义;和,

            int    count   = 0;
            string key     = string.Empty;
            string pattern = "(\\{[^\\[\\]\\{\\}]*\\})|(\\[[^\\[\\]\\{\\}]*\\])";

            while (Regex.IsMatch(text, pattern))
            {
                MatchCollection matches = Regex.Matches(text, pattern);
                foreach (Match match in matches)
                {
                    key = "___key" + count + "___";

                    if (match.Value.Substring(0, 1) == "{")
                    {
                        _json.Add(key, DeserializeSingletonObject(match.Value));
                    }
                    else
                    {
                        _json.Add(key, DeserializeSingletonArray(match.Value));
                    }

                    text = text.Replace(match.Value, key);

                    count++;
                }
            }
            return(text);
        }
Beispiel #3
0
        public static void LoadConfigs()
        {
            if (config != null)
            {
                ConfigClear();
            }

            TextAsset configFileData = (TextAsset)AssetDatabase.LoadAssetAtPath(projectConfigFilePath, typeof(TextAsset));

            if (configFileData == null)
            {
                usingOverview = false;
                if (EditorPrefs.HasKey(setupDoneKey))
                {
                    EditorPrefs.DeleteKey(setupDoneKey);
                }

                Initialize();
                return;
            }

            config = new JSONObject(configFileData.text);

            active = config["active"].b;

            if (!active)
            {
                config.Clear();
                return;
            }
        }
Beispiel #4
0
    void Start()
    {
        infoText.gameObject.SetActive(false);

        //JSONObject usage example:

        //Parse string into a JSONObject:
        JSONObject jsonObject = JSONObject.Parse(stringToEvaluate);

        //You can also create an "empty" JSONObject
        JSONObject emptyObject = new JSONObject();

        //Adding values is easy (values are implicitly converted to JSONValues):
        emptyObject.Add("key", "value");
        emptyObject.Add("otherKey", 123);
        emptyObject.Add("thirdKey", false);
        emptyObject.Add("fourthKey", new JSONValue(JSONValueType.Null));

        //You can iterate through all values with a simple for-each loop
        foreach (KeyValuePair <string, JSONValue> pair in emptyObject)
        {
            Debug.Log("key : value -> " + pair.Key + " : " + pair.Value);

            //Each JSONValue has a JSONValueType that tells you what type of value it is. Valid values are: String, Number, Object, Array, Boolean or Null.
            Debug.Log("pair.Value.Type.ToString() -> " + pair.Value.Type.ToString());

            if (pair.Value.Type == JSONValueType.Number)
            {
                //You can access values with the properties Str, Number, Obj, Array and Boolean
                Debug.Log("Value is a number: " + pair.Value.Number);
            }
        }

        //JSONObject's can also be created using this syntax:
        JSONObject newObject = new JSONObject {
            { "key", "value" }, { "otherKey", 123 }, { "thirdKey", false }
        };

        //JSONObject overrides ToString() and outputs valid JSON
        Debug.Log("newObject.ToString() -> " + newObject.ToString());

        //JSONObjects support array accessors
        Debug.Log("newObject[\"key\"].Str -> " + newObject["key"].Str);

        //It also has a method to do the same
        Debug.Log("newObject.GetValue(\"otherKey\").ToString() -> " + newObject.GetValue("otherKey").ToString());

        //As well as a method to determine whether a key exists or not
        Debug.Log("newObject.ContainsKey(\"NotAKey\") -> " + newObject.ContainsKey("NotAKey"));

        //Elements can removed with Remove() and the whole object emptied with Clear()
        newObject.Remove("key");
        Debug.Log("newObject with \"key\" removed: " + newObject.ToString());

        newObject.Clear();
        Debug.Log("newObject cleared: " + newObject.ToString());
    }
Beispiel #5
0
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.A))
     {
         message.AddField("message", "Hello! I am " + socket.sid);
         socket.Emit("actions", message);
         message.Clear();
     }
 }
Beispiel #6
0
    private JSONObject S_MOVE()
    {
        moveJSONObject.Clear();
        moveJSONObject.type = JSONObject.Type.BAKED;
        moveJSONObject.str  = moveJson;

        Debugger.Log(moveJSONObject);
        return(moveJSONObject);
    }
Beispiel #7
0
 protected void CheckRawCopy(ref JSONObject rawJSON)
 {
     if (rawJSON != null)
     {
         rawJSON.Clear();
     }
     else
     {
         rawJSON = JSONObject.Create(JSONObject.Type.OBJECT);
     }
 }
Beispiel #8
0
        public string Parse(string input, int?randomSeed = null)
        {
            if (randomSeed.HasValue)
            {
                JSONObjectExtensions.SeedRandom(randomSeed.Value);
            }
            var output = ParseInner(input);

            // Since we kept escape characters in the string, replace single escape characters
            output = non_escaped_backslash_regex.Replace(output, "");
            // Now replace all double-escapes with single ones.
            output = output.Replace(@"\\", @"\");
            // Clear any top-level saved actions.
            SaveData.Clear();
            return(output);
        }
Beispiel #9
0
    public void MakeObjCharCardRank()
    {
        if (!charCardRankObj.HasField("CharCardRank"))
        {
            charCardRankObj.AddField("CharCardRank", charCardRankArray);
        }

        charCardRankArray.Clear();

        for (int i = 0; i < mon.charcount; i++)
        {
            charCardRankArray.Add(game.charCardRank[i]);
        }

        cardRankEncodedString1 = charCardRankObj.Print();
        //Debug.Log(debutHistoryEncodedString1);

        //sampleJson1 = new JSONObject(debutHistoryEncodedString1);
        //accessData(sampleJson1);
    }
Beispiel #10
0
    public void MakeObjUnitDebutHistory()
    {
        if (!unitDebutHistoryObj.HasField("DebutHistory"))
        {
            unitDebutHistoryObj.AddField("DebutHistory", unitDebutHistoryArray);
        }

        unitDebutHistoryArray.Clear();

        for (int i = 0; i < mon.unitcount; i++)
        {
            unitDebutHistoryArray.Add(game.unitDebutHistory[i]);
        }

        debutHistoryEncodedString1 = unitDebutHistoryObj.Print();
        //Debug.Log(debutHistoryEncodedString1);

        //sampleJson1 = new JSONObject(debutHistoryEncodedString1);
        //accessData(sampleJson1);
    }
Beispiel #11
0
        public string ToJson()
        {
#if SHIP_DOCK_SDK
            jSON.AddField(nameof(soeAppId), soeAppId);
            jSON.AddField(nameof(token), token);
            jSON.AddField(nameof(evalMode), (int)evalMode);
            jSON.AddField(nameof(workMode), (int)workMode);
            jSON.AddField(nameof(storageMode), (int)storageMode);
            jSON.AddField(nameof(serverType), (int)serverType);
            jSON.AddField(nameof(textMode), (int)textMode);
            jSON.AddField(nameof(scoreCoeff), scoreCoeff);
            jSON.AddField(nameof(fragSize), fragSize);
            jSON.AddField(nameof(fragEnable), fragEnable);
            jSON.AddField(nameof(timeout), timeout);
            string str = jSON.ToString();
            jSON.Clear();
            return(str);
#else
            return(string.Empty);
#endif
        }
Beispiel #12
0
    public void MakeObjCharDearDegree()
    {
        //unitDearDegreeObj.AddField("field1", 0.5f);
        //unitDearDegreeObj.AddField("field2", "sampletext");
        if (!charDearDegreeObj.HasField("DearDegree"))
        {
            charDearDegreeObj.AddField("DearDegree", charDearDegreeArray);
        }

        charDearDegreeArray.Clear();

        //Debug.Log("character count :" + mon.charcount);
        for (int i = 0; i < mon.charcount; i++)
        {
            charDearDegreeArray.Add(game.charDearDegree[i]);
            //Debug.Log(game.charDearDegree[i]);
        }

        dearDegreeEncodedString1 = charDearDegreeObj.Print();
        //Debug.Log(dearDegreeEncodedString1);

        //JSONObject sampleJson1 = new JSONObject(dearDegreeEncodedString1);
        //accessData(sampleJson1);
    }
Beispiel #13
0
 public static void clearJson()
 {
     _json.Clear();
 }
    void Start()
    {
        infoText.gameObject.SetActive(false);

        //JSONObject usage example:

        //Parse string into a JSONObject:
        JSONObject.Parse(stringToEvaluate);

        //You can also create an "empty" JSONObject
        JSONObject emptyObject = new JSONObject();

        //Adding values is easy (values are implicitly converted to JSONValues):
        emptyObject.Add("key", "value");
        emptyObject.Add("otherKey", 123);
        emptyObject.Add("thirdKey", false);
        emptyObject.Add("fourthKey", new JSONValue(JSONValueType.Null));

        //You can iterate through all values with a simple for-each loop
        foreach (KeyValuePair<string, JSONValue> pair in emptyObject) {
            Debug.Log("key : value -> " + pair.Key + " : " + pair.Value);

            //Each JSONValue has a JSONValueType that tells you what type of value it is. Valid values are: String, Number, Object, Array, Boolean or Null.
            Debug.Log("pair.Value.Type.ToString() -> " + pair.Value.Type.ToString());

            if (pair.Value.Type == JSONValueType.Number) {
                //You can access values with the properties Str, Number, Obj, Array and Boolean
                Debug.Log("Value is a number: " + pair.Value.Number);
            }
        }

        //JSONObject's can also be created using this syntax:
        JSONObject newObject = new JSONObject {{"key", "value"}, {"otherKey", 123}, {"thirdKey", false}};

        //JSONObject overrides ToString() and outputs valid JSON
        Debug.Log("newObject.ToString() -> " + newObject.ToString());

        //JSONObjects support array accessors
        Debug.Log("newObject[\"key\"].Str -> " + newObject["key"].Str);

        //It also has a method to do the same
        Debug.Log("newObject.GetValue(\"otherKey\").ToString() -> " + newObject.GetValue("otherKey").ToString());

        //As well as a method to determine whether a key exists or not
        Debug.Log("newObject.ContainsKey(\"NotAKey\") -> " + newObject.ContainsKey("NotAKey"));

        //Elements can removed with Remove() and the whole object emptied with Clear()
        newObject.Remove("key");
        Debug.Log("newObject with \"key\" removed: " + newObject.ToString());

        newObject.Clear();
        Debug.Log("newObject cleared: " + newObject.ToString());
    }
 public static void DeleteAll()
 {
     jsonObject.Clear();
 }
Beispiel #16
0
 /// <summary>
 /// Clears the config variable, reset necessary variables too.
 /// </summary>
 public static void ConfigClear()
 {
     config.Clear();
     config = null;
     active = false;
 }