Exemplo n.º 1
0
        public Game()
        {
            TcpClient cl = new TcpClient();

            InitializeComponent();
            client = cl;
            client.Connect("127.0.0.1", 5555);
            clientIO = new ClientIO(client);
            lisen    = new Thread(() => ListendForCommand());
            lisen.Start();
            State.Content = "";
            GameCount     = 0;
            YouPlayer1    = true;
            YouTurn       = true;
            NewGame();
        }
Exemplo n.º 2
0
        private void ConnButt_Click(object sender, EventArgs e)
        {
            string nick = NickBox.Text;

            Regex regex = new Regex(@"\w");
            Match match = regex.Match(nick);



            if (match.Success && nick.Length < 11)
            {
                try
                {
                    client.Connect("127.0.0.1", 5555);
                }
                catch
                {
                    NickLable.Content    = "Не удалось подключиться к серверу";
                    NickLable.Foreground = Brushes.Red;
                    return;
                }

                NickLable.Content    = "Вы подключены";
                NickLable.Foreground = Brushes.Green;
                NickBox.IsEnabled    = false;
                ConnButt.IsEnabled   = false;

                PlayerList.Items.Add(nick);

                clientIO = new ClientIO(client);

                lisen = new Thread(() => ListendForCommand());
                lisen.Start();
                clientIO.SendData("conn," + nick);
            }
            else if (nick.Length > 10)
            {
                NickLable.Content    = "Максимальная длина имени 10 символов";
                NickLable.Foreground = Brushes.Red;
            }
            else
            {
                NickLable.Content    = "Некорректное имя";
                NickLable.Foreground = Brushes.Red;
            }
        }
Exemplo n.º 3
0
 public Game(TcpClient cl, bool YPlayer1, string YName, string OpponentName)
 {
     InitializeComponent();
     client = cl;
     //client.Connect("127.0.0.1", 5555);
     clientIO = new ClientIO(client);
     lisen    = new Thread(() => ListendForCommand());
     lisen.Start();
     YouName       = YName;
     Pl2Name       = OpponentName;
     State.Content = "";
     GameCount     = 0;
     YouPlayer1    = YPlayer1;
     if (YPlayer1)
     {
         YouTurn = true;
     }
     else
     {
         YouTurn = false;
     }
     NewGame();
 }