private void startGame(Object sender, EventArgs e) { MainMenuNewGameScreen tempScreen = (MainMenuNewGameScreen)state; String p1name = "Player 1"; String p2name = "Player 2"; if (tempScreen.player1name.Text.Length > 0) { p1name = tempScreen.player1name.Text; } if (tempScreen.player2name.Text.Length > 0) { p2name = tempScreen.player2name.Text; } Controls.Clear(); state = new GameState(new Game(p1name, p2name), ClientSize.Width, ClientSize.Height); GameState temp = (GameState)state; Controls.Add(temp.p1Score); Controls.Add(temp.p2Score); Controls.Add(temp.activePlayerReminder); foreach (Label l in temp.colonyNumbers) { Controls.Add(l); } foreach (Button b in temp.buttons) { Controls.Add(b); } temp.colonyButton.Click += colonyButtonClick; temp.tradeButton.Click += tradeButtonClick; temp.menuButton.Click += menuButtonClick; Invalidate(true); }
private void setContextNewGame(Object sender, EventArgs e) { Controls.Clear(); state = new MainMenuNewGameScreen(ClientSize.Width, ClientSize.Height); MainMenuNewGameScreen temp = (MainMenuNewGameScreen)state; temp.back.Click += backButton_Click; temp.startGame.Click += startGame; foreach (Button b in temp.buttons) { b.Font = new Font(font.Families[0], 20, FontStyle.Regular); Controls.Add(b); } Controls.Add(temp.player1); Controls.Add(temp.player2); Controls.Add(temp.player1name); Controls.Add(temp.player2name); //TODO NEW GAME FUNCTION Invalidate(true); }