ToString() публичный Метод

public ToString ( ) : string
Результат string
 public void createAssetFromJSON(SimpleJSON.JSONNode doc)
 {
     Debug.Log("Create From JSON: " + doc.ToString());
     try {
         string     type     = doc[S.SA_TYPE].Value;
         Vector3    position = new Vector3(float.Parse(doc[S.SA_POSITION]["x"].Value), float.Parse(doc[S.SA_POSITION]["y"].Value), float.Parse(doc[S.SA_POSITION]["z"].Value));
         GameObject go       = (GameObject)Instantiate(Resources.Load <GameObject>("AssetsLibrary/" + type), position, transform.rotation);
         if (go.GetComponent <SyncedAsset>() == null)
         {
             Debug.LogError("Prefab missing Synched Asset");
         }
         else
         {
             go.GetComponent <SyncedAsset>().UpdateWithJSON(doc.ToString());
         }
         if (!Enum.IsDefined(typeof(AssetType), type))
         {
             Debug.Log("Type from JSON is not an AssetType");
             AddToTree(go, (AssetType)Enum.Parse(typeof(AssetType), "Other"));
         }
         else
         {
             AddToTree(go, (AssetType)Enum.Parse(typeof(AssetType), type));
         }
     }
     catch (Exception e)
     {
         Debug.Log(e.ToString());
     }
 }
Пример #2
0
    public IEnumerator assess(string p_action, JSONNode p_values, Action<JSONNode> callback)
    {
        print("--- assess action (" + p_action + ") ---");

        string putDataString =
            "{" +
                "\"action\": \"" + p_action + "\"" +
                ", \"values\": " + p_values.ToString() +
                "}";

        string URL = baseURL + "/gameplay/" + idGameplay + "/assessAndScore";

        WWW www = new WWW(URL, Encoding.UTF8.GetBytes(putDataString), headers);

        // wait for the requst to finish
        yield return www;

        JSONNode returnAssess = JSON.Parse(www.text);

        feedback = returnAssess["feedback"].AsArray;
        scores = returnAssess["scores"].AsArray;
        print("Action " + putDataString + " assessed! returned: " + returnAssess.ToString());
        foreach (JSONNode f in feedback)
        {
            // log badge
            if (string.Equals(f["type"], "BADGE"))
            {
                badgesWon.Add(f);
            }
        }

        callback(returnAssess);
    }
Пример #3
0
    public void saveData(JSONNode json, string dirName="", string fileName="")
    {
        if (dirName == "") {
            dirName = defaultDirName;
        }
        if (fileName == "") {
            fileName = defaultFileName;
        }

        Debug.Log ("Saving Data: " + json.ToString());

        if (!Directory.Exists (folderPath + dirName)) {
            Directory.CreateDirectory(folderPath + dirName);
        }
        string path = folderPath + dirName + "/" + fileName + ".json";

        Debug.Log ("Saving To: " + path);

        File.WriteAllText(path , json.ToString());
    }
Пример #4
0
 public static string base64ToJson(string paramBase64)
 {
     try
     {
         SimpleJSON.JSONNode node = SimpleJSON.JSONNode.LoadFromBase64(paramBase64);
         return(node.ToString());
     } catch (Exception ex)
     {
         DebugLogError(ex.Message);
         return(paramBase64);
     }
 }
Пример #5
0
    void WriteToFile()
    {
        //json
        SimpleJSON.JSONNode node = SimpleJSON.JSONNode.Parse(File.ReadAllText(Application.dataPath + "/data.json"));
        node ["version"]        = gameVersion;
        node["volume"].AsFloat  = volume;
        node ["levelmax"].AsInt = levelMax;
        File.WriteAllText(Application.dataPath + "/data.json", node.ToString());
        //test

        /*if (System.IO.File.Exists("myfile.txt"))
         * {
         *      //do stuff
         * }*/
    }
Пример #6
0
    /**
     * This function converts the requested stored gesture into a JSON string containing the gesture name and training data.
     *
     * Gestures exported using this function can be re-imported using the fromJSON function below.
     *
     * @param gestureName
     * @returns {String}
     */
    string toJSON(string gestureName)
    {
        var gestures = this.gestures[gestureName];


        SimpleJSON.JSONNode json = new SimpleJSON.JSONNode(),
                            name = new SimpleJSON.JSONNode(),
                            pose = new SimpleJSON.JSONNode(),
                            data = new SimpleJSON.JSONNode(),
                            x, y, z, stroke;

        foreach (var gesture in gestures)
        {
            SimpleJSON.JSONNode gesturePoints = new SimpleJSON.JSONNode();

            foreach (var point in gesture)
            {
                SimpleJSON.JSONNode pointComponents = new SimpleJSON.JSONNode();

                x      = new SimpleJSON.JSONNode(); x.AsFloat = point.x;
                y      = new SimpleJSON.JSONNode(); y.AsFloat = point.y;
                z      = new SimpleJSON.JSONNode(); z.AsFloat = point.z;
                stroke = new SimpleJSON.JSONNode(); stroke.AsFloat = point.stroke;

                pointComponents.Add("x", x);
                pointComponents.Add("y", y);
                pointComponents.Add("z", z);
                pointComponents.Add("stroke", stroke);

                gesturePoints.Add(pointComponents);
            }

            data.Add(gesturePoints);
        }


        name.Value  = gestureName;
        pose.AsBool = this.poses[gestureName];

        json.Add("name", name);
        json.Add("pose", pose);
        json.Add("data", data);

        return(json.ToString());
    }
Пример #7
0
        public override string ToString(string aPrefix)
        {
            string result = "[ ";
            int    count  = m_List.Count;

            for (int i = 0; i < count; i++)
            {
                JSONNode N = m_List [i];
                if (result.Length > 3)
                {
                    result += ", ";
                }
                result += "\n" + aPrefix + "   ";
                result += N.ToString(aPrefix + "   ");
            }
            result += "\n" + aPrefix + "]";
            return(result);
        }
Пример #8
0
        public override string ToString()
        {
            string result = "[ ";
            int    count  = m_List.Count;

            //foreach (JSONNode N in m_List)
            for (int i = 0; i < count; i++)
            {
                JSONNode N = m_List[i];
                if (result.Length > 2)
                {
                    result += ",\r\n";
                }
                result += N.ToString();
            }
            result += " ]\r\n";
            return(result);
        }
Пример #9
0
        public override string ToString()
        {
            string text = "[ ";

            using (List <JSONNode> .Enumerator enumerator = this.m_List.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    JSONNode current = enumerator.get_Current();
                    if (text.get_Length() > 2)
                    {
                        text += ", ";
                    }
                    text += current.ToString();
                }
            }
            text += " ]";
            return(text);
        }
Пример #10
0
    public void LoadEquipment(SimpleJSON.JSONArray ids)
    {
        if (ids == null || ids.Count == 0)
        {
            return;
        }
        var items = DataApi.Inst.equipment.All();

        for (int i = 0; i < ids.Count; i++)
        {
            SimpleJSON.JSONNode p    = ids[i];
            JsonObject          item = items[p.ToString()] as JsonObject;

            string filepath = "equipment/item_" + Convert.ToInt32(item["imgId"]);
            Debug.Log(filepath);
            //GameObject obj = (GameObject)Instantiate(Resources.Load(filepath));
            //SetLoadedCount(1);
            //SceneManager.MoveGameObjectToScene(obj, SceneManager.GetSceneByName("desert"));
        }
    }
Пример #11
0
 public void SaveConfig()
 {
     File.WriteAllText(modConfigFile, modConfig.ToString());
 }
Пример #12
0
 /// <summary>
 /// Encodes a set of key-value pairs into JSON string.
 /// </summary>
 public static string JsonEncode(JSONNode parameters)
 {
     return parameters.ToString ();
 }
Пример #13
0
	public IEnumerator getLeaderboard(int p_idSG)
	{
		print ("--- get Leader Board ---");
		
		string URL = baseURL + "/learninganalytics/leaderboard/seriousgame/" + p_idSG + "/version/" + version;
		
		WWW www = new WWW(URL);
		
		// wait for the requst to finish
		yield return www;

		leaderboard = JSON.Parse(www.text);
		print ("Leader board received! " + leaderboard.ToString());
	}
Пример #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Tiled.TileProperties"/> class.
        /// </summary>
        /// <param name="jsondata">Jsondata. A JSONNode from the Tiled2D export. </param>
        public TileProperties(JSONNode jsondata, int i)
        {
            this.index = i;
            this.primitive = "cube";
            this.collider = "None";
            if (jsondata.ToString ().Equals( "")) {
                this.back = i;
                this.bottom = i;
                this.top = i;
                this.left = i;
                this.right = i;
            } else {
                this.back = this.getProperty("back", jsondata);
                this.bottom = this.getProperty("bottom", jsondata);
                this.top = this.getProperty("top", jsondata);
                this.left = this.getProperty("left", jsondata);
                this.right = this.getProperty("right", jsondata);
                this.collider = jsondata["collider"];
            }

            Debug.Log ("Tile Properties Initialized");
            Debug.Log ("Back:  " + this.back);
        }
Пример #15
0
	public void Send(JSONNode data){
		SendString(data.ToString());
	}
Пример #16
0
	public void OnButtonDrawTenCards(){
		string[] storageJsonArray = new string[10];
		JSONNode j;
		Storage s = new Storage();
		bool[] isCounselors = new bool[10];
		int random;
		bool isRedraw = true;
		bool isMustRedraw = false;
		JSONClass json;
		int[] results = new int[10];
		do {
			isMustRedraw = false;
			for (int i=0; i<10; i++) {
				random = UnityEngine.Random.Range (1, numberOfCounselors + numberOfGenerals);
				isCounselors[i] = (random <= numberOfCounselors);
				//Debug.Log (random);
				results[i] = (isCounselors[i]) ? random : random - numberOfCounselors + 1000;
				s = new Storage (){productId= results[i], type =2, quantity =1}; //TODO: Personnel number instead of 0.
				if (isCounselors[i]){ 
					isRedraw = (counselorList[random-1].Rank != rankStopRedraw) ; // Make it false if any card Rank 6
					if (counselorList[random-1].Rank == rankNeedRedraw) isMustRedraw = true;
					storageJsonArray[i] = "{\"type\":"+results[i]+",\"level\":1}";
				}else{ // result == generals
					isRedraw = ( generalList[random-numberOfCounselors].Rank != rankStopRedraw); // Make it false if any card Rank 6
					if (generalList[random-numberOfCounselors].Rank == rankNeedRedraw) isMustRedraw = true;
					j = (JSONNode)s.toJSON ();
					storageJsonArray[i] = j.ToString();
				}
			}
		} while(isRedraw|| isMustRedraw);
		//string data = "["+ String.Join(" , ", storageJsonArray)+"]";
		json = new JSONClass ();
		for (int i = 0; i<10; i++) {
			json["data"]  = storageJsonArray [i];
			json["action"]="NEW";
			json["table"]= (isCounselors[i])? "counselors" : "storage" ;
			wsc.Send (json.ToString ());
		}

		json ["data"] = "";

	}
 public void SaveConfig()
 {
     //Debug.Log(":: Saving Config ::");
     //var newJson = JSON.ToJson(modConfig.ToString());
     File.WriteAllText(modConfigFile, modConfig.ToString());
 }
Пример #18
0
	public void OnButtonDrawSingleCard(){
		int random = UnityEngine.Random.Range (1, numberOfCounselors + numberOfGenerals);
		bool isCounselors = (random <= numberOfCounselors);
		int result = (isCounselors) ? random : random - numberOfCounselors + 1000;

		//Debug.Log ("Random Number: "+random);

		//Debug.Log ("Result Number: "+ result);

		Storage s = new Storage(){productId= result, type =2, quantity =1}; //TODO: Personnel number instead of 0.

		json = new JSONClass ();
		if (isCounselors) {
			json["data"].Add ("userId",new JSONData(game.login.id));
			json["data"].Add ("type" , new JSONData(result));
			json["data"].Add ("level", new JSONData(1));
		} else {
			json.Add ("data", (JSONNode)s.toJSON ());
			json["data"].Add ("userId",new JSONData (game.login.id));
		}
		if (isCounselors) {
			json ["action"] = "NEW";
			json ["table"] = (isCounselors) ? "counselors" : "storage";
			Debug.Log (json.ToString ());
			wsc.Send (json.ToString ());
		}
	}
Пример #19
0
	void Start(){


		json = new JSONClass ();
		json ["data"] = "3";

		json ["action"] = "GET";
		json ["table"] = "users";
		//json ["table"] = "private_chat_histories";
		//Debug.Log (json.ToString ());//{"action":"GET", "table":"users", "data":"3"}
		if (wsc.conn.IsAlive) {
			wsc.Send (json.ToString ()); 
		} else {
			Debug.Log ("Connection Lost!");
		}
	}
Пример #20
0
 private void SendMessage(JSONNode json)
 {
     byte[] message = Encoding.UTF8.GetBytes(json.ToString());
     mqttClient.Publish(mqttTopic, message, MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, false);
 }
Пример #21
0
	public IEnumerator getGameDesc(int p_idSG)
	{
		print ("--- get SG ---");
		
		string URL = baseURL + "/seriousgame/" + p_idSG + "/version/" + version;
		
		WWW www = new WWW(URL);
		
		// wait for the requst to finish
		yield return www;

		seriousGame = JSON.Parse(www.text);
		print ("Serious game detailed received! " + seriousGame.ToString());
	}
    /**
     * Parse json response from blockscan
     * call asset's function if same name asset are found in json response
     * */
    public void ParseJson(JSONNode jsonResponse)
    {
        //check if asset has been found at this address (bad format address?)
        if (jsonResponse == null) {
            Debug.Log ("no asset found at this address");
            return;
        }

        Debug.Log ("jsonReponse text: " + jsonResponse.ToString ());
        Debug.Log ("jsonResponse data count: " + jsonResponse ["data"].Count);

        //store number of asset found in json response
        int nbrOfAsset = jsonResponse ["data"].Count;

        //iterate to check if asset name are the same in assetName array and asset from json response
        for (int i = 0; i < nbrOfAsset; i++) {
            for (int y = 0; y < assetName.Length; y++){
                if (jsonResponse ["data"] [i] ["asset"].Value == assetName[y]){
                    string methodName = "Asset"+i;

                    //Get the method information using the method info class
                    MethodInfo mi = this.GetType().GetMethod(methodName);

                    //Invoke the method Asset1, Asset2, etc..
                    var arguments = new object[] { y };
                    mi.Invoke(this, arguments);
                }
            }
            Debug.Log ("asset name: " + jsonResponse ["data"] [i] ["asset"].Value);
            Debug.Log ("asset balance: " + jsonResponse ["data"] [i] ["balance"].Value);
        }
    }