Inheritance: MonoBehaviour
        public void TestDay12Part1()
        {
            var moon1 = new Moon {
                Name = "Io", X = -10, Y = -13, Z = 7
            };
            var moon2 = new Moon {
                Name = "Europa", X = 1, Y = 2, Z = 1
            };
            var moon3 = new Moon {
                Name = "Ganymede", X = -15, Y = -3, Z = 13
            };
            var moon4 = new Moon {
                Name = "Callisto", X = 3, Y = 7, Z = -4
            };

            var system = new MoonSystem();

            system.AddMoon(moon1);
            system.AddMoon(moon2);
            system.AddMoon(moon3);
            system.AddMoon(moon4);

            var output = system.CalculateTotalEnergy(1000);

            Assert.AreEqual(8454, output);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Makes a moon
        /// </summary>
        /// <param name="endDest">The final destination of the moon</param>
        internal void MakeMoon(Point endDest)
        {
            //Exit if the moons are full
            if (_moons.Count >= MAX_MOONS)
            {
                return;
            }

            //Check if its time to shoot (used for moons)
            if (ShouldShoot(null))
            {
                //Create the bounds for the moon
                Rectangle moonBounds = Bounds;

                //Set the moon size
                moonBounds.Size = _moonSize;

                //Create the moon
                Moon moon = new Moon(_row, _col, moonBounds, endDest);

                //Add the moon to the list
                _moons.Add(moon);
                _moonsToDraw.Add(moon);

                //Cascade all of the moons
                CascadeMoons();
            }
        }
Ejemplo n.º 3
0
        protected override void Seed(DAL.SolarSystemDbContext context)
        {
            var star = new Star {
                Name = "Sun", Ordinal = 1, CreatedDate = DateTime.Now, LastUpdatedDate = DateTime.Now
            };
            var planet = new Planet {
                Name = "Earth", Ordinal = 3, CreatedDate = DateTime.Now, LastUpdatedDate = DateTime.Now, Star = star
            };
            var moon = new Moon {
                Name = "Moon", Ordinal = 1, CreatedDate = DateTime.Now, LastUpdatedDate = DateTime.Now, Planet = planet
            };
            var detailedProfile = new Profile
            {
                Id           = 1,
                Introduction = "Introduction",
                Content      = "Content",
                HasRings     = false,
                TypeId       = 1,
                TypeName     = "Planet"
            };

            context.Stars.AddOrUpdate(star);
            context.Planets.AddOrUpdate(planet);
            context.Moons.AddOrUpdate(moon);
            context.DetailedProfiles.AddOrUpdate(detailedProfile);
        }
Ejemplo n.º 4
0
 public void EvaluateGravity(Moon other)
 {
     if (X > other.X)
     {
         VelocityX       -= 1;
         other.VelocityX += 1;
     }
     else if (X < other.X)
     {
         VelocityX       += 1;
         other.VelocityX -= 1;
     }
     if (Y > other.Y)
     {
         VelocityY       -= 1;
         other.VelocityY += 1;
     }
     else if (Y < other.Y)
     {
         VelocityY       += 1;
         other.VelocityY -= 1;
     }
     if (Z > other.Z)
     {
         VelocityZ       -= 1;
         other.VelocityZ += 1;
     }
     else if (Z < other.Z)
     {
         VelocityZ       += 1;
         other.VelocityZ -= 1;
     }
 }
Ejemplo n.º 5
0
        private static void SimulateStep(List <Moon> moons)
        {
            for (int iA = 0; iA < moons.Count - 1; iA++)
            {
                for (int iB = iA + 1; iB < moons.Count; iB++)
                {
                    Moon a = moons[iA], b = moons[iB];
                    for (int j = 0; j < 3; j++)
                    {
                        if (a.Position[j] < b.Position[j])
                        {
                            a.Velocity[j]++;
                            b.Velocity[j]--;
                        }
                        else if (a.Position[j] > b.Position[j])
                        {
                            a.Velocity[j]--;
                            b.Velocity[j]++;
                        }
                    }
                }
            }

            foreach (var moon in moons)
            {
                for (int j = 0; j < 3; j++)
                {
                    moon.Position[j] += moon.Velocity[j];
                }
            }
        }
Ejemplo n.º 6
0
 public void UpdateVelocity(Moon other)
 {
     if (other.X > X)
     {
         Vx++;
     }
     if (other.X < X)
     {
         Vx--;
     }
     if (other.Y > Y)
     {
         Vy++;
     }
     if (other.Y < Y)
     {
         Vy--;
     }
     if (other.Z > Z)
     {
         Vz++;
     }
     if (other.Z < Z)
     {
         Vz--;
     }
 }
Ejemplo n.º 7
0
        public IActionResult Index()
        {
            DateTime birthday  = new DateTime(1991, 6, 5, 8, 26, 00);
            Equator  equator   = Sun.EquatorialCoordinate(birthday);
            Ecliptic mooquator = Moon.EclipticalCoordinate(birthday);
            Ecliptic merquator = Mercury.EclipticalCoordinate(birthday);
            Ecliptic vequator  = Venus.EclipticalCoordinate(birthday);
            Ecliptic mequator  = Mars.EclipticalCoordinate(birthday);
            Ecliptic jequator  = Jupiter.EclipticalCoordinate(birthday);
            Ecliptic sequator  = Saturn.EclipticalCoordinate(birthday);
            Ecliptic urquator  = Uranus.EclipticalCoordinate(birthday);
            Ecliptic nequator  = Neptune.EclipticalCoordinate(DateTime.Now);
            Ecliptic ecliptic  = CoordinateSystem.Equatorial2Ecliptic(equator);

            Debug.WriteLine(DateTime.Now);
            Debug.WriteLine("SUN" + ecliptic.Longitude);
            Debug.WriteLine("Moon" + mooquator.Longitude);
            Debug.WriteLine("MERC: " + merquator.Longitude);
            Debug.WriteLine("VENUS" + vequator.Longitude);
            Debug.WriteLine("Mars" + mequator.Longitude);
            Debug.WriteLine("Jup: " + jequator.Longitude);
            Debug.WriteLine("Saturn: " + sequator.Longitude);
            Debug.WriteLine("Urnuas: " + urquator.Longitude);
            Debug.WriteLine("Neptune: " + nequator.Longitude);

            return(View());
        }
        public void TestSimulate()
        {
            MotionSimulator ms = new MotionSimulator();

            Moon A = new Moon(-1, 0, 2);
            Moon B = new Moon(2, -10, -7);
            Moon C = new Moon(4, -8, 8);
            Moon D = new Moon(3, 5, -1);

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

            moons.Add(A);
            moons.Add(B);
            moons.Add(C);
            moons.Add(D);

            ms.Simulate(moons, 10);

            Assert.That(A.PosX, Is.EqualTo(2));
            Assert.That(A.PosY, Is.EqualTo(1));
            Assert.That(A.PosZ, Is.EqualTo(-3));
            Assert.That(A.VelX, Is.EqualTo(-3));
            Assert.That(A.VelY, Is.EqualTo(-2));
            Assert.That(A.VelZ, Is.EqualTo(1));
        }
Ejemplo n.º 9
0
    void Update()
    {
        Sun.Rotate(Vector3.up * Time.deltaTime * 5);

        Mercury.RotateAround(Sun.position, new Vector3(0.1f, 1, 0), 60 * Time.deltaTime);
        Mercury.Rotate(Vector3.up * 10000 / 58 * Time.deltaTime);

        Venus.RotateAround(Sun.position, new Vector3(0, 1, -0.1f), 55 * Time.deltaTime);
        Venus.Rotate(Vector3.up * 10000 / 243 * Time.deltaTime);

        Earth.RotateAround(Sun.position, Vector3.up, 50 * Time.deltaTime);
        Earth.Rotate(Vector3.up * 10000 * Time.deltaTime);
        Moon.RotateAround(Earth.position, Vector3.up, 5 * Time.deltaTime);
        Moon.Rotate(Vector3.up * 10000 / 27 * Time.deltaTime);

        Mars.RotateAround(Sun.position, new Vector3(0.2f, 1, 0), 45 * Time.deltaTime);
        Mars.Rotate(Vector3.up * 10000 * Time.deltaTime);

        Jupiter.RotateAround(Sun.position, new Vector3(-0.1f, 2, 0), 38 * Time.deltaTime);
        Jupiter.Rotate(Vector3.up * 10000 / 0.3f * Time.deltaTime);

        Saturn.RotateAround(Sun.position, new Vector3(0, 1, 0.2f), 36 * Time.deltaTime);
        Saturn.Rotate(Vector3.up * 10000 / 0.4f * Time.deltaTime);

        Uranus.RotateAround(Sun.position, new Vector3(0, 2, 0.1f), 35 * Time.deltaTime);
        Uranus.Rotate(Vector3.up * 10000 / 0.6f * Time.deltaTime);

        Neptune.RotateAround(Sun.position, new Vector3(-0.1f, 1, -0.1f), 33 * Time.deltaTime);
        Neptune.Rotate(Vector3.up * 10000 / 0.7f * Time.deltaTime);
    }
Ejemplo n.º 10
0
            public void ApplyGravity(Moon other)
            {
                var x = Velocity.X;
                var y = Velocity.Y;
                var z = Velocity.Z;

                if (other.Position.X < Position.X)
                {
                    x -= 1;
                }
                else if (other.Position.X > Position.X)
                {
                    x += 1;
                }

                if (other.Position.Y < Position.Y)
                {
                    y -= 1;
                }
                else if (other.Position.Y > Position.Y)
                {
                    y += 1;
                }

                if (other.Position.Z < Position.Z)
                {
                    z -= 1;
                }
                else if (other.Position.Z > Position.Z)
                {
                    z += 1;
                }

                Velocity = new Point(x, y, z);
            }
Ejemplo n.º 11
0
    private void DrawMoonsOrbit(PlanetSystem planetSystem)
    {
        GameObject folder    = GameObject.Find(folderOrbits);
        float      PointStep = (Mathf.PI * 2 / Settings.LineOrbit.CIRCLES_POINS);
        float      ROrbit;

        for (int m = 0; m < planetSystem.moonsArray.Length; m++)
        {
            Moon moon = planetSystem.moonsArray[m];
            ROrbit = (moon.orbitNumber + Settings.LineOrbit.EMPTY_PLANET_ORBITS_COUNT) * Settings.LineOrbit.ORBIT_MOON_SIZE;
            Vector3[]  vec3arr   = new Vector3[Settings.LineOrbit.CIRCLES_POINS + 1];
            GameObject lineOrbit = new GameObject();
            for (int i = 0; i < Settings.LineOrbit.CIRCLES_POINS; i++)
            {
                vec3arr[i] = new Vector3((int)ROrbit * Mathf.Cos(i * PointStep), (int)ROrbit * Mathf.Sin(i * PointStep), 0)
                             + planetSystem.planet.position;
            }
            vec3arr[vec3arr.Length - 1] = vec3arr[0];
            lineOrbit.name = "orbit moon" + moon.name;
            lineOrbit.AddComponent <ShowOrbitScript>();
            lineOrbit.AddComponent <LineRenderer>();
            LineRenderer lineRender = lineOrbit.GetComponent <LineRenderer>();
            lineRender.positionCount = Settings.LineOrbit.CIRCLES_POINS + 1;
            lineRender.SetPositions(vec3arr);
            lineRender.startColor = lineRender.endColor = Settings.LineOrbit.COLOR;
            lineRender.material   = new Material(Shader.Find("Legacy Shaders/Particles/Additive"));
            lineRender.transform.SetParent(folder.transform);
        }
    }
Ejemplo n.º 12
0
 private void ApplyVelocity(Moon moon)
 {
     for (int i = 0; i < 3; i++)
     {
         moon.Position[i] += moon.Velocity[i];
     }
 }
Ejemplo n.º 13
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == Asteroid.ASTEROID_TAG)
     {
         Asteroid collidedAsteroid = other.gameObject.GetComponent <Asteroid>();
         collidedAsteroid.ReceiveDamage(m_Damage);
         hitCallback();
         if (mNumberOfPiercesLeft == 0)
         {
             PutPropulsionEffectForAdoption();
             Destroy(this.gameObject);
         }
         else
         {
             mNumberOfPiercesLeft--;
             mHasHitOnce = true;
         }
     }
     else if (other.gameObject.tag == Moon.MOON_TAG)
     {
         Moon collidedMoon = other.gameObject.GetComponent <Moon>();
         collidedMoon.ReceiveDamage(m_Damage);
         PutPropulsionEffectForAdoption();
         Destroy(this.gameObject);
     }
 }
Ejemplo n.º 14
0
    private void DrawMoons(PlanetSystem planetSys, Vector3 planetPos)
    {
        float y     = 20;
        int   step  = 16;
        float scale = 6f;

        if (planetSys.moonsArray == null)
        {
            return;
        }
        for (int i = 0; i < planetSys.moonsArray.Length; i++)
        {
            Moon       moon = planetSys.moonsArray[i];
            GameObject go   = GameObject.Instantiate(
                PrefabService.PlanetSystemMap[moon.type],
                new Vector3(planetPos.x, planetPos.y - i * step - y, planetPos.z),
                Quaternion.identity);

            go.transform.SetParent(folder.transform);
            go.name = moon.name;
            go.transform.localScale = new Vector3(scale, scale, scale);

            GameObject.Destroy(go.GetComponent <PlanetSysMapScr>());
            var scr = go.AddComponent <SystemViewerPlanetScr>();
            scr.subStarBody = moon;
            planetsSystemObjects.Add(go);
            scr.systemObjects = planetsSystemObjects;
            scr.oldScale      = go.transform.localScale;
        }
    }
Ejemplo n.º 15
0
        private int CalculateEnergy(Moon moon)
        {
            var potential = Math.Abs(moon.PosX) + Math.Abs(moon.PosY) + Math.Abs(moon.PosZ);
            var kinetic   = Math.Abs(moon.VelX) + Math.Abs(moon.VelY) + Math.Abs(moon.VelZ);

            return(potential * kinetic);
        }
Ejemplo n.º 16
0
        static void Main(string[] args)
        {
            RenderWindow app = new RenderWindow(new VideoMode(800, 600), "Metonic Calendar");

            app.Closed += new EventHandler(OnClose);

            Nodes        nodes    = new Nodes();
            Sun          sun      = new Sun(nodes);
            Moon         moon     = new Moon();
            IMetonicYear year     = new MetonicYear();
            IMonth       month    = new Month(year, sun, moon);
            Day          day      = new Day(month, year);
            SunCount     sunCount = new SunCount(sun);

            Control controller = new Control(year, month, day, moon, sunCount, nodes, sun);

            controller.SetYearZero();

            Color windowColor = new Color(255, 255, 255);

            while (app.IsOpen)
            {
                app.DispatchEvents();
                app.Clear(windowColor);

                DrawCalendar(app, nodes, sun, moon, year, month, day, sunCount);

                app.Display();
                controller.AddDay();
                Thread.Sleep(1000);
            }
        }
Ejemplo n.º 17
0
        private static void BuildPlanetData(SpaceDatabaseContext context)
        {
            var mercury = new Planet
            {
                Name = "Mercury",
                Mass = "3.285 × 10^23 kg",
            };

            var venus = new Planet
            {
                Name = "Venus",
                Mass = "4.867 × 10^24 kg",
            };


            var moon = new Moon
            {
                Name = "Moon",
            };

            context.Moons.Add(moon);

            var earth = new Planet
            {
                Name  = "Earth",
                Mass  = "5.972 × 10^24 kg",
                Moons = new List <Moon> {
                    moon
                }
            };

            context.Planets.Add(mercury);
            context.Planets.Add(venus);
            context.Planets.Add(earth);
        }
Ejemplo n.º 18
0
        public void TestApplyGravity()
        {
            var moons = Day12.ApplyGravity(new Moon[] {
                Moon.Parse("<x=-1, y=  0, z= 2>"),
                Moon.Parse("<x= 2, y=-10, z=-7>"),
                Moon.Parse("<x= 4, y= -8, z= 8>"),
                Moon.Parse("<x= 3, y=  5, z=-1>"),
            });

            Assert.Equal(3, moons[0].Velocity.X);
            Assert.Equal(-1, moons[0].Velocity.Y);
            Assert.Equal(-1, moons[0].Velocity.Z);

            Assert.Equal(1, moons[1].Velocity.X);
            Assert.Equal(3, moons[1].Velocity.Y);
            Assert.Equal(3, moons[1].Velocity.Z);

            Assert.Equal(-3, moons[2].Velocity.X);
            Assert.Equal(1, moons[2].Velocity.Y);
            Assert.Equal(-3, moons[2].Velocity.Z);

            Assert.Equal(-1, moons[3].Velocity.X);
            Assert.Equal(-3, moons[3].Velocity.Y);
            Assert.Equal(1, moons[3].Velocity.Z);
        }
Ejemplo n.º 19
0
        static void ApplyGravity(Moon m1, Moon m2)
        {
            if (m1.X > m2.X)
            {
                m1.vX -= 1;
                m2.vX += 1;
            }
            else if (m1.X < m2.X)
            {
                m1.vX += 1;
                m2.vX -= 1;
            }

            if (m1.Y > m2.Y)
            {
                m1.vY -= 1;
                m2.vY += 1;
            }
            else if (m1.Y < m2.Y)
            {
                m1.vY += 1;
                m2.vY -= 1;
            }

            if (m1.Z > m2.Z)
            {
                m1.vZ -= 1;
                m2.vZ += 1;
            }
            else if (m1.Z < m2.Z)
            {
                m1.vZ += 1;
                m2.vZ -= 1;
            }
        }
Ejemplo n.º 20
0
            public void ApplyGravity(Moon other)
            {
                var d = Location.SignedDifferenceFrom(other.Location);

                Velocity       -= d;
                other.Velocity += d;
            }
Ejemplo n.º 21
0
        private T General <T>(BreakCondition condition, PostRunner <T> postRunner)
        {
            var lines = FileLines;
            var moons = new Moon[lines.Length];

            for (int i = 0; i < lines.Length; i++)
            {
                moons[i] = Moon.Parse(lines[i]);
            }

            long steps  = 0;
            long xSteps = 0;
            long ySteps = 0;
            long zSteps = 0;

            for (; condition(steps, moons, ref xSteps, ref ySteps, ref zSteps); steps++)
            {
                for (int j = 0; j < moons.Length; j++)
                {
                    for (int k = j + 1; k < moons.Length; k++)
                    {
                        moons[j].ApplyGravity(moons[k]);
                    }
                }

                for (int j = 0; j < moons.Length; j++)
                {
                    moons[j].ApplyVelocity();
                }
            }

            return(postRunner(steps, moons, xSteps, ySteps, zSteps));
        }
Ejemplo n.º 22
0
        private void Run_Moon_Faster(object sender, EventArgs e)
        {
            Action run = () => { Moon.Location = new Point(Moon.Location.X + dx, Moon.Location.Y + dy); };

            Moon.Visible = true;

            //updating coordinates

            Task.Run(() =>
            {
                while (true)
                {
                    if (Moon.Location.X + dx <= 0 || Moon.Location.X + dx >= ClientSize.Width - Moon.Width)
                    {
                        dx = -dx;
                        Boing();
                    }

                    if (Moon.Location.Y + dy <= 0 || Moon.Location.Y + dy >= ClientSize.Height - Moon.Height)
                    {
                        dy = -dy;
                        Boing();
                    }


                    Moon.BeginInvoke(run);
                    Thread.Sleep(10);
                }
            });
        }
Ejemplo n.º 23
0
        internal LuniSolarYear(int year)
        {
            Year = year;
            //TimeZone = timeZone;
            var timeZone = ILocalInfoProvider.GetLocalInfoProvider <T>().TimeZone;

            // at 00:00:00 local
            _month11LastYear = Moon.GetNewMoon11(Year - 1, timeZone).Date;
            _month11ThisYear = Moon.GetNewMoon11(Year, timeZone).Date;

            // Convert the local date to UTC date time by adding AddHours(-TimeZone).
            double jdMonth11LastYear = _month11LastYear.AddHours(-timeZone).UniversalDateTimeToJulianDate();
            double jdMonth11ThisYear = _month11ThisYear.AddHours(-timeZone).UniversalDateTimeToJulianDate();

            int k = (int)(0.5 + (jdMonth11LastYear - 2415021.076998695) / 29.530588853);

            IsLeapYear = (jdMonth11ThisYear - jdMonth11LastYear) > 365.0;

            if (!IsLeapYear)
            {
                InitNonLeapYear(k, timeZone);
                Console.WriteLine("None Leap {0}", year);
            }
            else
            {
                InitLeapYear(k, timeZone);
                Console.WriteLine("Leap {0}", year);
            }
        }
Ejemplo n.º 24
0
        public void Setup()
        {
            //Planets
            Planet mercury = new Planet("Mercury");
            Planet venus   = new Planet("Venus");
            Planet earth   = new Planet("Earth");
            Planet mars    = new Planet("Mars");
            Planet jupiter = new Planet("Jupiter");
            Planet saturn  = new Planet("Saturn");
            Planet uranus  = new Planet("Uranus");
            Planet neptune = new Planet("Neptune");
            Planet pluto   = new Planet("Pluto");

            //Moons
            Moon luna   = new Moon("Luna", earth);
            Moon phobos = new Moon("Phobos", mars);
            Moon deimos = new Moon("Deimos", mars);
            Moon europa = new Moon("Europa", jupiter);
            Moon titan  = new Moon("Titan", saturn);

            //Relationships
            mercury.AddNextPlanet(venus);
            venus.AddNextPlanet(earth);
            earth.AddNextPlanet(mars);
            mars.AddNextPlanet(jupiter);
            jupiter.AddNextPlanet(saturn);
            saturn.AddNextPlanet(uranus);
            uranus.AddNextPlanet(neptune);
            neptune.AddNextPlanet(pluto);

            currentLocation = earth;
        }
Ejemplo n.º 25
0
 public void calculateNewVelocity(Moon m1)
 {
     if (m1.x > x)
     {
         vX++;
     }
     else if (m1.x < x)
     {
         vX--;
     }
     if (m1.y > y)
     {
         vY++;
     }
     else if (m1.y < y)
     {
         vY--;
     }
     if (m1.z > z)
     {
         vZ++;
     }
     else if (m1.z < z)
     {
         vZ--;
     }
 }
Ejemplo n.º 26
0
        public Moon BuildMoon()
        {
            var newMoon = Moon;

            Moon = new Moon();
            return(newMoon);
        }
Ejemplo n.º 27
0
        public static void solve()
        {
            var input = InputLoader.loadAsStringArray("12");

            var regex = new Regex("<x=(.+), y=(.+), z=(.+)>");

            var moons = new List <Moon>();

            foreach (var line in input)
            {
                MatchCollection matches = regex.Matches(line);

                var moon = new Moon();

                moon.x = int.Parse(matches[0].Groups[1].Value);
                moon.y = int.Parse(matches[0].Groups[2].Value);
                moon.z = int.Parse(matches[0].Groups[3].Value);

                moons.Add(moon);
            }

            for (var step = 0; step < 1000; step++)
            {
                // Apply gravity.
                for (var i = 0; i < moons.Count - 1; i++)
                {
                    for (var j = i + 1; j < moons.Count; j++)
                    {
                        var gravityX = moons[i].x <moons[j].x ? 1 : moons[i].x> moons[j].x ? -1 : 0;
                        moons[i].vx += gravityX;
                        moons[j].vx -= gravityX;

                        var gravityY = moons[i].y <moons[j].y ? 1 : moons[i].y> moons[j].y ? -1 : 0;
                        moons[i].vy += gravityY;
                        moons[j].vy -= gravityY;

                        var gravityZ = moons[i].z <moons[j].z ? 1 : moons[i].z> moons[j].z ? -1 : 0;
                        moons[i].vz += gravityZ;
                        moons[j].vz -= gravityZ;
                    }
                }

                // Apply velocity
                foreach (var moon in moons)
                {
                    moon.x += moon.vx;
                    moon.y += moon.vy;
                    moon.z += moon.vz;
                }
            }

            var sum = 0;

            foreach (var moon in moons)
            {
                sum += (Math.Abs(moon.x) + Math.Abs(moon.y) + Math.Abs(moon.z)) * (Math.Abs(moon.vx) + Math.Abs(moon.vy) + Math.Abs(moon.vz));
            }

            Console.WriteLine(sum);
        }
Ejemplo n.º 28
0
 private void UpdatePosition(Moon moon)
 {
     for (int c = 0; c < 3; c++)
     {
         moon.Pos[c] += moon.Vel[c];
     }
 }
Ejemplo n.º 29
0
 private void CollisionDetection()
 {
     if (Rectangle.Intersect(_player.Rectangle, _goal.Rectangle) != Rectangle.Empty)
     {
         Stop(true);
         CalculateScore();
         _noOfEnemies += _noOfEnemiesIncrement;
         _noOfStars   += _noOfStarsIncrement;
         SetupGame();
     }
     else
     {
         foreach (Npc enemy in _enemies)
         {
             if (Rectangle.Intersect(_player.Rectangle, enemy.Rectangle) != Rectangle.Empty)
             {
                 Stop(true);
                 if (MessageBox.Show($"Final score: {_score}\nNew game?", "Game over", MessageBoxButtons.YesNo) == DialogResult.Yes)
                 {
                     _score       = 0;
                     _moon        = null;
                     _noOfEnemies = _DEFAULT_NO_OF_ENEMIES;
                     _noOfStars   = _DEFAULT_NO_OF_STARS;
                     SetupGame();
                 }
                 else
                 {
                     _gameOver = true;
                     Close();
                 }
                 break;
             }
         }
     }
 }
Ejemplo n.º 30
0
        private static List <IMoon> GetMoons()
        {
            //total magnification  is 1.5
            //this means that magic will be affected by at most 50% yielding a 1.5x increase and a .6666x decrease
            //IE 100 damage becomes 150 at full bonus and 66 at full decrease
            List <IMoon> moons = new List <IMoon>();

            IMoon moon = new Moon();

            //moon.MagicModifier = 1.14M;
            moon.MoonPhaseCycleDays = 13;
            moon.Name = "Luna";
            moons.Add(moon);

            moon = new Moon();
            //moon.MagicModifier = 1.135M;
            moon.MoonPhaseCycleDays = 28;
            moon.Name = "Selene";
            moons.Add(moon);

            moon = new Moon();
            //moon.MagicModifier = 1.165M;
            moon.MoonPhaseCycleDays = 80;
            moon.Name = "Callisto";
            moons.Add(moon);

            moon = new Moon();
            //moon.MagicModifier = 1.06M;
            moon.MoonPhaseCycleDays = 7;
            moon.Name = "Dione";
            moons.Add(moon);

            return(moons);
        }
Ejemplo n.º 31
0
  private void GenerateTestSystem()
  {
    Star = new Star() { Mass = 1, Size = 1, Rotation = 30, System = this, Name = "Sol" };
    var earth = new Planet() { Mass = 1, Size = 1, Rotation = 24, Name = "Earth", Orbit = new Orbit() { MeanDistance = 1, Period = 1, Eccentricity = 0.0167086f, Inclination = 7.155f, PeriapsisArgument= 114.207f, OrbitCentre = Star } };
    var moon = new Moon() { Mass = 0.0123f, Size = 0.273f, Rotation = 27, Name = "Moon", Orbit = new Orbit() { MeanDistance = 0.00257f * 40, Period = 0.0739f, Eccentricity = 0.0549f, Inclination = 5.145f, OrbitCentre = earth } };
    earth.OrbitingObjects.Add(moon);
    Star.OrbitingObjects.Add(earth);

    var jupiter = new Planet() { Mass = 317.8f, Size = 11.209f, Rotation = 9.925f, Name = "Jupiter", Orbit = new Orbit() { MeanDistance = 5.20260f, Period = 11.8618f, Eccentricity = 0.048498f, Inclination = 6.09f, PeriapsisArgument = 273.867f, OrbitCentre = Star } };
    var ganymede = new Planet() { Mass = 0.025f, Size = 0.413f, Rotation = 9.925f, Name = "Ganymede", Orbit = new Orbit() { MeanDistance = 0.00715f * 120, Period = 0.0195f, Eccentricity = 0.0013f, Inclination = 2.214f, OrbitCentre = jupiter } };
    var calisto = new Planet() { Mass = 0.018f, Size = 0.378f, Rotation = 9.925f, Name = "Calisto", Orbit = new Orbit() { MeanDistance = 0.0125f * 80, Period = 0.04569f, Eccentricity = 0.0074f, Inclination = 2.017f, OrbitCentre = jupiter } };
    var io = new Planet() { Mass = 0.015f, Size = 0.286f, Rotation = 9.925f, Name = "Io", Orbit = new Orbit() { MeanDistance = 0.002819f * 250, Period = 0.00484f, Eccentricity = 0.0041f, Inclination = 2.213f, OrbitCentre = jupiter } };
    Star.OrbitingObjects.Add(jupiter);
    jupiter.OrbitingObjects.Add(ganymede);
    jupiter.OrbitingObjects.Add(calisto);
    jupiter.OrbitingObjects.Add(io);

    var saturn = new Planet() { Mass = 95.159f, Size = 9.4492f, Rotation = 10.55f, Name = "Saturn", Orbit = new Orbit() { MeanDistance = 9.554909f, Period = 29.4571f, Eccentricity = 0.05555f, Inclination = 5.51f, PeriapsisArgument = 339.392f, OrbitCentre = Star } };
    var titan = new Planet() { Mass = 0.0225f, Size = 0.404f, Rotation = 10.55f, Name = "Titan", Orbit = new Orbit() { MeanDistance = 0.00816f * 80, Period = 0.043f, Eccentricity = 0.0288f, Inclination = 8.348f, OrbitCentre = saturn } };
    Star.OrbitingObjects.Add(saturn);
    saturn.OrbitingObjects.Add(titan);

    var uranus = new Planet() { Mass = 14.536f, Size = 4.007f, Rotation = 17.1f, Name = "Uranus", Orbit = new Orbit() { MeanDistance = 19.2184f, Period = 84.0205f, Eccentricity = 0.046381f, Inclination = 6.48f, PeriapsisArgument = 96.998f, OrbitCentre = Star } };
    Star.OrbitingObjects.Add(uranus);

    var neptune = new Planet() { Mass = 17.147f, Size = 3.883f, Rotation = 16.02f, Name = "Neptune", Orbit = new Orbit() { MeanDistance = 30.110387f, Period = 164.8f, Eccentricity = 0.009456f, Inclination = 6.43f, PeriapsisArgument = 276.336f, OrbitCentre = Star } };
    Star.OrbitingObjects.Add(neptune);

    var venus = new Planet() { Mass = 0.815f, Size = 0.9499f, Rotation = -5832.6f, Name = "Venus", Orbit = new Orbit() { MeanDistance = 0.723f, Period = 0.615f, Eccentricity = 0.006772f, Inclination = 3.86f, PeriapsisArgument = 54.884f, OrbitCentre = Star } };
    Star.OrbitingObjects.Add(venus);

    var mars = new Planet() { Mass = 0.107f, Size = 0.533f, Rotation = 24.2f, Name = "Mars", Orbit = new Orbit() { MeanDistance = 1.523f, Period = 1.88f, Eccentricity = 0.0934f, Inclination = 5.65f, PeriapsisArgument = 286.502f, OrbitCentre = Star } };
    Star.OrbitingObjects.Add(mars);

    var mercury = new Planet() { Mass = 0.055f, Size = 0.3829f, Rotation = 1407.5f, Name = "Mercury", Orbit = new Orbit() { MeanDistance = 0.387f, Period = 0.240f, Eccentricity = 0.205f, Inclination = 3.38f, PeriapsisArgument = 29.124f, OrbitCentre = Star } };
    Star.OrbitingObjects.Add(mercury);


    //var mercury = new Planet() { Mass = f, Size = f, Rotation = f, Name = "Mercury", Orbit = new Orbit() { MeanDistance = f * 40, Period = f, Eccentricity = f, Inclination = f, PeriapsisArgument = f, OrbitCentre = Star } };
    // var mercury = new Planet() { Mass = f, Size = f, Rotation = f, Name = "Mercury", Orbit = new Orbit() { MeanDistance = f  * 40, Period = f, Eccentricity = f, Inclination = f, PeriapsisArgument = f, OrbitCentre = Star } };
    // var mercury = new Planet() { Mass = f, Size = f, Rotation = f, Name = "Mercury", Orbit = new Orbit() { MeanDistance = f  * 40, Period = f, Eccentricity = f, Inclination = f, PeriapsisArgument = f, OrbitCentre = Star } };
    // var mercury = new Planet() { Mass = f, Size = f, Rotation = f, Name = "Mercury", Orbit = new Orbit() { MeanDistance = f  * 40, Period = f, Eccentricity = f, Inclination = f, PeriapsisArgument = f, OrbitCentre = Star } };
    // var mercury = new Planet() { Mass = f, Size = f, Rotation = f, Name = "Mercury", Orbit = new Orbit() { MeanDistance = f  * 40, Period = f, Eccentricity = f, Inclination = f, PeriapsisArgument = f, OrbitCentre = Star } };
  }
Ejemplo n.º 32
0
		/// <summary>
		/// Draws the PDF element
		/// </summary>
		/// <param name="pdfDraw"></param>
		/// <param name="data"></param>
		public abstract void Draw(Moon.PDFDraw.IPDFDraw pdfDraw, IDictionary data);