Inheritance: JSONNode
示例#1
0
        public override void Serialize(System.IO.BinaryWriter aWriter)
        {
            var tmp = new JSONData("") { AsInt = AsInt };

            if (tmp._data == _data) {
                aWriter.Write((byte)JSONBinaryTag.IntValue);
                aWriter.Write(AsInt);
                return;
            }
            tmp.AsFloat = AsFloat;
            if (tmp._data == _data) {
                aWriter.Write((byte)JSONBinaryTag.FloatValue);
                aWriter.Write(AsFloat);
                return;
            }
            tmp.AsDouble = AsDouble;
            if (tmp._data == _data) {
                aWriter.Write((byte)JSONBinaryTag.DoubleValue);
                aWriter.Write(AsDouble);
                return;
            }

            tmp.AsBool = AsBool;
            if (tmp._data == _data) {
                aWriter.Write((byte)JSONBinaryTag.BoolValue);
                aWriter.Write(AsBool);
                return;
            }
            aWriter.Write((byte)JSONBinaryTag.Value);
            aWriter.Write(_data);
        }
    private void ClientBatchPOST(object sender, ElapsedEventArgs e)
    {
        JSONData packet = new JSONData("SamplePacket:" + mDuration);
        ClientSocket.Instance.POST(packet);

        Timer timer = (Timer)sender;

        mDuration += (int)timer.Interval;

        if (mDuration > 1000)
        {
            timer.Stop();
            Debug.Log("Completed TestStartPOST");
        }
    }
示例#3
0
    void DoSync()
    {
		
		JSONClass cl = new JSONClass();
		
		JSONData dt_p1_mana = new JSONData(p1_mana);
		JSONData dt_p2_mana = new JSONData(p2_mana);
		JSONData dt_pop_all = new JSONData(pop_all);
		JSONData dt_pop_p1 = new JSONData(pop_p1);
		JSONData dt_pop_p2 = new JSONData(pop_p2);
		cl.Add("p1_mana",dt_p1_mana);
		cl.Add("p2_mana",dt_p2_mana);
		cl.Add("pop_all",dt_pop_all);
		cl.Add("pop_p1",dt_pop_p1);
		cl.Add("pop_p2",dt_pop_p2);
		
		string data = cl.SaveToBase64();
		
		pview.RPC("GameResources_DoSyncGet",PhotonTargets.Others,data);
        //nview.RPC("GameResources_DoSyncGet", RPCMode.Others, data);
		//Debug.Log ("sending data to client");
    }
示例#4
0
        public override void Serialize(System.IO.BinaryWriter aWriter)
        {
            var tmp = new JSONData("");

            tmp.AsInt = AsInt;
            if (tmp.m_Data == this.m_Data)
            {
                aWriter.Write((byte)JSONBinaryTag.IntValue);
                aWriter.Write(AsInt);
                return;
            }
            tmp.AsFloat = AsFloat;
            if (tmp.m_Data == this.m_Data)
            {
                aWriter.Write((byte)JSONBinaryTag.FloatValue);
                aWriter.Write(AsFloat);
                return;
            }
            tmp.AsDouble = AsDouble;
            if (tmp.m_Data == this.m_Data)
            {
                aWriter.Write((byte)JSONBinaryTag.DoubleValue);
                aWriter.Write(AsDouble);
                return;
            }

            tmp.AsBool = AsBool;
            if (tmp.m_Data == this.m_Data)
            {
                aWriter.Write((byte)JSONBinaryTag.BoolValue);
                aWriter.Write(AsBool);
                return;
            }
            aWriter.Write((byte)JSONBinaryTag.Value);
            aWriter.Write(m_Data);
        }
示例#5
0
        public override void Serialize (BinaryWriter aWriter)
        {
            var tmp = new JSONData("");
 
            tmp.AsInt = AsInt;
            if (tmp.m_Data == this.m_Data)
            {
                aWriter.Write((byte)JSONBinaryTag.IntValue);
                aWriter.Write(AsInt);
                return;
            }
            tmp.AsFloat = AsFloat;
            if (tmp.m_Data == this.m_Data)
            {
                aWriter.Write((byte)JSONBinaryTag.FloatValue);
                aWriter.Write(AsFloat);
                return;
            }
            tmp.AsDouble = AsDouble;
            if (tmp.m_Data == this.m_Data)
            {
                aWriter.Write((byte)JSONBinaryTag.DoubleValue);
                aWriter.Write(AsDouble);
                return;
            }
 
            tmp.AsBool = AsBool;
            if (tmp.m_Data == this.m_Data)
            {
                aWriter.Write((byte)JSONBinaryTag.BoolValue);
                aWriter.Write(AsBool);
                return;
            }
            aWriter.Write((byte)JSONBinaryTag.Value);
            aWriter.Write(m_Data);
        }
        public override string ToString()
        {
			var tmp = new JSONData("");
			
			tmp.AsInt = AsInt;
			if (tmp.m_Data == this.m_Data) {
				return this.m_Data;
			}

			tmp.AsFloat = AsFloat;
			if (tmp.m_Data == this.m_Data) {
				return this.m_Data;
			}

			tmp.AsDouble = AsDouble;
			if (tmp.m_Data == this.m_Data) {
				return this.m_Data;
			}

			tmp.AsBool = AsBool;
			if (tmp.m_Data == this.m_Data) {
				return this.m_Data;
			}

			return "\"" + Escape(m_Data) + "\"";
        }
		public override void Serialize (System.IO.BinaryWriter aWriter)
		{
			var tmp = new JSONData ("");
			
			if(this.m_Data != null) //jbw
			{ //jbw
			

					
				tmp.AsInt = AsInt;
				if (tmp.m_Data == this.m_Data) {
					aWriter.Write ((byte)JSONBinaryTag.IntValue);
					aWriter.Write ((int)AsInt); //jbw cast
					return;
				}
				tmp.AsFloat = AsFloat;
				if (tmp.m_Data == this.m_Data) {
					aWriter.Write ((byte)JSONBinaryTag.FloatValue);
					aWriter.Write ((float)AsFloat); //jbw cast
					return;
				}
				tmp.AsDouble = AsDouble;
				if (tmp.m_Data == this.m_Data) {
					aWriter.Write ((byte)JSONBinaryTag.DoubleValue);
					aWriter.Write ((double)AsDouble); //jbw cast
					return;
				}
				
				tmp.AsBool = AsBool;
				if (tmp.m_Data == this.m_Data) {
					aWriter.Write ((byte)JSONBinaryTag.BoolValue);
					aWriter.Write ((bool)AsBool); //jbw cast
					return;
				}
				
			} //jbw
			
			aWriter.Write ((byte)JSONBinaryTag.Value);
			
			if(m_Data == null) //jbw
				aWriter.Write ("null"); //jbw
			else
				aWriter.Write (m_Data);
		}
示例#8
0
    private static JSONNode SaveToJSON()
    {
        JSONClass root = new JSONClass ();

        JSONArray slotsJson = new JSONArray ();
        int i =0;
        foreach (Save slotInList in saves) {
            JSONClass slot = new JSONClass();

            if(saves[i].Hero.Name != null) {
                JSONData name = new JSONData (slotInList.Hero.Name);
                slot.Add ("name", name);
                JSONData score = new JSONData (slotInList.Score);
                slot.Add ("score", score);
                JSONData heroClass = new JSONData (slotInList.Hero.GetType().ToString());
                slot.Add ("class", heroClass);
                JSONData heroXp = new JSONData (slotInList.Hero.XpQuantity);
                slot.Add ("xp", heroXp);
                JSONData currentLevel = new JSONData (GameModel.Levels[slotInList.LevelId].Name);
                slot.Add ("currentLevel", currentLevel);
            } else {
                slot.Add ("name", "");
                slot.Add ("score", "");
                slot.Add ("class", "");
                slot.Add ("xp", "");
                slot.Add ("currentLevel", "");
            }

            slotsJson.Add (slot);

            Debug.Log(i);
            i++;
        }

        root.Add ("slots", slotsJson);
        return root;
    }
示例#9
0
    private static JSONNode HighScoreToJSON()
    {
        JSONClass root = new JSONClass ();

        JSONArray slotsJson = new JSONArray ();
        foreach (HighScore slotInList in highScores) {
            JSONClass slot = new JSONClass();

            JSONData name = new JSONData (slotInList.Name);
            slot.Add ("name", name);

            JSONData score = new JSONData (slotInList.Score);
            slot.Add ("score", score);

            slotsJson.Add (slot);
        }

        root.Add ("slots", slotsJson);
        return root;
    }
示例#10
0
 /// <summary>
 /// used for storing your own player-related data on the device
 /// JSONData supports all primitive data types
 /// </summary>
 public static void SetPlayerData(string id, JSONData data)
 {
     //get location string, pass result to node
     string loc = instance.player;
     instance.gameData[loc][id] = data;
     Save();
 }
示例#11
0
 public void POST(JSONData content)
 {
     // mBatchedContent.Add(mBatchedContent.Count.ToString(), content);  - disabled while this crash callstack investigated. https://ptowndev.slack.com/files/rajantande/F0C7CBYA3/screen_shot_2015-10-09_at_16.20.55.png
 }
示例#12
0
        public override object Clone()
        {
            JSONData d = new JSONData(m_Data);

            return(d);
        }
示例#13
0
    private static JSONNode LevelToJSON(Level level)
    {
        JSONClass root = new JSONClass ();

        JSONData name = new JSONData (level.Name);
        root.Add ("name",name);

        JSONData music = new JSONData (level.MusicPath);
        root.Add ("music",name);

        JSONData map = new JSONData (level.Map);
        root.Add ("map",name);

        JSONData tutorial = new JSONData (level.Tutorial);
        root.Add ("tutorial", tutorial);

        int i = 0;
        JSONArray items = new JSONArray ();
        foreach (Item itemInList in level.ItemList) {
            JSONClass item = new JSONClass();

            i++;
            JSONData id = new JSONData (i);
            item.Add ("id", id);

            JSONData type = new JSONData (itemInList.Type);
            item.Add ("type", type);

            JSONData position_seconds = new JSONData (itemInList.PositionInSeconds);
            item.Add ("position_seconds", position_seconds);

            JSONData position_x = new JSONData (itemInList.PositionInX);
            item.Add ("position_x", position_x);

            items.Add (item);
        }

        root.Add ("items", items);
        return root;
    }
示例#14
0
        public override string ToString()
        {
            var tmp = new JSONData("");
            tmp.AsInt = AsInt;

            bool needquote = true;
            if(tmp.m_Data == this.m_Data)
            {
                needquote = false;
            }
            else {
                tmp.AsBool = AsBool;
                if(tmp.m_Data == this.m_Data)
                {
                    needquote = false;
                }
                else {
                    tmp.AsDouble = AsDouble;
                    if(tmp.m_Data == this.m_Data)
                    {
                        needquote = false;
                    }
                    else {
                        tmp.AsFloat = AsFloat;
                        if (tmp.m_Data == this.m_Data) {
                            needquote = false;
                        }
                    }
                }
            }
            if(needquote)
            {
                return "\"" + Escape(m_Data) + "\"";
            }
            return Escape(m_Data);
        }