private void connectButton_Click(object sender, RoutedEventArgs e) { ProtoClient.OnHandshakeReceived += ProtoClient_OnHandshakeReceived; connectButton.IsEnabled = false; Task.Factory.StartNew((o) => { string[] array = (string[])o; string server = array[0]; string nick = array[1]; try { ProtoClient.Connect(server); ProtoClient.SendHandshake(ProtoClient.VERSION, nick); } catch { this.Invoke(() => { MessageBox.Show(this.GetMainWindow(), $"Could not establish connection with {this.serverTextBox.Text}"); connectButton.IsEnabled = true; }); } }, new string[] { this.serverTextBox.Text, this.nickTextBox.Text }); }
private void EnemyBoard_OnCellMouseUp(object sender, SeaBoard.SeaBoardCellEventArgs e) { if (this.GameState == LocalGameState.MY_TURN && e.Cell.Value == SeaCellState.SEA) { ProtoClient.FireAt(e.Cell.X, e.Cell.Y); this.GameState = LocalGameState.FIRED_WAIT; } }
public MainWindow() { Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException; ProtoClient.OnConnectionLost += ProtoClient_OnConnectionLost; ProtoClient.Bind(); this.SyncContext = SynchronizationContext.Current; this.Loaded += MainWindow_Loaded; InitializeComponent(); }
public LoginView() { if (Net.ENABLE_DISCOVERY) { ProtoClient.OnServerDiscovered += ProtoClient_OnServerDiscovered; try { ProtoClient.DiscoverServer(); } catch { // ... screw this } } InitializeComponent(); }
public void OnShowAnimationEnd() { ProtoClient.GameReady(); //myBoard[0, 0].AnimateState(Common.Structures.Remote.SeaCellState.SHIP_HIT); }