public void JourneyComplete(Satellite pvSatellite, int pvTimeToComplete)
        {
            double dblDistanceTravelled        = pvSatellite.DistanceBetweenPlanets + pvSatellite.DistanceInPlanetaryOrbit;
            string strMessageComplete          = "    JOURNEY COMPLETE!";
            string strMessageDistanceTravelled = "Distance Travelled: " + dblDistanceTravelled.ToString();
            string strTimeToComplete           = "In " + (pvTimeToComplete / 365) + " Years " + (pvTimeToComplete % 365) + " Days";

            pvSatellite.Reset();

            MessageBox.Show(strTimeToComplete, strMessageComplete, MessageBoxButton.OK);
        }
        public void UpdateJourneyComplete(Satellite pvSatellite, int pvTimeToComplete)
        {
            JourneyCompleteDel objJourneyCompleteDel = new JourneyCompleteDel(JourneyComplete);
            List <Satellite>   lstSatellite          = new List <Satellite>();

            lstSatellite.Add(pvSatellite);


            // parameters
            object[] lstParams = { pvSatellite, pvTimeToComplete };
            mainCanvas.Dispatcher.BeginInvoke(objJourneyCompleteDel, System.Windows.Threading.DispatcherPriority.Render, lstParams);
        }
Exemple #3
0
        public TravellerRunTime(List <Planet> pvListPlanets, Satellite pvSatellite, Sun pvSun, ViewObserver pvViewObserver)
        {
            bKeepGoing = true;
            bRunning   = false;
            bUpdatePlanetOrbitPosition             = true;
            bUpdateSatelliteOrbitPosition          = true;
            bUpdateSatelliteInterPlanetaryPosition = true;

            bStep    = false;
            bUseStep = false;


            lstPlanets      = pvListPlanets;
            objSatellite    = pvSatellite;
            objSun          = pvSun;
            objViewObserver = pvViewObserver;
            objThread       = new Thread(Run);
            objThread.Name  = "TravellerRunTime";
            timeToComplete  = 1;


            objThreadFlash = new Thread(FlashSatellite);
        }
Exemple #4
0
        // uses the satellite radius attribute for the pull checks
        // RG 24/05/20  not used
        public bool WithinOrbitPullSatelliteRadius(Satellite pvSatellite)
        {
            bool bWithinOrbitPull = false;

            bool bCouldBeInOrbitX = false;
            bool bCouldBeInOrbitY = false;

            /* test A satellite is at an X co-ordinate > planet X but <= planet X + radius */
            if ((pvSatellite.Position.PosX > this.Position.PosX) & (pvSatellite.Position.PosX <= this.Position.PosX + pvSatellite.Position.Radius))
            {
                bCouldBeInOrbitX = true;
            }

            /* test B satellite is at an X co-ordinate < planet X but >= planet X - radius */
            if ((pvSatellite.Position.PosX < this.Position.PosX) & (pvSatellite.Position.PosX >= this.Position.PosX - pvSatellite.Position.Radius))
            {
                bCouldBeInOrbitX = true;
            }

            /* test C satellite is at a Y co-ordinate > planet Y but <= planet Y + radius*/
            if ((pvSatellite.Position.PosY > this.Position.PosY) & (pvSatellite.Position.PosY <= this.Position.PosY + pvSatellite.Position.Radius))
            {
                bCouldBeInOrbitY = true;
            }

            /* test D satellite is at a Y co-ordinate < planet Y but >= planet Y - radius
             */
            if ((pvSatellite.Position.PosY < this.Position.PosY) & (pvSatellite.Position.PosY >= this.Position.PosY - pvSatellite.Position.Radius))
            {
                bCouldBeInOrbitY = true;
            }

            bWithinOrbitPull = (bCouldBeInOrbitX & bCouldBeInOrbitY);


            return(bWithinOrbitPull);
        }
Exemple #5
0
        // constructor loads the objects in the system
        public MainWindow()
        {
            InitializeComponent();


            // initialise the model
            lstPlanets  = new List <Planet>();
            lstPlanetUI = new List <PlanetUI>();


            NINETY_DEGREES_AS_RADIANS = 90 * (Pi / 180);
            // sun
            {
                PositionParams objSunPosition = new PositionParams();

                objSunPosition.PosX     = 550;
                objSunPosition.PosY     = 500;
                objSunPosition.Angle    = 100;
                objSunPosition.Velocity = 0;


                objSun = new Sun(objSunPosition);

                objSunPlanet = new Planet(objSun, objSunPosition, "Sun", 40);

                Ellipse objSunEllipse = new Ellipse();
                objSunEllipse.Stroke = System.Windows.Media.Brushes.Orange;
                objSunEllipse.Fill   = System.Windows.Media.Brushes.Yellow;
                objSunEllipse.HorizontalAlignment = HorizontalAlignment.Left;
                objSunEllipse.VerticalAlignment   = VerticalAlignment.Center;
                objSunEllipse.Width  = 30;
                objSunEllipse.Height = 30;
                objSunUI             = new PlanetUI(objSunPlanet, objSunEllipse);

                Canvas.SetLeft(objSunUI.Ellipse, objSunPosition.PosX);
                Canvas.SetTop(objSunUI.Ellipse, objSunPosition.PosY);

                mainCanvas.Children.Add(objSunUI.Ellipse);
            }

            // mars
            {
                PositionParams objPlanetParams = new PositionParams();
                objPlanetParams.PosX  = 250;
                objPlanetParams.PosY  = 250;
                objPlanetParams.Angle = 100;
                // was 0.003
                objPlanetParams.Velocity = 0.005;
                // was 400
                objPlanetParams.Radius = 200;

                double dblMarsPullRadius = 20;
                objPlanet = new Planet(objSun, objPlanetParams, "Mars", dblMarsPullRadius);
                lstPlanets.Add(objPlanet);

                Ellipse objPlanetEllipse = new Ellipse();
                objPlanetEllipse.Stroke = System.Windows.Media.Brushes.Red;
                objPlanetEllipse.Fill   = System.Windows.Media.Brushes.DarkBlue;
                objPlanetEllipse.HorizontalAlignment = HorizontalAlignment.Left;
                objPlanetEllipse.VerticalAlignment   = VerticalAlignment.Center;
                objPlanetEllipse.Width  = 10;
                objPlanetEllipse.Height = 10;
                objPlanetUI             = new PlanetUI(objPlanet, objPlanetEllipse);
                lstPlanetUI.Add(objPlanetUI);

                Canvas.SetLeft(objPlanetUI.Ellipse, objPlanetParams.PosX);
                Canvas.SetTop(objPlanetUI.Ellipse, objPlanetParams.PosY);

                mainCanvas.Children.Add(objPlanetUI.Ellipse);

                // moon around mars
                //{
                //    PositionParams objMoonParams = new PositionParams();
                //    objMoonParams.PosX = 50;
                //    objMoonParams.PosY = 50;
                //    objMoonParams.Angle = 100;
                //    // was 0.003
                //    objMoonParams.Velocity = 0.070;
                //    // was 400
                //    objMoonParams.Radius = 50;

                //    double dblMoonPullRadius = 10;
                //    objPlanetMoon = new Planet(objPlanet, objMoonParams, "MarsMoon", dblMoonPullRadius);
                //    lstPlanets.Add(objPlanetMoon);

                //    Ellipse objMoonEllipse = new Ellipse();
                //    objMoonEllipse.Stroke = System.Windows.Media.Brushes.DarkOrange;
                //    objMoonEllipse.Fill = System.Windows.Media.Brushes.DarkOrange;
                //    objMoonEllipse.HorizontalAlignment = HorizontalAlignment.Left;
                //    objMoonEllipse.VerticalAlignment = VerticalAlignment.Center;
                //    objMoonEllipse.Width = 5;
                //    objMoonEllipse.Height = 5;
                //    objPlanetMoonUI = new PlanetUI(objPlanetMoon, objMoonEllipse);
                //    lstPlanetUI.Add(objPlanetMoonUI);

                //    Canvas.SetLeft(objPlanetMoonUI.Ellipse, objMoonParams.PosX);
                //    Canvas.SetTop(objPlanetMoonUI.Ellipse, objMoonParams.PosY);

                //    mainCanvas.Children.Add(objPlanetMoonUI.Ellipse);


                //}
            }



            // earth
            {
                PositionParams objPlanet2Params = new PositionParams();
                objPlanet2Params.PosX     = 150;
                objPlanet2Params.PosY     = 150;
                objPlanet2Params.Angle    = 100;
                objPlanet2Params.Velocity = 0.01;
                objPlanet2Params.Radius   = 150;


                double dblEarthPullRadius = 15;
                objPlanet2 = new Planet(objSun, objPlanet2Params, "Earth", dblEarthPullRadius);
                lstPlanets.Add(objPlanet2);

                Ellipse objPlanet2Ellipse = new Ellipse();
                objPlanet2Ellipse.Stroke = System.Windows.Media.Brushes.Blue;
                objPlanet2Ellipse.Fill   = System.Windows.Media.Brushes.LightBlue;
                objPlanet2Ellipse.HorizontalAlignment = HorizontalAlignment.Left;
                objPlanet2Ellipse.VerticalAlignment   = VerticalAlignment.Center;
                objPlanet2Ellipse.Width  = 10;
                objPlanet2Ellipse.Height = 10;
                objPlanetUI2             = new PlanetUI(objPlanet2, objPlanet2Ellipse);
                lstPlanetUI.Add(objPlanetUI2);

                Canvas.SetLeft(objPlanetUI2.Ellipse, objPlanet2Params.PosX);
                Canvas.SetTop(objPlanetUI2.Ellipse, objPlanet2Params.PosY);

                mainCanvas.Children.Add(objPlanetUI2.Ellipse);
            }

            // venus
            {
                PositionParams objPlanet3Params = new PositionParams();
                objPlanet3Params.PosX     = 160;
                objPlanet3Params.PosY     = 160;
                objPlanet3Params.Angle    = 100;
                objPlanet3Params.Velocity = 0.01;
                objPlanet3Params.Radius   = 50;

                double dblVenusPullRadius = 15;
                objPlanet3 = new Planet(objSun, objPlanet3Params, "Venus", dblVenusPullRadius);
                lstPlanets.Add(objPlanet3);

                Ellipse objPlanet3Ellipse = new Ellipse();
                objPlanet3Ellipse.Stroke = System.Windows.Media.Brushes.Gold;
                objPlanet3Ellipse.Fill   = System.Windows.Media.Brushes.Goldenrod;
                objPlanet3Ellipse.HorizontalAlignment = HorizontalAlignment.Left;
                objPlanet3Ellipse.VerticalAlignment   = VerticalAlignment.Center;
                objPlanet3Ellipse.Width  = 10;
                objPlanet3Ellipse.Height = 10;
                objPlanetUI3             = new PlanetUI(objPlanet3, objPlanet3Ellipse);
                lstPlanetUI.Add(objPlanetUI3);

                Canvas.SetLeft(objPlanetUI3.Ellipse, objPlanet3Params.PosX);
                Canvas.SetTop(objPlanetUI3.Ellipse, objPlanet3Params.PosY);

                mainCanvas.Children.Add(objPlanetUI3.Ellipse);
            }

            // Jupiter
            {
                PositionParams objPlanet4Params = new PositionParams();
                objPlanet4Params.PosX     = 165;
                objPlanet4Params.PosY     = 165;
                objPlanet4Params.Angle    = 100;
                objPlanet4Params.Velocity = 0.009;
                objPlanet4Params.Radius   = 420;

                double dblSaturnPullRadius = 30;
                objPlanet4 = new Planet(objSun, objPlanet4Params, "Jupiter", dblSaturnPullRadius);
                lstPlanets.Add(objPlanet4);

                Ellipse objPlanet4Ellipse = new Ellipse();
                objPlanet4Ellipse.Stroke = System.Windows.Media.Brushes.Blue;
                objPlanet4Ellipse.Fill   = System.Windows.Media.Brushes.DarkBlue;
                objPlanet4Ellipse.HorizontalAlignment = HorizontalAlignment.Left;
                objPlanet4Ellipse.VerticalAlignment   = VerticalAlignment.Center;
                objPlanet4Ellipse.Width  = 12;
                objPlanet4Ellipse.Height = 12;
                objPlanetUI4             = new PlanetUI(objPlanet4, objPlanet4Ellipse);
                lstPlanetUI.Add(objPlanetUI4);

                Canvas.SetLeft(objPlanetUI4.Ellipse, objPlanet4Params.PosX);
                Canvas.SetTop(objPlanetUI4.Ellipse, objPlanet4Params.PosY);

                mainCanvas.Children.Add(objPlanetUI4.Ellipse);
            }

            // saturn
            {
                PositionParams objPlanet5Params = new PositionParams();
                objPlanet5Params.PosX     = 170;
                objPlanet5Params.PosY     = 170;
                objPlanet5Params.Angle    = 100;
                objPlanet5Params.Velocity = 0.008;
                objPlanet5Params.Radius   = 450;

                double dblPlanet5PullRadius = 40;
                objPlanet5 = new Planet(objSun, objPlanet5Params, "Saturn", dblPlanet5PullRadius);
                lstPlanets.Add(objPlanet5);

                Ellipse objPlanet5Ellipse = new Ellipse();
                objPlanet5Ellipse.Stroke = System.Windows.Media.Brushes.Green;
                objPlanet5Ellipse.Fill   = System.Windows.Media.Brushes.DarkGreen;
                objPlanet5Ellipse.HorizontalAlignment = HorizontalAlignment.Left;
                objPlanet5Ellipse.VerticalAlignment   = VerticalAlignment.Center;
                objPlanet5Ellipse.Width  = 15;
                objPlanet5Ellipse.Height = 15;
                objPlanetUI5             = new PlanetUI(objPlanet5, objPlanet5Ellipse);
                lstPlanetUI.Add(objPlanetUI5);

                Canvas.SetLeft(objPlanetUI5.Ellipse, objPlanet5Params.PosX);
                Canvas.SetTop(objPlanetUI5.Ellipse, objPlanet5Params.PosY);

                mainCanvas.Children.Add(objPlanetUI5.Ellipse);
            }

            // satellite
            {
                PositionParams objSatelliteParams = new PositionParams();
                objSatelliteParams.PosX  = 0;
                objSatelliteParams.PosY  = 0;
                objSatelliteParams.Angle = 100;
                // 20/11/16 original test params
                objSatelliteParams.Velocity = 0.08;
                //objSatelliteParams.Radius = 20;
                //objSatelliteParams.Velocity = 0.2;
                // was 40
                objSatelliteParams.Radius = 20;

                // start round earth
                objSatellite = new Satellite(objPlanet2, objSatelliteParams, false, lstPlanets);

                Ellipse objSatelliteEllipse = new Ellipse();
                objSatelliteEllipse.Stroke = System.Windows.Media.Brushes.Black;
                objSatelliteEllipse.Fill   = System.Windows.Media.Brushes.Red;
                objSatelliteEllipse.HorizontalAlignment = HorizontalAlignment.Left;
                objSatelliteEllipse.VerticalAlignment   = VerticalAlignment.Center;
                objSatelliteEllipse.Width  = 10;
                objSatelliteEllipse.Height = 10;
                objSatelliteUI             = new SatelliteUI(objSatellite, objSatelliteEllipse);

                Canvas.SetLeft(objSatelliteUI.Ellipse, objSatelliteParams.PosX);
                Canvas.SetTop(objSatelliteUI.Ellipse, objSatelliteParams.PosY);

                mainCanvas.Children.Add(objSatelliteUI.Ellipse);
            }



            // initialise view observer
            objViewObserver = new ViewObserver(this, lstPlanetUI, objSatelliteUI);

            // initialise runitme controller
            objTravellerRunTime = new TravellerRunTime(lstPlanets, objSatellite, objSun, objViewObserver);

            // set true to use debugging window
            bDebug = false;
            if (bDebug)
            {
                bTracePlanets   = false;
                bTraceSatOrbit  = false;
                bTraceSatTravel = false;
                bStep           = false;
                objDebugWindow  = new DebugWindow(this);
                objDebugWindow.Show();
            }

            // start the main thread running
            objTravellerRunTime.StartRunning();
        }
Exemple #6
0
 void UpdateInterPlanetaryPosition(Satellite pvSatellite)
 {
     pvSatellite.UpdateInterPlanetaryPosition();
 }
Exemple #7
0
 void UpdateOrbitPosition(Satellite pvSatellite)
 {
     pvSatellite.updateOrbitPosition();
 }
Exemple #8
0
 public SatelliteUI(Satellite pvSatellite, Ellipse pvEllipse)
 {
     objSatellite = pvSatellite;
     objEllipse   = pvEllipse;
 }