Example #1
0
        public Level2()
        {
            FileName            = string.Empty;
            mousePoint          = new Point();
            this.DoubleBuffered = true;
            InitializeComponent();
            barrel              = new Barrel(new Point(40, 475));
            aim                 = new Aim();
            radians             = 0;
            ammo                = new AmmoMagazine();
            hits                = 0;
            total               = 0;
            increase            = true;
            speed               = 0; // max speed 25, min speed 0
            healthBar.Visible   = true;
            drawAim             = true;
            RopeHit             = false;
            barrel.ropeHeight   = 80;
            barrel.ropeWidth    = 3;
            barrel.wallHeight   = 300;
            barrel.wallWidth    = 10;
            barrel.wallPosX     = 630;
            barrel.wallPosY     = 10;
            barrel.buttonPosX   = 480;
            barrel.buttonPosY   = 415;
            barrel.buttonHeight = 20;
            barrel.buttonWidth  = 20;

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
Example #2
0
        private void ToolStripButton3_Click(object sender, EventArgs e)
        {
            timer1.Stop();
            var dialog = new OpenFileDialog();

            dialog.Filter = "Tank Game document (*.tgd)|*.tgd";
            dialog.Title  = "Open your game";
            if (FileName != string.Empty)
            {
                dialog.FileName = FileName.Substring(FileName.LastIndexOf('\\') + 1);
            }

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                FileName = dialog.FileName;
            }
            else
            {
                if (toolStripButton4.Text != "Resume")
                {
                    timer1.Start();
                }
                return;
            }
            try
            {
                using (var stream = new FileStream(FileName, FileMode.Open, FileAccess.Read))
                {
                    var formatter = new BinaryFormatter();
                    ammo = (AmmoMagazine)formatter.Deserialize(stream);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show($"EXEPTION HAS HAPPENED! HERE ARE DETAILS:\n\n{exception}");
            }
            finally
            {
                Invalidate(true);
                if (toolStripButton4.Text != "Resume")
                {
                    timer1.Start();
                }
            }
        }
        public MainGameWindow()
        {
            this.DoubleBuffered = true;
            InitializeComponent();
            FileName          = string.Empty;
            mousePoint        = new Point();
            barrel            = new Barrel(new Point(130, 460));
            aim               = new Aim();
            radians           = 0;
            ammo              = new AmmoMagazine();
            hits              = 0;
            total             = 0;
            increase          = true;
            speed             = 0; // max speed 25, min speed 0
            healthBar.Visible = true;
            drawAim           = true;

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }