private void startGameButton_Click(object sender, RoutedEventArgs e) { parent.Children.Remove(parent.Children[1]); //hostCanvas List <TextBox> tbList = new List <TextBox>(7); List <ComboBox> cbList = new List <ComboBox>(7); List <Player> players = new List <Player>(); input = this.tb.Text; UIElementCollection c = waitingCanvas.Children; //System.Console.WriteLine("\n\n\n"); for (int i = 0; i < c.Count; i++) { UIElement el = c[i]; if (c[i].GetType() == typeof(System.Windows.Controls.ComboBox)) { cbList.Add((ComboBox)c[i]); } if (c[i].GetType() == typeof(System.Windows.Controls.TextBox)) { tbList.Add((TextBox)c[i]); } } for (int i = 0; i < tbList.Count; i++) { ComboBox cb = null; TextBox tb = tbList[i]; if (tb.Text.Length != 0 && tb.Text != " ") { cb = this.getComboBox(cbList, tb.Name.Substring(4, 1)); players.Add(new Player(i, cb.SelectedIndex)); } } if (players.Count < 3) { System.Windows.MessageBox.Show("C'mon you need at least three players!"); WaitingToStartCanvasHost wait = new WaitingToStartCanvasHost(parent); } else { StartGame start = new StartGame(players); //TODO NETWORKING need a text field input of how many players are connected //Just read the text fields?...Accumulate GameState game = start.getGame(); List <PlayerState> ps = game.getPlayers(); PlayerGameBoard play = new PlayerGameBoard(parent, ps[0], game);//this creates the canvas that shows. //TODO need to make child 0 player and child 1 current view. } }
//"play" button on play canvas "start hosting" on host canvas private void startHostingGame_Click(object sender, RoutedEventArgs e) { parent.Children.Remove(parent.Children[1]); /*var connecting = new WaitingOnConnectionWindow(); * connecting.Show(); */ /* WondersServer server = new WondersServer(3004); * ThreadStart ts = new ThreadStart(server.serverStart); * Thread serverThread = new Thread(ts); * serverThread.Start(); * * ClientDblBuff commBuffer = new ClientDblBuff(); * ClientComm client = new ClientComm("127.0.0.1", commBuffer); * ThreadStart cs = new ThreadStart(client.ClientRun); * Thread clientThread = new Thread(cs); * clientThread.Start();*/ WaitingToStartCanvasHost wait = new WaitingToStartCanvasHost(parent); }
//"Play!" Button on StartCanvas private void PlayGameButton_Click(object sender, RoutedEventArgs e) { parent.Children.Remove(parent.Children[1]); WaitingToStartCanvasHost play = new WaitingToStartCanvasHost(parent); }
//"play" button on play canvas "start hosting" on host canvas private void startHostingGame_Click(object sender, RoutedEventArgs e) { parent.Children.Remove(parent.Children[1]); /*var connecting = new WaitingOnConnectionWindow(); connecting.Show(); */ WondersServer server = new WondersServer(3004); ThreadStart ts = new ThreadStart(server.serverStart); Thread serverThread = new Thread(ts); serverThread.Start(); ClientDblBuff commBuffer = new ClientDblBuff(); ClientComm client = new ClientComm("127.0.0.1", commBuffer); ThreadStart cs = new ThreadStart(client.ClientRun); Thread clientThread = new Thread(cs); clientThread.Start(); WaitingToStartCanvasHost wait = new WaitingToStartCanvasHost(parent); }
private void startGameButton_Click(object sender, RoutedEventArgs e) { parent.Children.Remove(parent.Children[1]); //hostCanvas List<TextBox> tbList = new List<TextBox>(7); List<ComboBox> cbList = new List<ComboBox>(7); List<Player> players = new List<Player>(); input = this.tb.Text; UIElementCollection c = waitingCanvas.Children; //System.Console.WriteLine("\n\n\n"); for (int i = 0; i < c.Count; i++) { UIElement el = c[i]; if (c[i].GetType() == typeof(System.Windows.Controls.ComboBox)) cbList.Add((ComboBox)c[i]); if (c[i].GetType() == typeof(System.Windows.Controls.TextBox)) tbList.Add((TextBox)c[i]); } for (int i = 0; i < tbList.Count; i++) { ComboBox cb = null; TextBox tb = tbList[i]; if (tb.Text.Length != 0 && tb.Text != " ") { cb = this.getComboBox(cbList, tb.Name.Substring(4, 1)); players.Add(new Player(i, cb.SelectedIndex)); } } if (players.Count < 3) { System.Windows.MessageBox.Show("C'mon you need at least three players!"); WaitingToStartCanvasHost wait = new WaitingToStartCanvasHost(parent); } else { StartGame start = new StartGame(players); //TODO NETWORKING need a text field input of how many players are connected //Just read the text fields?...Accumulate GameState game = start.getGame(); List<PlayerState> ps = game.getPlayers(); PlayerGameBoard play = new PlayerGameBoard(parent, ps[0], game);//this creates the canvas that shows. //TODO need to make child 0 player and child 1 current view. } }