private void Form1_Load(object sender, EventArgs e) { statusLabel.Text = "Not Connected"; ConnectToStarCraft connectionDlg = new ConnectToStarCraft(); if (connectionDlg.ShowDialog(this) == DialogResult.Cancel) { this.Close(); return; } m_connection = connectionDlg.Connection; statusLabel.Text = "Connected"; if (m_connection.State != Communication.CommState.ListeningForUpdates) { MessageBox.Show( "Error connecting to StarCraft. Application will now exit.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); return; } m_connection.GameStateUpdated += new Communication.PlayerStateRecievedDelegate(m_connection_GameStateUpdated); // Setup the mediator to enable AI modules m_mediator = new Communication.GameMediator(m_connection); // Update UI on the UI thread Action updateUI = () => gameStateControl.UpdateMap(m_connection.GameMetadata.Map); gameStateControl.Invoke(updateUI); }
public ConnectToStarCraft() { InitializeComponent(); Connection = new Communication.StarCraftConnector(); }
public ConnectToStarCraft() { InitializeComponent(); Connection = new Communication.StarCraftConnector(GetAddress()); }