Наследование: JSONNode, IEnumerable
Пример #1
0
    /// <summary>基础信息录入 - 建筑信息(按区块为单位上传)</summary>
    public static void UploadBlockInfo(string block_id, string buildings_sinfo, Action <string> callback, Action <HttpResp.ErrorType, string> failCallback = null)
    {
        var jclass = new SimpleJSON.JSONClass();

        jclass["block_id"]       = block_id;
        jclass["buildings_info"] = buildings_sinfo;
        string strJson = jclass.ToString();

        WWWManager.Instance.Post("block_details/update_detail", strJson, resp =>
        {
            if (!HasRespError(resp))
            {
                callback(resp.WwwText);
            }
            else
            {
                if (failCallback != null)
                {
                    failCallback(resp.Error, resp.WwwText);
                }
                else
                {
                    Debug.LogError("ERROR: " + resp.Error + ", " + resp.WwwText);
                }
            }
        });
    }
Пример #2
0
        public JSONClass GetJsonStatus()
        {
            var sj = new SimpleJSON.JSONClass();

            var jsonObj = new JSONClass();

            jsonObj.Add("id", new JSONData(id));
            if (mSocket != null)
            {
                var ip = mSocket.RemoteEndPoint as IPEndPoint;
                jsonObj.Add("ip", new JSONData(ip.ToString()));
                jsonObj.Add("Active", new JSONData("true"));
                jsonObj.Add("ReceivePackets", new JSONData(mReceivePacketCount));
                jsonObj.Add("ReceivePacketsSize", new JSONData(mReceivePacketSizeCount));
                jsonObj.Add("SendPackets", new JSONData(mSendPacketCount));
                jsonObj.Add("SendPacketsSize", new JSONData(mSendPacketSizeCount));
                jsonObj.Add("MsgQueueLength", new JSONData(msgBuffer.Count));
            }
            else
            {
                jsonObj.Add("Active", new JSONData("false"));
            }

            sj.Add("Agent", jsonObj);
            return(sj);
        }
Пример #3
0
    public void addGameVersion(string id)
    {
        JSONClass json = new JSONClass ();
        json.Add ("gameId", id);

        net.POST (url + "/" + id + "/versions" , System.Text.Encoding.UTF8.GetBytes (json.ToString ()), trackHeaders, new GameVersionCreatorListener ());
    }
Пример #4
0
	public void sendAction() {

		GetComponent<Animator>().Play("Click");

		if (buttonType == FLOOR_BUTTON_TYPE.YES || buttonType == FLOOR_BUTTON_TYPE.NO) {

			GameObject.Find("Debug Text").GetComponent<Text>().text += "Setting Position \n";

			HTTPRequest request = new HTTPRequest(new Uri("http://run-west.att.io/d9576f027ee8f/6e9234f387c9/9c7023eee2b3b23/in/flow/action"), HTTPMethods.Put, actionSentCallback);

			JSONClass data = new JSONClass();

			data["value"] = ((int)buttonType).ToString();

			request.AddHeader("Content-Type", "application/json");
			//request.AddHeader("X-M2X-KEY", "9fc7996ea7f03fccc6ef3978f2a4d012");
			request.RawData = Encoding.UTF8.GetBytes(data.ToString());
			request.Send();
		} else {

			HTTPRequest request = new HTTPRequest(new Uri("http://run-west.att.io/d9576f027ee8f/6e9234f387c9/9c7023eee2b3b23/in/flow/dlswitch"), HTTPMethods.Put, actionSentCallback);

			JSONClass data = new JSONClass();

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

			request.AddHeader("Content-Type", "application/json");
			//request.AddHeader("X-M2X-KEY", "9fc7996ea7f03fccc6ef3978f2a4d012");
			request.RawData = Encoding.UTF8.GetBytes(data.ToString());
			request.Send();
		}



	}
Пример #5
0
        public void readHosts()
        {
            string path = Application.persistentDataPath;

            if (!path.EndsWith("/"))
            {
                path += "/";
            }

            PlayerPrefs.Save();
            //PlayerPrefs.DeleteAll();

            SimpleJSON.JSONNode hostfile = new SimpleJSON.JSONClass();

#if !(UNITY_WEBPLAYER || UNITY_WEBGL)
            if (!System.IO.File.Exists("host.cfg"))
            {
                hostfile.Add("host", new SimpleJSON.JSONData("http://localhost:3000/api/proxy/gleaner/collector/"));
                hostfile.Add("trackingCode", new SimpleJSON.JSONData("asdasdasdasda"));
                System.IO.File.WriteAllText("host.cfg", hostfile.ToString());
            }
            else
            {
                hostfile = SimpleJSON.JSON.Parse(System.IO.File.ReadAllText("host.cfg"));
            }
#endif

            PlayerPrefs.SetString("host", hostfile["host"]);
            PlayerPrefs.SetString("trackingCode", hostfile["trackingCode"]);
            PlayerPrefs.Save();


            //End tracker data loading
        }
	private void ConfirmConnectionOut(string id){
		JSONNode data = new JSONClass();
		data["function"] = "Confirm";
		data["id"] = id;

		udpSend.Send(data);
	}
Пример #7
0
    static void ExportResource()
    {
        int StageNum = 1;
        string fileName = "Stage" + StageNum + ".json";

        Transform tf = GameObject.Find("BlockRoot").transform;

        string seedString = "{\"blocks\":[]}";

        JSONNode node = JSON.Parse(seedString);

        Transform[] arTF = tf.GetComponentsInChildren<Transform>();
        for (int i = 1; i < arTF.Length; i++)
        {
            Transform subtf = arTF[i];

            JSONClass subNode = new JSONClass();

            subNode.Add("type", "Normal");
            subNode.Add("posX", subtf.position.x + "");
            subNode.Add("posY", subtf.position.y + "");

            node["blocks"][-1] = subNode;
        }

        Debug.Log(node.ToString());
        writeStringToFile(node.ToString(), fileName);
    }
Пример #8
0
    public static void UpdateBuildingInfo(string _strBlockName, string _strNodeGUID, string _strJsData, Action <string> sCb, Action <string> fCb,
                                          SingleTargetType _sType = SingleTargetType.Building)
    {
        var jclass = new SimpleJSON.JSONClass();

        jclass["block_name"] = _strBlockName;
        jclass["build_guid"] = _strNodeGUID;
        jclass["info"]       = _strJsData;
        string strJson = jclass.ToString();

        string strPort = "building_infos/upsert";

        Debug.LogWarning("更新,发送的Js:\n" + _strJsData);
        Debug.LogWarning(string.Format("更新:地块ID:{0}\n建筑gID:{1}", _strBlockName, _strNodeGUID));

        WWWManager.Instance.Post(strPort, strJson, resp =>
        {
            if (!HasRespError(resp))
            {
                sCb(resp.ToString());
            }
            else
            {
                Debug.LogError(string.Format("更新建筑基础信息:{0},失败:{1}", _strNodeGUID, resp.WwwText));

                fCb(resp.WwwText);
            }
        });
    }
Пример #9
0
    public static void UploadStreet(string city_name, JSONNode city_info, Action <string> callback, Action <HttpResp.ErrorType, string> failCallback = null)
    {
        var jclass = new SimpleJSON.JSONClass();

        jclass["name"] = city_name;
        jclass["info"] = city_info.ToString();
        string strJson = jclass.ToString();

        WWWManager.Instance.Post("roads/new_road", strJson, resp =>
        {
            if (!HasRespError(resp))
            {
                callback(resp.WwwText);
            }
            else
            {
                if (failCallback != null)
                {
                    failCallback(resp.Error, resp.WwwText);
                }
                else
                {
                    Debug.LogError("修改街道失败: " + resp.Error + ", " + resp.WwwText);
                }
            }
        });
    }
Пример #10
0
    public static void UploadCity(string city_id, string city_name, string prov_id, string isHot, string j_city_id, JSONNode birth_coordinate, Action <string> callback, Action <HttpResp.ErrorType, string> failCallback = null)
    {
        var jclass = new SimpleJSON.JSONClass();

        jclass["name"]       = city_name;
        jclass["city"]       = city_id;
        jclass["prov_id"]    = prov_id;
        jclass["j_city_id"]  = j_city_id;
        jclass["is_hotcity"] = isHot;
        if (birth_coordinate != null)
        {
            jclass["birth_coordinate"] = birth_coordinate.ToString();
        }
        string strJson = jclass.ToString();

        WWWManager.Instance.Post("cities/update_city", strJson, resp =>
        {
            if (!HasRespError(resp))
            {
                callback(resp.WwwText);
            }
            else
            {
                if (failCallback != null)
                {
                    failCallback(resp.Error, resp.WwwText);
                }
                else
                {
                    Debug.LogError("ERROR: " + resp.Error + ", " + resp.WwwText);
                }
            }
        });
    }
Пример #11
0
	//JSON Format:

	/*
	{
		"session": {
			"id": "session1234",
			"player": "user123",
			"game": "game1",
			"version": "version 1.0"
		},
		
		"play_events" :
		[ 
		{  "time": "2015-02-17T22:43:45-5:00", "event": "PowerUp.FireBall", "value": "1.0", "level": "1-1"},
		{  "time": "2015-02-17T22:45:45-5:00", "event": "PowerUp.Mushroom", "value": "2.0", "level": "1-1"}
		 ]
	}
	*/

	public static string ToJSON(Gloggr_Report r)
	{
	
		JSONNode n = new JSONClass();
		
		
		
		n.Add ("session",  Gloggr_SessionHeader.ToJSONObject(r.session)  );
		
		JSONArray a = new JSONArray();
		
		foreach(Gloggr_PlayEvent e in r.play_events)
		{
			a.Add(Gloggr_PlayEvent.ToJSONObject(e));
		}
		
		n.Add ("play_events", a);
		
		return n.ToString();	
	
//		string json = JsonConvert.SerializeObject(e, Formatting.Indented);
//		//from Gloggr_SessionHeader.ToJSON
//		//json = Gloggr_SessionHeader.FormatJSONKeys(json);
//		//from Gloggr_PlayEvent.ToJSON
//		//json = Gloggr_PlayEvent.FormatJSONKeys(json);
//		return json;
	}
 public void OnException(Exception e)
 {
     ServiceAPI sp = AppConstant.GetServce();
     JSONClass json = new JSONClass();
     json.Add("userId",FB.UserId);
     json.Add("userName",AppConstant.GetUserName());
     AppConstant.GetStorageService(sp).InsertJSONDocument(AppConstant.DBName, AppConstant.CollectionName,json,this);
 }
Пример #13
0
    static JSONNode GenerateLaunchConfiguration(int port)
    {
        JSONNode N = new JSONClass();
        N["version"] = "0.1.0";
        N["configurations"][-1] = GenerateUnityConfiguration(port);

        return N;
    }
Пример #14
0
    public void addGame(string title, bool ispublic)
    {
        JSONClass json = new JSONClass ();
        json.Add ("title", new JSONData (title));
        json.Add ("public", new JSONData (ispublic));

        net.POST (url, System.Text.Encoding.UTF8.GetBytes (json.ToString ()), trackHeaders, new GameCreatorListener ());
    }
Пример #15
0
 public Dictionary<string, string> GetDictionary(JSONClass N)
 {
     Dictionary<string, string> d = new Dictionary<string, string>();
     foreach (string key in N.GetKeys()) {
         d.Add(key, N[key]);
     }
     return d;
 }
Пример #16
0
    public void login(string user, string pass)
    {
        JSONClass json = new JSONClass ();
        json.Add ("username", new JSONData (this.user));
        json.Add ("password", new JSONData (this.pass));

        www = net.POST (baseurl + loginurl, System.Text.Encoding.UTF8.GetBytes (json.ToString ()), trackHeaders, new LoginListener ());
    }
	public void ConnectToServerOut(){
		JSONNode data = new JSONClass();

		data["function"] = "Connect";
		data["id"] = id;

		udpSend.Send(data);
	}
Пример #18
0
 public override string ToString()
 {
     JSONClass json = new JSONClass();
     json["uri"] = Uri;
     json["complete_uri"] = CompleteUri;
     json["ticket_id"] = TicketId;
     json["upload_link_secure"] = UploadLinkSecure;
     return json;
 }
Пример #19
0
 public static byte[] BuildMessageBytes_Move( string piece, int gbi )
 {
     SimpleJSON.JSONClass moveObj = new SimpleJSON.JSONClass();
     moveObj.Add("gridBoxIndex", gbi);
     moveObj.Add("sender", AppWarp.localusername);
     moveObj.Add("piece", piece);
     moveObj.Add("type", "move");
     return System.Text.Encoding.UTF8.GetBytes(moveObj.ToString());
 }
Пример #20
0
    public static byte[] BuildBytes_NewMatch()
    {
        SimpleJSON.JSONClass obj = new SimpleJSON.JSONClass();
        obj.Add("sender", AppWarp.localusername);
        obj.Add("type", "new_match");

        byte[] retVal = System.Text.Encoding.UTF8.GetBytes(obj.ToString());
        return retVal;
    }
Пример #21
0
    public static byte[] BuildMessageBytes_OppName()
    {
        SimpleJSON.JSONClass obj = new SimpleJSON.JSONClass();
        obj.Add("sender", AppWarp.localusername);
        obj.Add("type", "oppName");

        byte[] retVal = System.Text.Encoding.UTF8.GetBytes(obj.ToString());
        return retVal;
    }
Пример #22
0
 public Dictionary<string, float> GetDictionaryFloat(JSONClass N)
 {
     Dictionary<string, string> d = this.GetDictionary(N);
     Dictionary<string, float> df = new Dictionary<string, float>();
     foreach(KeyValuePair<string, string> keyValuePair in d){
         df[keyValuePair.Key] = float.Parse(keyValuePair.Value);
     }
     return df;
 }
Пример #23
0
 override public void OnMenuOpened()
 {
     SimpleJSON.JSONClass N = LevelBuilder.inst.currentPiece.GetComponent <UserEditableObject>().GetProperties();
     if (N.GetKeys().Contains(LinkLevelPortalPipe.linkLevelKey))
     {
         levelCodeText.text = N[LinkLevelPortalPipe.linkLevelKey][LinkLevelPortalPipe.portalDestinationKey].Value;
         levelNameText.text = N[LinkLevelPortalPipe.linkLevelKey][LinkLevelPortalPipe.portalNameKey].Value;
     }
 }
	public void MoveOut(float x, float y){
		JSONNode data = new JSONClass();

		data["function"] = "move";
		data["id"] = id;
		data["x"].AsFloat = x;
		data["y"].AsFloat = y;
	
		udpSend.Send(data);
	}
Пример #25
0
        void DisableRating()
        {
            JSONNode data = new JSONClass();
            data = JSON.Parse(EditorPrefs.GetString(keyName));

            data["active"].AsBool = false;
            data["counter"].AsInt = 0;
            EditorPrefs.SetString(keyName, data.ToString());
            this.Close();
        }
Пример #26
0
 public override JSONNode ToJSON(Tile tile)
 {
     JSONNode node = new JSONClass ();
     node ["x"].AsInt = tile.position.x;
     node ["y"].AsInt = tile.position.y;
     node ["type"] = GetType ();
     node ["name"] = name;
     node ["description"] = description;
     return node;
 }
Пример #27
0
 public override JSONNode ToJSON(Tile tile)
 {
     JSONNode node = new JSONClass ();
     node ["x"].AsInt = tile.position.x;
     node ["y"].AsInt = tile.position.y;
     node ["type"] = GetType ();
     node ["text"] = tile.text;
     node ["color"] = Util.Color.ColorToHex(tile.color);
     return node;
 }
Пример #28
0
    void UpdateAI(JSONClass packet)
    {
    
        Debug.Log("Received packet: " + packet.ToString());
        xCoord = packet["x"].AsFloat;
        yCoord = packet["y"].AsFloat;
        angleFacing = packet["facing"].AsFloat;
        Vector2 newPos = new Vector2(xCoord, yCoord);

        transform.rotation = Quaternion.AngleAxis((float)angleFacing, Vector3.forward);
    }
	public static JSONNode ToJSONObject(Gloggr_SessionHeader e)
	{
		
		JSONNode n = new JSONClass();
		
		n.Add ("id", new JSONData( e.gSessionID));
		n.Add ("player", new JSONData(e.gPlayer));
		n.Add ("game", new JSONData(e.gGameName));
		n.Add ("version", new JSONData(e.gVersion));
		
		return n;
	}
	public static JSONNode ToJSONObject(Gloggr_PlayEvent e)
	{
		JSONNode n = new JSONClass();
		
		n.Add ("time", new JSONData( e.gTime));
		n.Add("event", new JSONData(e.gEvent));
		n.Add("value", new JSONData(e.gValue));
		n.Add("position", new JSONData(e.gPosition));
		n.Add("level", new JSONData(e.gLevel));
		
		return n;
	}
Пример #31
0
    static JSONClass GenerateUnityConfiguration(int port)
    {
        JSONClass conf = new JSONClass();

        conf["name"] = "Unity";
        conf["type"] = "mono";
        conf["address"] = "localhost";
        conf["port"].AsInt = port;
        conf["sourceMaps"].AsBool = false;

        return conf;
    }
Пример #32
0
    void LoadLevelData(JSONClass levelData)
    {
        foreach (KeyValuePair<string, JSONNode> kv in levelData) {
            var coords = kv.Key;
            var tile = GameObject.Find(string.Format("({0})", coords));

            var obj = kv.Value.Value;

            var prefab = registry.Get(obj);
            var go = Instantiate(prefab);
            go.transform.position = tile.transform.position;
        }
    }
Пример #33
0
        static void Startup()
        {
            EditorApplication.update -= Startup;

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

            Count();
        }
    void took_damage(JSONClass packet)
    {
        baseClass.ClassStat.CurrentHp = packet["NewHP"].AsFloat;

        GameManager.instance.PlayerTookDamage(playerID, packet["NewHP"].AsFloat, baseClass.ClassStat);

        if (baseClass.ClassStat.CurrentHp <= 0.0f)
        {
            NetworkingManager.Unsubscribe(DataType.Player, playerID);
            GameData.PlayerPosition.Remove(playerID);
            Destroy(gameObject);
        }
    }
Пример #35
0
        public string connectToDb()
        {
            //make sure all the paramter has something
            if (!System.String.IsNullOrEmpty(function) && !System.String.IsNullOrEmpty(url) && parameterList.Count > 0 && valueList.Count > 0)
            {
                WebClient webClient = new WebClient();
                NameValueCollection formData = new NameValueCollection();
                var sendJSON = new JSONClass();

                //get the values to be sent to backend
                for (int i=0; i < parameterList.Count;i++)
                {
                    string key = (string)parameterList[i];
                    sendJSON["info"][key] = (string)valueList[i];
                }

                //send to backend
                sendJSON["function"] = this.function;
                formData["send"] = sendJSON.ToString();
                byte[] responseBytes = webClient.UploadValues(this.url, "POST", formData);
                string responsefromserver = Encoding.UTF8.GetString(responseBytes);
                Debug.Log(responsefromserver);

                //parse the return values
                var returnValue = JSONNode.Parse(responsefromserver);
                int error = Convert.ToInt32(returnValue["error"]);

                if (error != -1)
                {
                    //if got error, parse it and return the appropriate error message
                    string errorString = this.parseError(error);
                    return errorString;

                } else {

                    //if no error, return "SUCCESS NO RETURN" if only "TRUE" is returned by backend
                    this.jsonReturn = returnValue["result"][0].ToString();
                    if (String.Compare(this.jsonReturn, "\"TRUE\"") == 0)
                    {
                        return "SUCCESS NO RETURN";
                    } else {
                        return "SUCCESS";
                    }
                }

                //return "";

            }

            return "you did not insert a function/parameter/value";
        }
Пример #36
0
 override public void SetObjectProperties()
 {
     // commented Debug.Log("setting obj properties for portal:");
     if (levelCodeText.text.Length == 0 || levelNameText.text.Length == 0)
     {
         return;
     }
     base.SetObjectProperties();
     SimpleJSON.JSONClass N = new SimpleJSON.JSONClass();
     N[LinkLevelPortalPipe.linkLevelKey][LinkLevelPortalPipe.portalDestinationKey] = levelCodeText.text;
     N[LinkLevelPortalPipe.linkLevelKey][LinkLevelPortalPipe.portalNameKey]        = levelNameText.text;
     LevelBuilder.inst.currentPiece.GetComponent <UserEditableObject>().SetProperties(N);
     // commented Debug.Log("success, N:"+N.ToString());
 }
Пример #37
0
    public static Trigger LoadFromJson(JSONClass p_json)
    {
        try {
            TileType tile_type = TileType.LoadFromValue (Util.getValue<string> (p_json, "type"));
            ETileScope scope = Util.parseEnum<ETileScope> (Util.getValue<string> (p_json, "scope"));
            ETileWhen when = Util.parseEnum<ETileWhen> (Util.getValue<string> (p_json, "when"));
            Effect effect = new Effect (Util.parseEnum<ETileResource> (p_json ["effect"] ["resource"].Value),
                                        p_json ["effect"] ["value"].AsInt);

            return new Trigger (scope, when, tile_type, effect);
        } catch (ArgumentException) {
            Debug.LogError ("Error while trying to load trigger");
            return null;
        }
    }
Пример #38
0
    public void OnMenuOpened()
    {
//		// commented Debug.Log("setter opened");
        SimpleJSON.JSONClass N = LevelBuilder.inst.currentPiece.GetComponent <UserEditableObject>().GetProperties();
        if (N.GetKeys().Contains(PlaceableNPC.speechKey))
        {
//			// commented Debug.Log("got n and st:"+N.ToString());
            string s = Utils.FakeToRealQuotes(N[PlaceableNPC.speechKey].Value);             // hm.. Some keys appear to be in Json LevelLoader also.

            speech.text = s;
        }
        else
        {
        }
    }
Пример #39
0
		public override JSONClass getDataClass ()
		{
				JSONClass jClass = new JSONClass ();

				for (int i = 0; i < names.Count; i++) {
						string name = names [i];
						jClass ["names"] [i] = name;
				}

				for (int i = 0; i < scores.Count; i++) {
						int score = scores [i];
						jClass ["scores"] [i].AsInt = score;
				}
		
				return jClass;
		}
Пример #40
0
        public override void setClassData(SimpleJSON.JSONClass jClass)
        {
            this.myData.setPalette(jClass);

/*						for (int i = 0; i < this.myData.percentages.Length; i++) {
 *                                                              Debug.Log (i + " % is " + this.myData.percentages [i]);
 *                                              }
 */
/*						int size = jClass ["colors"].Count;
 *
 *                                              string[] hexArray = new string[size];
 *
 *                                              for (int i = 0; i < size; i++) {
 *                                                              hexArray [i] = jClass ["colors"] [i];
 *                                              }
 *
 *                                              myData.colors = JSONPersistor.getColorsArrayFromHex (hexArray);
 *
 *
 *                                              size = jClass ["alphas"].Count;
 *
 *                                              // if the size of the file is different than the standard size -> init()
 *                                              if (myData.alphas.Length != size) {
 *                                                              myData.alphas = new float[size];
 *                                              }
 *
 *                                              for (int i = 0; i < size; i++) {
 *                                                              float alphaValue = jClass ["alphas"] [i].AsFloat;
 *                                                              myData.alphas [i] = alphaValue;
 *                                                              myData.colors [i].a = alphaValue;
 *                                              }
 *
 *                                              size = jClass ["percentages"].Count;
 *
 *                                              // if the size of the file is different than the standard size -> init()
 *                                              if (myData.percentages.Length != size) {
 *                                                              myData.percentages = new float[size];
 *                                              }
 *
 *                                              for (int i = 0; i < size; i++) {
 *                                                              myData.percentages [i] = jClass ["percentages"] [i].AsFloat;
 *                                              }
 *
 *                                              myData.totalWidth = jClass ["totalWidth"].AsFloat;*/
        }
Пример #41
0
    /// <summary>
    /// 保存到JSON文件
    /// </summary>
    public void SaveWayPointMethod()
    {
        var pathes = wayPoint.GetComponentsInChildren <iTweenPath>();
        var result = new SimpleJSON.JSONClass();

        foreach (var p in pathes)
        {
            var obj = new JSONClass();
            obj["name"] = p.name;
            var jarr = new JSONArray();
            obj["nodes"] = jarr;
            var nodes = p.nodes;
            foreach (var n in nodes)
            {
                var varr = new JSONArray();
            }
        }
    }
    public override void SetObjectProperties()
    {
        if (speech.text.Length == 0)
        {
            return;
        }
        base.SetObjectProperties();
        SimpleJSON.JSONClass N = new SimpleJSON.JSONClass();
        N[PlayerNowMessageTrigger.textTriggerKey] = speech.text;         // hm.. Some keys appear to be in JsonLevelLoader also.
//		// commented Debug.Log("props:"+props+" on:"+);
        if (LevelBuilder.inst.currentPiece)
        {
            LevelBuilder.inst.currentPiece.GetComponent <UserEditableObject>().SetProperties(N);
        }
        else
        {
//			// commented Debug.Log("whoops, tried to set object properties for speech without a current.");
        }
    }
Пример #43
0
        public void Save()
        {
            var path = GetFilePath();

            if (Application.isEditor && !Application.isPlaying)
            {
                var simvaconf = new SimpleJSON.JSONClass();
                simvaconf["study"]         = Study;
                simvaconf["host"]          = Host;
                simvaconf["protocol"]      = Protocol;
                simvaconf["port"]          = Port;
                simvaconf["sso"]           = SSO;
                simvaconf["client_id"]     = ClientId;
                simvaconf["url"]           = URL;
                simvaconf["trace_storage"] = TraceStorage.ToString();
                simvaconf["backup"]        = Backup.ToString();
                simvaconf["realtime"]      = Realtime.ToString();
                System.IO.File.WriteAllText(path, simvaconf.ToJSON(4));
            }
        }
Пример #44
0
    /// <summary>
    /// Update City Information
    /// </summary>
    /// <param name="_strCityName"></param>
    /// <param name="_strJsData"></param>
    /// <param name="sCb"></param>
    /// <param name="fCb"></param>
    public static void UpdateCityInfo(string _strCityName, string _strJsData, Action sCb, Action <HttpResp.ErrorType, string> fCb)
    {
        var jclass = new SimpleJSON.JSONClass();

        jclass["name"]       = _strCityName;
        jclass["block_file"] = _strJsData;
        string strJson = jclass.ToString();

        WWWManager.Instance.Post("cities/update_city", strJson, resp =>
        {
            if (!HasRespError(resp))
            {
                sCb();
            }
            else
            {
                fCb(resp.Error, resp.WwwText);
            }
        });
    }
Пример #45
0
    /// <summary>
    /// 批量删除组件
    /// </summary>
    /// <param name="_strNames">组件ID字符串</param>
    /// <param name="_cb"></param>
    public static void DeleteCompConfig(string _strNames, Action <bool, HttpResp> _cb)
    {
        // 转为json
        var jclass = new SimpleJSON.JSONClass();

        jclass["name_list"] = _strNames;

        WWWManager.Instance.Post("components/drop_by_list", jclass.ToString(), resp =>
        {
            Debug.Log("删除结果返回:" + resp.WwwText);
            if (!HasRespError(resp))
            {
                _cb(true, resp);
            }
            else
            {
                _cb(false, resp);
            }
        });
    }
Пример #46
0
        public override string ToString()
        {
            var sj = new SimpleJSON.JSONClass();

            var jsonObj = new JSONClass();

            jsonObj.Add("AgentCount", new JSONData(AgentCount));

            var jsonArray = new JSONArray();

            lock (agents)
            {
                foreach (var agent in agents)
                {
                    jsonArray.Add("Agent", agent.Value.GetJsonStatus());
                }
            }
            jsonObj.Add("Agents", jsonArray);
            sj.Add("AgentStatus", jsonObj);
            return(sj.ToString());
        }
Пример #47
0
    /// <summary>
    /// 保存组件配置
    /// </summary>
    /// <param name="_strName"></param>
    /// <param name="_strInfo"></param>
    /// <param name="_cb"></param>
    public static void SaveCompConfig(string _strName, string _strInfo, Action <bool, HttpResp> _cb)
    {
        // 转为json
        var jclass = new SimpleJSON.JSONClass();

        jclass["name"] = _strName;
        jclass["info"] = _strInfo;


        WWWManager.Instance.Post("components/set_info", jclass.ToString(), resp =>
        {
            if (!HasRespError(resp))
            {
                _cb(true, resp);
            }
            else
            {
                _cb(false, resp);
            }
        });
    }
Пример #48
0
    /// <summary>
    /// 保存临时数据接口
    /// </summary>
    /// <param name="_strName"></param>
    /// <param name="_strType"></param>
    /// <param name="_strInfo"></param>
    /// <param name="_cb"></param>
    public static void SaveTempData(string _strName, string _strType, string _strInfo, Action <bool, HttpResp> _cb)
    {
        // 转为json
        var jclass = new SimpleJSON.JSONClass();

        jclass["name"] = _strName;
        jclass["type"] = _strType;
        jclass["info"] = _strInfo;

        WWWManager.Instance.Post("temp_buildings/set_info", jclass.ToString(), resp =>
        {
            if (!HasRespError(resp))
            {
                _cb(true, resp);
            }
            else
            {
                _cb(false, resp);
            }
        });
    }
Пример #49
0
    //Save each object properties to a JSON file

    /* JSON format:
     *      {
     *              "ObjectN": {
     *                      "Position" : {
     *                              "x" : Double,
     *                              "y": Double,
     *                              "z" : Double
     *                      },
     *                      "Rotation" : {
     *                              "x" : Double,
     *                              "y": Double,
     *                              "z" : Double
     *                      },
     *                      "Scale" : {
     *                              "x" : Double,
     *                              "y": Double,
     *                              "z" : Double
     *                      },
     *                      "Name" : String
     *              }
     *      }
     */
    private void SaveSceneToFile(string mazeName, List <ObjectSet> mazeSet)
    {
        SimpleJSON.JSONNode mazeJSON = new SimpleJSON.JSONClass();

        int i = 0;

        foreach (ObjectSet mazeObj in mazeSet)
        {
            //Debug.Log (mazeObj.name + " " + mazeObj.postion + " " + mazeObj.rotation + " " + mazeObj.scale);

            string objectName = "Object" + i;

            //JSON Format, creates the JSON format through the mazeJSON Node
            mazeJSON[objectName]["Position"]["x"].AsDouble = mazeObj.position.x;
            mazeJSON[objectName]["Position"]["y"].AsDouble = mazeObj.position.y;
            mazeJSON[objectName]["Position"]["z"].AsDouble = mazeObj.position.z;

            mazeJSON[objectName]["Rotation"]["x"].AsDouble = mazeObj.rotation.x;
            mazeJSON[objectName]["Rotation"]["y"].AsDouble = mazeObj.rotation.y;
            mazeJSON[objectName]["Rotation"]["z"].AsDouble = mazeObj.rotation.z;

            mazeJSON[objectName]["Scale"]["x"].AsDouble = mazeObj.scale.x;
            mazeJSON[objectName]["Scale"]["y"].AsDouble = mazeObj.scale.y;
            mazeJSON[objectName]["Scale"]["z"].AsDouble = mazeObj.scale.z;

            mazeJSON[objectName]["State"].AsInt = mazeObj.toggleState;

            mazeJSON[objectName]["Name"] = mazeObj.name;

            i++;
        }

        string fileDest = "Assets/Resources/Mazes/" + mazeName + ".txt";

        File.WriteAllText(fileDest, mazeJSON.ToString()); //Writes the JSON file

        UnityEditor.AssetDatabase.Refresh();              //Refresh the Editor, making changes immeadiate
    }
    public void OnMenuOpened()
    {
//		// commented Debug.Log("setter opened");
        SimpleJSON.JSONClass N = LevelBuilder.inst.currentPiece.GetComponent <UserEditableObject>().GetProperties();
        if (N.GetKeys().Contains(PlayerNowMessageTrigger.textTriggerKey))
        {
//			// commented Debug.Log("got n and st:"+N.ToString());
            string s = N[PlayerNowMessageTrigger.textTriggerKey].Value;             // hm.. Some keys appear to be in JsonLevelLoader also.
//			s = Regex.Unescape(s);
            s           = Utils.FakeToRealQuotes(s);
            speech.text = s;
        }
        else
        {
//			string keylist="";
//			N.GetKeys
//			foreach(string s in N.GetKeys()){
//				// commented Debug.Log("key:L"+s);
////				// commented Debug.Log("kvkp:"+kvp.Key+","+kvp.Value.ToString());
//			}
//			// commented Debug.Log("missed key:"+PlaceableNPC.speechKey+" in :"+N.ToString());
        }
    }
Пример #51
0
    public static void DeleteSingleBuildingInfoByJson(string _strBlockName, string _strGUID, Action sCb, Action <string> fCb)
    {
        var jclass = new SimpleJSON.JSONClass();

        jclass["block_name"] = _strBlockName;
        jclass["build_guid"] = _strGUID;
        string strJson = jclass.ToString();

        string strPort = "building_infos/delete";

        WWWManager.Instance.Post(strPort, strJson, resp =>
        {
            if (!HasRespError(resp))
            {
                sCb();
            }
            else
            {
                Debug.LogWarning(string.Format("删除:{0},失败:{1}", strPort, resp.Error));
                fCb(resp.WwwText);
            }
        });
    }
Пример #52
0
        public void ReadHosts()
        {
            string path = Application.persistentDataPath;

            if (!path.EndsWith("/"))
            {
                path += "/";
            }

            PlayerPrefs.Save();
            //PlayerPrefs.DeleteAll();

            SimpleJSON.JSONNode hostfile = new SimpleJSON.JSONClass();

            /*
             #if !(UNITY_WEBPLAYER || UNITY_WEBGL)
             * if (!System.IO.File.Exists("host.cfg"))
             * {
             *  hostfile.Add("host", new SimpleJSON.JSONData("https://analytics-test.e-ucm.es/api/proxy/gleaner/collector/"));
             *  hostfile.Add("trackingCode", new SimpleJSON.JSONData("5be4222305ea050083483aa8izpp9w59eji"));
             *  System.IO.File.WriteAllText("host.cfg", hostfile.ToString());
             * }
             * else
             *  hostfile = SimpleJSON.JSON.Parse(System.IO.File.ReadAllText("host.cfg"));
             #endif
             *
             * PlayerPrefs.SetString("host", hostfile["host"]);
             * PlayerPrefs.SetString("trackingCode", hostfile["trackingCode"]);
             * PlayerPrefs.Save();*/

            PlayerPrefs.SetString("host", "https://analytics-test.e-ucm.es/api/proxy/gleaner/collector/");
            PlayerPrefs.SetString("trackingCode", "5be4222305ea050083483aa8izpp9w59eji");
            PlayerPrefs.Save();


            //End tracker data loading
        }
Пример #53
0
        public override string ToString()
        {
            var sj = new SimpleJSON.JSONClass();

            var jsonObj = new JSONClass();

            KeyValuePair <int, Actor>[] ad;
            lock (actorDict)
            {
                ad = actorDict.ToArray();
            }

            jsonObj.Add("ActorCount", new JSONData(ad.Length));
            var jsonArray = new JSONArray();

            foreach (var actor in ad)
            {
                var actorJson = new JSONClass();
                actorJson.Add("type", new JSONData(actor.Value.GetType().ToString()));
                var actorComponents = new JSONClass();

                /*
                 *  foreach (var compoent in actor.Value.GetComponents().Result)
                 *  {
                 *      actorComponents.Add("Component", new JSONData(compoent.GetType().ToString()));
                 *  }
                 */
                actorJson.Add("Components", actorComponents);
                actorJson.Add("Attribute", actor.Value.GetAttr());
                jsonArray.Add("Actor", actorJson);
            }
            jsonObj.Add("Actors", jsonArray);

            sj.Add("AtorStatus", jsonObj);
            return(sj.ToString());
        }
 public override SimpleJSON.JSONClass GetProperties()
 {
     SimpleJSON.JSONClass N = base.GetProperties();
     return(N);
 }
	public GameObject[] objectsToCycle; //hmm problematic?


	public SimpleJSON.JSONClass GetProperties(SimpleJSON.JSONClass N){
		N[objectIndexKey].AsInt = objectIndex;
		
		return N;
	}
Пример #56
0
        public void exportMethod()
        {
#if UNITY_EDITOR
            var astar = AstarPath.active;
            if (astar == null)
            {
                astar = GameObject.FindObjectOfType <AstarPath>();
            }
            string path = EditorUtility.SaveFilePanel("Save Graphs", "", "graph" + Convert.ToString(mapId) + ".zip", "zip");
            if (path != "")
            {
                if (EditorUtility.DisplayDialog("Scan before saving?", "Do you want to scan the graphs before saving" +
                                                "\nNot scanning can cause node data to be omitted from the file if Save Node Data is enabled", "Scan", "Don't scan"))
                {
                    astar.Scan();
                }


                //uint checksum;
                Pathfinding.Serialization.SerializeSettings settings = Pathfinding.Serialization.SerializeSettings.All;


                byte[] bytes = null;
                //uint ch = 0;
                astar.AddWorkItem(new AstarPath.AstarWorkItem(delegate(bool force) {
                    Pathfinding.Serialization.AstarSerializer sr = new Pathfinding.Serialization.AstarSerializer(astar.astarData, settings);
                    sr.OpenSerialize();
                    astar.astarData.SerializeGraphsPart(sr);
                    //sr.SerializeEditorSettings (graphEditors);
                    var start = GameObject.Find("PlayerStart").transform.position;
                    var grid  = Util.CoordToGrid(start.x, start.z);
                    var yOff  = Util.IntYOffset(start.y);

                    SimpleJSON.JSONClass jc = new SimpleJSON.JSONClass();
                    var arr = jc["playerStart"] = new SimpleJSON.JSONArray();

                    arr[-1].AsInt = (int)(grid.x);
                    arr[-1].AsInt = yOff;
                    arr[-1].AsInt = (int)(grid.y);

                    /*
                     * System.IO.MemoryStream stream = new System.IO.MemoryStream();
                     * BinaryWriter outfile = new BinaryWriter(stream);
                     * jc.Serialize(outfile);
                     */
                    Debug.Log("Export " + jc.ToString());
                    var graph = astar.graphs[0] as Pathfinding.GridGraph;
                    var js    = new SimpleJSON.JSONClass();
                    js["unclampedSize"]["x"].AsInt = graph.width;
                    js["unclampedSize"]["y"].AsInt = graph.depth;
                    js["center"]["x"].AsFloat      = graph.center.x;
                    js["center"]["y"].AsFloat      = graph.center.y;
                    js["center"]["z"].AsFloat      = graph.center.z;
                    sr.zip.AddEntry("playerStart" + Convert.ToString(mapId) + ".json", System.Text.Encoding.UTF8.GetBytes(jc.ToString()));
                    sr.zip.AddEntry("graph0.json", System.Text.Encoding.UTF8.GetBytes(js.ToString()));
                    bytes = sr.CloseSerialize();
                    //ch = sr.GetChecksum ();
                    return(true);
                }));

                Pathfinding.Serialization.AstarSerializer.SaveToFile(path, bytes);
                EditorUtility.DisplayDialog("Done Saving", "Done saving graph data.", "Ok");
            }
#endif
        }
Пример #57
0
 public override SimpleJSON.JSONClass GetProperties()
 {
     SimpleJSON.JSONClass N = base.GetProperties();
     N[checkpointKey] = checkpointStatus.ToString();
     return(N);
 }
Пример #58
0
    public override void SetProperties(SimpleJSON.JSONClass N)
    {
        SetFraction(JsonUtil.ConvertJsonToFraction(Fraction.fractionKey, N));
//		CreateWall();
    }
    // upoffset     }

    public override void SetProperties(SimpleJSON.JSONClass N)
    {
        base.SetProperties(N);
    }
Пример #60
0
 public override SimpleJSON.JSONClass GetProperties()
 {
     SimpleJSON.JSONClass N = base.GetProperties();
     N = JsonUtil.ConvertFractionToJson(Fraction.fractionKey, frac, N);
     return(N);
 }