Exemplo n.º 1
0
        void sendNewCoordinates(String gameName, clsUser user)
        {
            messageUsersFromServer mufs = new messageUsersFromServer();

            lock (games) {
                mufs.users = new userInfo[games[gameName].Users.Count];
                int i = 0;
                foreach (var userName in games[gameName].Users.Keys)
                {
                    userInfo ui = new userInfo();
                    ui.color = games[gameName].Users[userName].Color;
                    ui.name  = userName;
                    ui.x     = games[gameName].Users[userName].X;
                    ui.y     = games[gameName].Users[userName].Y;

                    mufs.users[i] = ui;
                    i++;
                }
                foreach (var userName in games[gameName].Users.Keys)
                {
                    if (games[gameName].Users[userName].SendClient != null && games[gameName].Users[userName].SendClient.Connected)
                    {
                        mufs.sendMessage(games[gameName].Users[userName].SendClient.GetStream());
                    }
                }
            }
        }
Exemplo n.º 2
0
 void updateUsersTable(messageUsersFromServer message)
 {
     lock (players) {
         players.Clear();
         foreach (var user in message.users)
         {
             players.Add(user);
             if (user.name == me.name)
             {
                 me = user;
             }
         }
     }
     gameField.Invalidate();
 }