示例#1
0
        /// <summary>
        /// Restart het spel met dezelfde instellingen en namen als het vorig spel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ButtonSpeelOpnieuw_Click(object sender, EventArgs e)
        {
            this.pictureBoxSpeelOpnieuw.BackgroundImage = (Bitmap)Properties.Resources.ResourceManager.GetObject("SpeelOpnieuwButtonEndgame2D");
            await Task.Delay(300);

            this.pictureBoxSpeelOpnieuw.BackgroundImage = (Bitmap)Properties.Resources.ResourceManager.GetObject("SpeelOpnieuwButtonEndgame");
            if (BaseGame.Gamemode == 2 && GameMultiplayerOnline.Reset())
            {
                return;
            }
            this.Close();
            this.Dispose();
            GC.Collect();
            BaseGame.Reset();
            if (BaseGame.Gamemode == 0)
            {
                GameSingleplayer.Start(BaseGame.Height, BaseGame.Width, BaseGame.Naam1);
            }
            else if (BaseGame.Gamemode == 1)
            {
                GameMultiplayerLocal.Start(BaseGame.Height, BaseGame.Width, BaseGame.Naam1, BaseGame.Naam2);
            }
            else if (BaseGame.Gamemode == 2)
            {
                GameMultiplayerOnline.Reset2();
            }
        }
        /// <summary>
        /// Eindigt de game
        /// Als dit de client is, wacht op een reset packet van de host
        /// </summary>
        public static async void End()
        {
            BaseGame.Gamestate = 2;
            await Task.Delay(2000);

            //Als het een client is, wacht op reset packet van host
            if (!Host)
            {
                BackgroundWorker b = new BackgroundWorker();

                //Wordt op tweede thread gerunned
                b.DoWork += delegate(object o, DoWorkEventArgs args) {
                    BackgroundWorker bw    = o as BackgroundWorker;
                    object[]         reset = Utils.StringToArray(NetClient.ReceiveMessage()) as object[];
                    args.Result = reset;
                };

                //Als er een bericht is binnen gekomen
                b.RunWorkerCompleted += delegate(object o, RunWorkerCompletedEventArgs args) {
                    object[] reset = (object[])args.Result;
                    if ((reset[0] as string) == "reset")
                    {
                        BaseGame.Reset();
                        FormEndgame.instance.Close();
                        FormEndgame.instance.Dispose();
                        Start(BaseGame.Height, BaseGame.Width, BaseGame.Naam2, false);
                    }
                };
                b.RunWorkerAsync();
            }

            Exit();
        }
示例#3
0
 /// <summary>
 /// reset het spel
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void restartToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (BaseGame.Gamemode == 2 && GameMultiplayerOnline.Reset())
     {
         return;
     }
     BaseGame.Reset();
     BaseGame.ResetVeld();
 }
示例#4
0
        /// <summary>
        /// Closed de endgame form en reset de variabelen voor en nieuw spel gaat terug naar het hoofdmenu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ButtonHoofdmenu_Click(object sender, EventArgs e)
        {
            this.pictureBoxHoofdmenu.BackgroundImage = (Bitmap)Properties.Resources.ResourceManager.GetObject("HoofdmenuButtonBlauwEndgame2D");
            await Task.Delay(300);

            this.pictureBoxHoofdmenu.BackgroundImage = (Bitmap)Properties.Resources.ResourceManager.GetObject("HoofdmenuButtonBlauwEndgame");
            this.Close();
            this.Dispose();
            GC.Collect();
            BaseGame.Reset();
        }
示例#5
0
        /// <summary>
        /// reset het spel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void Buton_Reset_Click(object sender, EventArgs e)
        {
            this.PictureBox_Reset.BackgroundImage = (Bitmap)Properties.Resources.ResourceManager.GetObject("ResetButtonBlauwSpeelveld2D");
            await Task.Delay(300);

            this.PictureBox_Reset.BackgroundImage = (Bitmap)Properties.Resources.ResourceManager.GetObject("ResetButtonBlauwSpeelveld");
            if (BaseGame.Gamemode == 2 && GameMultiplayerOnline.Reset())
            {
                return;
            }
            BaseGame.Reset();
            BaseGame.ResetVeld();
        }
示例#6
0
        /// <summary>
        /// Opened het de startgame form zodat je een nieuw spel kunt doen met andere instellingen
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ButtonInstellingen_Click(object sender, EventArgs e)
        {
            this.pictureBoxInstellingen.BackgroundImage = (Bitmap)Properties.Resources.ResourceManager.GetObject("InstellingenButtonBlauwEndgame2D");
            await Task.Delay(300);

            this.pictureBoxInstellingen.BackgroundImage = (Bitmap)Properties.Resources.ResourceManager.GetObject("InstellingenButtonBlauwEndgame");
            if (BaseGame.Gamemode == 2)
            {
                GameMultiplayerOnline.Disconnect();
            }
            this.Close();
            this.Dispose();
            GC.Collect();
            BaseGame.Reset();
            FormStartgame startgame = new FormStartgame();

            startgame.ShowDialog();
        }