private void btnCreateGame_Click(object sender, EventArgs e) { string gameName = tbxGameName.Text; string password = tbxGamePassword.Text; if (String.IsNullOrEmpty(gameName)) { FormMessage fm = new FormMessage("Game name must be specified!"); fm.Opacity = 0; fm.ShowDialog(); tbxGameName.Focus(); return; } if (_selectedIndex >= 0) { _names.Remove(_names[_selectedIndex]); } FormGame f = new FormGame(this); f.Opacity = 0; IModel m = new ModelGame(gameName, password); IController c = new ControllerInternet(m, (IView)f); f.GameController = c; c.CreateGame(); f.Show(); }
private void btnSinglePlayer_Click(object sender, EventArgs e) { IModel model = new ModelGame(); fg = new FormGame(this); IController ctrl = new ControllerSinglePlayer(model, fg); fg.GameController = ctrl; fg.Opacity = 0; fg.Show(); _tSinglePlayer.Enabled = true; }
private void btnHotseat_Click(object sender, EventArgs e) { IModel model = new ModelGame(); fg = new FormGame(this); IController ctrl = new ControllerHotseat(model, fg); fg.GameController = ctrl; fg.Opacity = 0; fg.Show(); _tHotseat.Enabled = true; }
private void btnJoinGame_Click(object sender, EventArgs e) { if (dgvGames.RowCount == 1) { return; } string gameName = dgvGames.SelectedRows[0].Cells[0].Value as string; string ip = dgvGames.SelectedRows[0].Cells[1].Value as string; string pass = dgvGames.SelectedRows[0].Cells[2].Value as string; var item = new GameItem(gameName, ip, pass); string pwd = tbxPasswordGame.Text; if (item.PasswordProtected == "False") { pwd = ""; } bool joined = ctrl.JoinGame(item, pwd); if (joined) { fg.Opacity = 0; fg.EnableTimer(true); fg.Show(); fg.DisplayMessage("You connected!"); } else { FormMessage fm = new FormMessage("Can't connect!"); fm.Opacity = 0; fm.ShowDialog(); btnRefresh.PerformClick(); } }