Esempio n. 1
0
        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 });
        }
Esempio n. 2
0
 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;
     }
 }
Esempio n. 3
0
 public MainWindow()
 {
     Application.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException;
     ProtoClient.OnConnectionLost += ProtoClient_OnConnectionLost;
     ProtoClient.Bind();
     this.SyncContext = SynchronizationContext.Current;
     this.Loaded     += MainWindow_Loaded;
     InitializeComponent();
 }
Esempio n. 4
0
 public LoginView()
 {
     if (Net.ENABLE_DISCOVERY)
     {
         ProtoClient.OnServerDiscovered += ProtoClient_OnServerDiscovered;
         try
         {
             ProtoClient.DiscoverServer();
         }
         catch
         {
             // ... screw this
         }
     }
     InitializeComponent();
 }
Esempio n. 5
0
 public void OnShowAnimationEnd()
 {
     ProtoClient.GameReady();
     //myBoard[0, 0].AnimateState(Common.Structures.Remote.SeaCellState.SHIP_HIT);
 }