Ejemplo n.º 1
0
        private void UpdatePosition()
        {
            double posX = 0;
            double posY = 0;


            for (int i = 0; i < solarSystem.Count; i++)
            {
                Ellipse e = (Ellipse)VisualTreeHelper.GetChild(spaceFrame, i);

                pos = solarSystem[i].CalcPosition(time);
                double posXCenter = origoX - e.Width * 0.5;
                double posYCenter = origoY - e.Height * 0.5;

                if (solarSystem[i] is Moon)
                {
                    Moon                   moon      = (Moon)solarSystem[i];
                    SpaceObjects           Parent    = moon.parent;
                    Tuple <double, double> parentPos = Parent.CalcPosition(time);
                    posX = (posXCenter + parentPos.Item1) + pos.Item1;
                    posY = (posYCenter + parentPos.Item2) + pos.Item2;
                }
                else
                {
                    posX = origoX - e.Width * 0.5 + pos.Item1;
                    posY = origoY - e.Height * 0.5 + pos.Item2;
                }
                positions[i] = new Point(posX, posY);

                Canvas.SetTop(e, posY);
                Canvas.SetLeft(e, posX);
            }
        }
Ejemplo n.º 2
0
        public SolarSystemProgram()
        {
            Moon  moon1 = new Moon();
            Sun   sun1  = new Sun();
            Stars stars = new Stars();
            Earth earth = new Earth();

            int month = 0;

            // The Unix epoch (or Unix time or POSIX time or Unix timestamp)
            // is the number of seconds that have elapsed since January 1, 1970
            var computerTime = Math.Round((DateTime.Now.Subtract(new System.DateTime(1970, 1, 1))).TotalDays / 365);

            for (long year = 0; year < computerTime; year++)
            {
                // Earth completes it's orbit once a year
                Planet.CompletedRotation();

                // lunar eclipse 0-3 times per year
                for (int day = 0; day < 365; day++)
                {
                    // Earth completing 1 rotation creates 1 day
                    Planet.CompletedRotation();

                    // The moon pulls tides every day
                    Moon.PullTides();
                    if (day % 30 == 0)
                    {
                        // The moon completes it's orbit and a full rotation once a month
                        Moon.CompletedOrbit();
                        Moon.CompletedRotation();
                        month++;
                    }

                    // The moon wanes and waxes mid-way
                    if (day % 15 == 0)
                    {
                        moon1.waning = !moon1.waning;
                        moon1.waxing = !moon1.waxing;
                    }
                }

                Console.WriteLine(new DateTime(1970, 1, 1).ToString("d"));

                //Light travels 300,000 kilometers per second!
                int kilometers = 300000;
                int second     = 1;

                // One lightyear is 9.5 trillion km
                // new LightYear(kilometers, second);
                var ly = new LightYear(kilometers, second);
            }
        }
Ejemplo n.º 3
0
 public Planet(float radius, String name, Vector3 position, String imagePath, bool hasMoon, float orbitSpeed)
 {
     this.radius        = radius;
     this.name          = name;
     this.imagePathID   = loadTexture(imagePath);
     this.position      = position;
     this.hasMoon       = hasMoon;
     this.orbitRotation = r.Next(360);
     this.orbitSpeed    = orbitSpeed;
     if (hasMoon)
     {
         moon = new Moon(radius / 5, "Moon", this.position, "textures/moon.jpg");
     }
 }
Ejemplo n.º 4
0
        public SolarSystemProgram()
        {
            Moon  moon1 = new Moon();
            Sun   sun1  = new Sun();
            Stars stars = new Stars();
            Earth earth = new Earth();

            var month = 0;

            // The Unix epoch (or Unix time or POSIX time or Unix timestamp)
            // is the number of seconds that have elapsed since January 1, 1970
            var computerTime = Math.Round((DateTime.Now.Subtract(new System.DateTime(1970, 1, 1))).TotalDays / 365);

            for (long year = 0; year < computerTime; year++)
            {
                // Earth completes it's orbit once a year
                earth.CompletedOrbit();

                // lunar eclipse 0-3 times per year
                for (int day = 0; day < 365; day++)
                {
                    // Earth completing 1 rotation creates 1 day
                    earth.CompletedRotation();

                    // The moon pulls tides every day
                    moon1.PullTides();
                    if (day % 30 == 0)
                    {
                        // The moon completes it's orbit and a full rotation once a month
                        moon1.CompletedOrbit();
                        moon1.CompletedRotation();
                        month++;
                    }

                    // The moon wanes and waxes mid-way
                    if (day % 15 == 0)
                    {
                        moon1.waning = !moon1.waning;
                        moon1.waxing = !moon1.waxing;
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public List <SpaceObject> fakeSolarSystem()
        {
            Star   Sun     = new Star("Sun", 0, 0, 60000, 0, "Orange");
            Planet Mercury = new Planet("Mercury", 80, 88, 6000, 59, "Aquamarine");
            Planet Venus   = new Planet("Venus", 120, 225, 10000, 243, "DarkGoldenrod");
            Planet Earth   = new Planet("Earth", 150, 365, 11000, 1, "SteelBlue");
            Planet Mars    = new Planet("Mars", 180, 687, 9800, 1.025, "Brown");
            Planet Jupiter = new Planet("Jupiter", 240, 20000, 32000, 0.4125, "Salmon");
            Planet Saturn  = new Planet("Saturn", 300, 18000, 30004, 0.417, "BurlyWood");
            Planet Uranus  = new Planet("Uranus", 360, 30685, 18000, 0.67, "DeepSkyBlue");
            Planet Neptun  = new Planet("Neptun", 400, 60190, 17000, 0.71, "DodgerBlue");

            Moon TheMoon = new Moon("The Moon", 16, 27.322, 3800, 27, "White");
            Moon Phobos  = new Moon("Phobos", 10, 0.3189, 3500, 0.3, "GRAY");

            Mercury.setParent(Sun);
            Venus.setParent(Sun);
            Earth.setParent(Sun);
            Mars.setParent(Sun);
            Jupiter.setParent(Sun);
            Saturn.setParent(Sun);
            Uranus.setParent(Sun);
            Neptun.setParent(Sun);
            TheMoon.setParent(Earth);
            Phobos.setParent(Mars);
            Earth.setChild(TheMoon);
            Mars.setChild(Phobos);
            list.Add(Sun);
            list.Add(Mercury);
            list.Add(Venus);
            list.Add(Earth);
            list.Add(Mars);
            list.Add(Jupiter);
            list.Add(Saturn);
            list.Add(Uranus);
            list.Add(Neptun);
            list.Add(TheMoon);
            list.Add(Phobos);
            return(list);
        }
Ejemplo n.º 6
0
        public List <SpaceObject> realSolarSystem()
        {
            Star   Sun     = new Star("Sun", 0, 0, 696340, 0, "Crimson");
            Planet Mercury = new Planet("Mercury", 57910, 87.97, 2439.5, 59, "Aquamarine");
            Planet Venus   = new Planet("Venus", 108200, 224.70, 6052, 243, "DarkGoldenrod");
            Planet Earth   = new Planet("Earth", 149600, 365.26, 6371, 1, "SteelBlue");
            Planet Mars    = new Planet("Mars", 227940, 686.98, 3402.5, 1.025, "Brown");
            Planet Jupiter = new Planet("Jupiter", 778330, 4332.71, 69911, 0.4125, "Salmon");
            Planet Saturn  = new Planet("Saturn", 1429400, 10759.5, 60268, 0.417, "BurlyWood");
            Planet Uranus  = new Planet("Uranus", 2870990, 30685, 25559, 0.67, "DeepSkyBlue");
            Planet Neptun  = new Planet("Neptun", 4504300, 60190, 24764, 0.708, "DodgerBlue");
            Moon   TheMoon = new Moon("The Moon", 0.384, 27.322, 1737.1, 27, "Gray");
            Moon   Phobos  = new Moon("Phobos", 0.000009, 0.32, 11.25, 0.3, "Gray");

            Mercury.setParent(Sun);
            Venus.setParent(Sun);
            Earth.setParent(Sun);
            Mars.setParent(Sun);
            Jupiter.setParent(Sun);
            Saturn.setParent(Sun);
            Uranus.setParent(Sun);
            Neptun.setParent(Sun);
            TheMoon.setParent(Earth);
            Phobos.setParent(Mars);
            Earth.setChild(TheMoon);
            Mars.setChild(Phobos);
            RealList.Add(Sun);
            RealList.Add(Mercury);
            RealList.Add(Venus);
            RealList.Add(Earth);
            RealList.Add(Mars);
            RealList.Add(Jupiter);
            RealList.Add(Saturn);
            RealList.Add(Uranus);
            RealList.Add(Neptun);
            RealList.Add(TheMoon);
            RealList.Add(Phobos);
            return(RealList);
        }
Ejemplo n.º 7
0
        public List <Moon> GetListOfMoons()
        {
            string fileName = (Name + ".txt");
            string path     = Path.Combine(Directory.GetCurrentDirectory(), fileName);

            //string path = "C:/Users/user/Desktop/Specter_C#/ClassProjects/SolarSystem/" + Name + ".txt";

            string[] lines = File.ReadAllLines(path);

            List <Moon> moons = new List <Moon>();

            for (int i = 0; i < lines.Length; i++)
            {
                Moon     sat   = new Moon();
                string[] words = lines[i].Split('#');
                sat.Name     = words[0];
                sat.Diameter = double.Parse(words[1]);
                sat.Mass     = double.Parse(words[2]);

                moons.Add(sat);
            }

            return(moons);
        }
Ejemplo n.º 8
0
        protected override void Initialize()
        {
            Sun = new Sun(0, 0, 0);
            Earth = new Earth();
            Moon = new Moon();

            Children.Add(Sun);
            Children.Add(Earth);
            Children.Add(Moon);
            Children.Add(new Monitor());

            base.Initialize();
        }
Ejemplo n.º 9
0
        static void Main(string[] args)
        {
            Planet Earth = new Planet("Earth");

            Earth.Mass = 34;
            //Satellite Moon = new Satellite("Moon");
            //Earth.SetSatellites(Moon);



            test[] items = new test[4];

            //test first = new test { x = "Jupiter", y = 2 };
            //test second = new test { x = "Saturn", y = 0 };

            items[0] = new test {
                x = "Jupiter", y = 2
            };
            items[1] = new test {
                x = "Saturn", y = 0
            };
            items[2] = new test {
                x = "Jungo", y = 3
            };
            items[3] = new test {
                x = "Pluto", y = 0
            };

            var filteredNames  = items.OrderBy(n => n.y);
            int min            = filteredNames.First().y;
            var filteredNames2 = items.Where(n => n.y == min);

            //Console.WriteLine(filteredNames.First().y);
            foreach (test name in filteredNames2)
            {
                Console.WriteLine(name.x + " " + name.y);
            }

            Moon first  = new Moon("First", 20, 34.9);
            Moon second = new Moon("Second", 24, 35.8);
            Moon third  = new Moon("Third", 11, 5.8);

            List <Moon> Moons = new List <Moon>();

            Moons.Add(first);
            Moons.Add(second);
            Moons.Add(third);

            Moons.Sort();


            Planet Neptune = new Planet("Neptune");

            List <Moon> MoonsOfNeptune = Neptune.GetListOfMoons();

            MoonsOfNeptune.Sort();

            foreach (var item in MoonsOfNeptune)
            {
                Console.WriteLine(item.ToString());
            }
        }
Ejemplo n.º 10
0
        protected override void Initialize()
        {
            Setting = new Setting();
            Camera = new Camera();
            Children = new List<GameEntity>();

            Skybox = new Skybox();
            Sound = new Sound();
            Sun = new Sun(0, 0, 0);
            Earth = new Earth();
            Moon = new Moon();

            Children.Add(Sound);
            Children.Add(Sun);
            Children.Add(Earth);
            Children.Add(Moon);
            Children.Add(new SatelliteManager());
            Children.Add(new Monitor());

            base.Initialize();
        }