Beispiel #1
0
        private void GetResponse(string responseFilename, List <MovableSceneObject> sceneObjects)
        {
            var      pointSize       = new Size(2, 2);
            var      response        = JsonSaverLoader.Load <ImitationResponse>(responseFilename);
            Aircraft aircraft        = null;
            var      missileBitmap   = new Bitmap(Resources.Missile1, 10, 10);
            var      explosionBitmap = new Bitmap(Resources.Explosion, 25, 25);

            if (response.AircraftTrajectory.Count > 0)
            {
                List <PointF> aircraftTrajectory  = response.AircraftTrajectory;
                var           aircraftBitmap      = new Bitmap(Resources.FighterJet, 25, 25);
                var           aircraftScenePoints = new ScenePoints(aircraftTrajectory, pointSize, Brushes.Black);
                aircraft = new Aircraft(aircraftBitmap, aircraftScenePoints);
                sceneObjects.Add(aircraft);
            }
            else
            {
                mainForm.ShowMessage("Нет траектории самолета");
            }

            if (response.UsualMissile.Trajectory.Count > 0)
            {
                List <PointF> missileTrajectory  = response.UsualMissile.Trajectory;
                var           missileScenePoints = new ScenePoints(missileTrajectory, pointSize, Brushes.Red);
                var           usualMissile       = new Missile(missileBitmap, missileScenePoints, response.UsualMissile.IsHit);
                usualMissile.Hit += (bitmap) => usualMissile.Explosion(explosionBitmap);
                mainForm.AddDGVData("Длина траектории четкой ракеты", usualMissile.TrajectoryLength);

                if (aircraft != null)
                {
                    usualMissile.Hit += (bitmap) => aircraft.Explosion(explosionBitmap);
                }

                sceneObjects.Add(usualMissile);
            }
            else
            {
                mainForm.ShowMessage("Нет траектории четкой ракеты");
            }

            if (response.FuzzyMissile.Trajectory.Count > 0)
            {
                List <PointF> fuzzyMissileTrajectory  = response.FuzzyMissile.Trajectory;
                var           fuzzyMissileScenePoints = new ScenePoints(fuzzyMissileTrajectory, pointSize, Brushes.Blue);
                var           fuzzyMissile            = new Missile(missileBitmap, fuzzyMissileScenePoints, response.FuzzyMissile.IsHit);
                fuzzyMissile.Hit += (bitmap) => fuzzyMissile.Explosion(explosionBitmap);
                mainForm.AddDGVData("Длина траектории нечеткой ракеты", fuzzyMissile.TrajectoryLength);

                if (aircraft != null)
                {
                    fuzzyMissile.Hit += (bitmap) => aircraft.Explosion(explosionBitmap);
                }

                sceneObjects.Add(fuzzyMissile);
            }
            else
            {
                mainForm.ShowMessage("Нет траектории нечеткой ракеты");
            }

#if (!DEBUG)
            File.Delete(responseFilename);
#endif
        }