Exemple #1
0
        private void AttackMethod()
        {
            if (warRoom.countriesAtWar.Count > 1)
            {
                var countryWars = warRoom.RandomCountries();

                PointF attackPoint = new PointF(countryWars.x1, countryWars.y1);
                PointF defendPoint = new PointF(countryWars.x2, countryWars.y2);

                curveStart = attackPoint;
                curveEnd   = defendPoint;
                CreateCurve(curveStart, curveEnd);

                float x = countryWars.x2 - 20;
                float y = countryWars.y2 - 20;

                var g = Graphics.FromImage(Background.BackgroundImage);

                if (ClearLinesCheckBox.Checked && drawLoop >= 1)
                {
                    g.Clear(Color.Transparent);
                    drawLoop = 0;
                }
                g.SmoothingMode = SmoothingMode.AntiAlias;
                Pen pen = new Pen(Color.Red, 2);
                g.DrawCurve(pen, curvePointList.ToArray());
                ExplosionPictureBox.Hide();
                ExplosionPictureBox.Show();
                ExplosionPictureBox.Location = new Point((int)x, (int)y);
                Background.Refresh();
                drawLoop++;

                Thread ES = new Thread(() => MediaPlayer.ExplosionSound());
                ES.Start();
            }
            else
            {
                warTimer.Stop();
                ExplosionPictureBox.Hide();

                EndCredits endPage = new EndCredits();
                endPage.GetWinCountry(warRoom.countriesAtWar[0].CountryName);

                if (endPage.ShowDialog(this) == DialogResult.OK)
                {
                    Graphics.FromImage(Background.BackgroundImage).Clear(Color.Transparent);
                    Background.Refresh();
                    PauseButton.Enabled      = false;
                    CustomizeGameBtn.Enabled = true;
                    warRoom.countriesAtWar.Clear();

                    IsOn = !IsOn;
                }
                else
                {
                    EnduranceListBox.DataSource = null;
                    Close();
                }
            }
        }
Exemple #2
0
 private void PauseButton_Click(object sender, EventArgs e)
 {
     IsPause = !IsPause;
     if (IsPause)
     {
         warTimer.Stop();
         ExplosionPictureBox.Hide();
     }
     if (!IsPause)
     {
         warTimer.Start();
     }
 }
Exemple #3
0
 private void StartButton_Click(object sender, EventArgs e)
 {
     IsOn = !IsOn;
     if (IsOn)
     {
         //if the user havent visited the "customize" section the when pressed it will create a list of countries with default stats
         if (warRoom.countriesAtWar.Count == 0)
         {
             warRoom.CountryList();
             PauseButton.Enabled      = true;
             CustomizeGameBtn.Enabled = false;
         }
         //start the program using the list with stats from the "customize" section
         else
         {
             PauseButton.Enabled      = true;
             CustomizeGameBtn.Enabled = false;
         }
         warTimer.Start();
     }
     if (!IsOn)
     {
         //stops the war, when it says Stop also works as and reset the list
         warRoom.countriesAtWar.Clear();
         ExplosionPictureBox.Hide();
         PauseButton.Enabled      = false;
         CustomizeGameBtn.Enabled = true;
         warTimer.Stop();
         ExplosionPictureBox.Hide();
         if (IsPause)
         {
             IsPause = !IsPause;
         }
         IsPause = IsPause;
     }
     Graphics.FromImage(Background.BackgroundImage).Clear(Color.Transparent);
     Background.Refresh();
     warRoom.countriesAtWar.Sort();
     ((CurrencyManager)EnduranceListBox.BindingContext[warRoom.countriesAtWar]).Refresh();
 }