public JSONBuilder Clone() { String text = stringBuilder.ToString(); JSONBuilder clone = new JSONBuilder(); clone.counter = counter; clone.stringBuilder = new StringBuilder(text); return(clone); }
public JSONBuilder GetProxyJSON() { JSONBuilder json = new JSONBuilder(); lock (mutex) { json.Add("name", name); json.Add("id", id); json.Add("players", players.Count); } return(json); }
public override String ToString() { JSONBuilder json = new JSONBuilder(); lock (mutex) { json.Add("name", name); json.Add("id", id); json.Add("playernumber", players.Count); for (int id = 0; id < players.Count; ++id) { Player player = players[id]; json.Add("player_" + id, player); } } return(json.ToString()); }
private String GetGameInfos() { JSONBuilder json = new JSONBuilder(); json.Add("playerid", id); lock (GameManager.mutex) { List <JSONBuilder> gameInfos = Program.GameManager.GetGameInfos(); json.Add("gamecount", gameInfos.Count); int gameID = 0; foreach (JSONBuilder gameInfo in gameInfos) { json.Add("game_" + gameID, gameInfo); gameID++; } } return(json.ToString()); }
public void RemoveGame(Game game) { lock (mutex) { games.Remove(game); int id = -1; for (int i = 0; i < gameInfos.Count; ++i) { JSONBuilder gameInfo = gameInfos[i]; if (gameInfo.Clone().ToString().Contains("'id':" + game.ID)) { id = i; break; } } if (id != -1) { gameInfos.RemoveAt(id); } } }
public override string ToString() { JSONBuilder json = new JSONBuilder(); lock (mutex) { json.Add("name", name); json.Add("id", id); json.Add("x", x); json.Add("y", y); json.Add("dirx", dirX); json.Add("diry", dirY); json.Add("range", range); json.Add("attackangle", attackAngle); json.Add("attackspeed", attackSpeed); json.Add("movespeed", moveSpeed); json.Add("attackdamage", attackDamage); json.Add("health", health); json.Add("isalive", isAlive); } return(json.ToString()); }