Ejemplo n.º 1
0
        public JSONBuilder Clone()
        {
            String text = stringBuilder.ToString();

            JSONBuilder clone = new JSONBuilder();

            clone.counter       = counter;
            clone.stringBuilder = new StringBuilder(text);

            return(clone);
        }
Ejemplo n.º 2
0
        public JSONBuilder GetProxyJSON()
        {
            JSONBuilder json = new JSONBuilder();

            lock (mutex)
            {
                json.Add("name", name);
                json.Add("id", id);
                json.Add("players", players.Count);
            }

            return(json);
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
        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());
        }
Ejemplo n.º 5
0
        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);
                }
            }
        }
Ejemplo n.º 6
0
        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());
        }