private void имяИгрокаToolStripMenuItem_Click(object sender, EventArgs e) { FormNickname form5 = new FormNickname(); form5.ShowDialog(); }
private void Form1_KeyDown(object sender, KeyEventArgs e) { try { switch (e.KeyCode) { case Keys.Up: if (!isFirstHitSpace) { player.ChangePosition("up"); } break; case Keys.Down: if (!isFirstHitSpace) { player.ChangePosition("down"); } break; case Keys.Space: try { if (isFirstHitSpace) { game = (Game)Activator.GetObject(typeof(Game), "tcp://" + FormConnection.GetAddress() + ":8000/Game/Gameee"); Console.WriteLine(FormConnection.GetAddress()); player = game.Connect(FormNickname.GetNickName()); TickTimer = new System.Timers.Timer(5); TickTimer.Elapsed += onUpdateInfo; TickTimer.AutoReset = true; TickTimer.Enabled = true; pb_Ball.Location = new Point(game.Ball.X, game.Ball.Y); CircleThis(pb_Ball); } isFirstHitSpace = false; if (game.getPlayer(1) == null) { game.SetStatus("waiting2player"); this.label_Start.Text = "Второй игрок не подключен"; } else { game.SetStatus("playing"); } } catch { Console.WriteLine(isFirstHitSpace); label_Start.Text = "Сервер не обнаружен. Нажмите ESC для выхода."; } break; case Keys.Escape: if (this.label_Start.Text == "Сервер не обнаружен. Нажмите ESC для выхода.") { Close(); } break; } } catch { Console.WriteLine(isFirstHitSpace); Close(); } }