Ejemplo n.º 1
0
        /// <summary>
        ///     Ereignisbehandlung für das Timerintervall.
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">Eventargumente</param>

        public static void Decide()
        {
            if (GlobalVariables.MeAngefragt)
            {
                //Timer Stoppen & Resetten
                GlobalTimer.Atimer.Stop();
                GlobalTimer.Atimer.Dispose();

                SpielSchnittstelle.DontAcceptGameRequest();

                Program.Form1.AddTextToChat("Du hast die Anfrage abgebrochen");

                GlobalVariables.MeAngefragt = false;
            }

            else if (GlobalVariables.HeAngefragt)
            {
                //Timer Stoppen & Resetten
                GlobalTimer.Atimer.Stop();
                GlobalTimer.Atimer.Dispose();

                SpielSchnittstelle.DontAcceptGameRequest();

                if (ReceiveBinaryData.User != null)
                {
                    Program.Form1.AddTextToChat(ReceiveBinaryData.User.Name + " hat das Spiel abgelehnt");
                }

                else
                {
                    Program.Form1.AddTextToChat("Das Gegenüber hat das Spiel abgelehnt");
                }

                GlobalVariables.HeAngefragt = false;
            }

            else
            {
                Program.Form1.AddTextToChat("Du hast das Spiel beendet");

                SpielSchnittstelle.StopTheGame();
            }

            Program.Form1.SperreStop();
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Starte das Spiel oder Frage um ein Spiel an.
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">Eventargumente</param>

        public static void StartOrRequest()
        {
            // Wenn Bereits vom anderen Spieler angefragt wurde starte das Spiel, Ansonsten Frage an!
            if (!GlobalVariables.MeAngefragt && GlobalVariables.HeAngefragt)
            {
                try
                {
                    GlobalTimer.Atimer.Stop();
                    GlobalTimer.Atimer.Dispose();

                    GlobalVariables.MeAngefragt = false;
                    GlobalVariables.HeAngefragt = false;

                    Program.Form1.AddTextToChat("Spiel gestartet - Anfrage wurde akzeptiert");

                    // Starte das Spiel
                    SpielSchnittstelle.StartTheGame();
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    throw;
                }
            }
            // Wenn der andere Spieler angefragt hat und Ich angefragt habe, starte das Spiel
            else if (GlobalVariables.MeAngefragt && GlobalVariables.HeAngefragt)
            {
                try
                {
                    // Starte das Spiel
                    SpielSchnittstelle.StartTheGame();

                    GlobalTimer.Atimer.Stop();
                    GlobalTimer.Atimer.Dispose();

                    GlobalVariables.MeAngefragt = false;
                    GlobalVariables.HeAngefragt = false;

                    Program.Form1.AddTextToChat("Spiel gestartet - Beide haben Angefragt");
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    throw;
                }
            }
            // Frage an
            else
            {
                try
                {
                    GlobalVariables.TimeLeft = 10;

                    SpielSchnittstelle.GameRequest();
                    new GlobalTimer();
                    GlobalTimer.Atimer.Start();

                    GlobalVariables.MeAngefragt = true;

                    Program.Form1.AddTextToChat("Warte auf anderen Spieler");
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                    throw;
                }
            }

            Program.Form1.SperreStart();
        }
Ejemplo n.º 3
0
 private void bSpalte7_Click(object sender, EventArgs e)
 {
     SpielSchnittstelle.SetEinwurf(7);
     DisableGameButtons();
 }