Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1.         class ClientInfo
  2.         {
  3.             public int posX, posY, score;
  4.  
  5.             ClientInfo( int x, int y )
  6.             {
  7.                 posX = x;
  8.                 posY = y;
  9.                 score = 0;
  10.             }
  11.         }
  12.  
  13.         Dictionary<string, ClientInfo> clients = new Dictionary<string, ClientInfo>();
  14.  
  15.         //            01234567890 012345678 012345678 0123456789
  16.         String str = "portID:XXXX,PosX=XXXX,PosY=XXXX,Score=XXXX";
  17.  
  18.         void ParseClientInfo( string msg )
  19.         {
  20.             char[] delimited = new char[] { ',' };
  21.  
  22.             string[] parsed = str.Split( delimited );
  23.  
  24.             int portID = Convert.ToInt32( parsed[0].Substring( 7 ) );
  25.  
  26.             int pX = Convert.ToInt32( parsed[1].Substring( 5 ) );
  27.  
  28.             int pY = Convert.ToInt32( parsed[2].Substring( 5 ) );
  29.  
  30.             int score = Convert.ToInt32( parsed[3].Substring( 6 ) );
  31.  
  32.             clients[ portID.ToString() ].posX = pX;
  33.             clients[ portID.ToString() ].posY = pY;
  34.             clients[ portID.ToString() ].score = score;
  35.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement