예제 #1
0
파일: Form1.cs 프로젝트: ssozinov/bomberSoz
        private void MainForm_Load(object sender, EventArgs e)
        {
            BufferedGraphicsContext currentContext;
            BufferedGraphics        myBuffer;

            SoundPlayer mainSound = new SoundPlayer(Resources.go_goom);

            //  mainSound.PlaySync();

            currentContext = BufferedGraphicsManager.Current;

            myBuffer = currentContext.Allocate(this.CreateGraphics(),
                                               this.DisplayRectangle);
            var mapManager = new MapManager(ConfigurationManager.AppSettings["pathToMapDirectory"], ConfigurationManager.AppSettings["pathToMapFile"]);
            var map        = new FormMap(int.Parse(ConfigurationManager.AppSettings["widthField"]), int.Parse(ConfigurationManager.AppSettings["heightField"]), int.Parse(ConfigurationManager.AppSettings["timeToBoom"]));
            var Bomber     = new BomberSoz.Model.Bomber(int.Parse(ConfigurationManager.AppSettings["liveCount"]), map.FirstPositionBomber);

            this.Size = new System.Drawing.Size((map.Width + 1) * ImagePath.IMAGE_SIZE + 20, (map.Height + 1) * ImagePath.IMAGE_SIZE + 150);
            map.Load(mapManager.GetFirstMap());
            map.SetUpgradeOnMap(1, 1, 1);
            this.DoubleBuffered = true;
            displayForm         = new FormDisplay(map, this, this.CreateGraphics(), myBuffer, Bomber, mainSound);
            gamepadForm         = new FormGamePad();
            mC = new MotionController(displayForm, gamepadForm, map, Bomber, mapManager);

            mC.SetPositionForPerson(2, 1);
            mC.SetPositionForPerson(3, 2);
            mC.SetPositionForPerson(4, 1);

            System.Diagnostics.Stopwatch sw = new Stopwatch();
            sw.Start();

            sw.Stop();
            Logging.WriteTrace("Первая отрисовка" + (sw.ElapsedMilliseconds / 100.0).ToString());
            Task.Run(() => mC.Start());
        }