public ludzik(TcpClient Client, sReader readS, sWriter writeS, ludzik[] L, int x, int y, bool Run) { _l = L; this.Client = Client; NetworkStream stream = Client.GetStream(); this.readS = readS; this.writeS = writeS; this.X = x; this.Y = y; if (Run) { _readT = new Thread(new ThreadStart(reader)); _readT.Start(); } }
private void action(TcpClient Client) { NetworkStream stream = Client.GetStream(); sWriter writeS = new sWriter(logTxt, this, stream); sReader readS = new sReader(logTxt, this, stream); string buf = readS.ReadString(); string[] data = buf.Split('|'); switch (data[0]) { case MsgC.GetID: writeS.Write(MsgS.SetID + "|" + _index.ToString()); int x = _posS.Pos[_index, 0]; int y = _posS.Pos[_index, 1]; for (int i = 0; i < _index; i++) { _l[i].writeS.Write( MsgS.Join + "|" + _index.ToString() + "|" + x.ToString() + "|" + y.ToString() ); } for (int i = 0; i < _index; i++) { writeS.Write( MsgS.Move + "|" + i.ToString() + "|" + _l[i].X.ToString() + "|" + _l[i].Y.ToString() ); } _l[_index++] = new ludzik(Client, readS, writeS, _l, x, y, true); break; } }