Example #1
0
 public static LiteCelestialBody ToLiteCelestialBody(CelestialBodyDescriptor descriptor)
 {
     return new LiteCelestialBody
     (
         descriptor.Path,
         descriptor.Position,
         descriptor.Rotation,
         descriptor.StartingPosition,
         descriptor.Size,
         descriptor.Speed
     );
 }
Example #2
0
        public bool InBorders(CelestialBodyDescriptor descriptor, PhysicalRectangle limits)
        {
            LiteCelestialBody corpsCeleste = new LiteCelestialBody
            (
                descriptor.Path,
                descriptor.Position,
                descriptor.Rotation,
                descriptor.StartingPosition,
                descriptor.Size,
                descriptor.Speed
            );

            // au temps 0
            corpsCeleste.ActualRotationTime = 0;
            corpsCeleste.Move();
            if (!limits.Includes(corpsCeleste.Position + new Vector3((int)descriptor.Size, 0, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(-(int)descriptor.Size, 0, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(0, (int)descriptor.Size, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(0, -(int)descriptor.Size, 0)))
                return false;

            // au temps 1/4
            corpsCeleste.ActualRotationTime = corpsCeleste.RotationTime / 4;
            corpsCeleste.Move();
            if (!limits.Includes(corpsCeleste.Position + new Vector3((int)descriptor.Size, 0, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(-(int)descriptor.Size, 0, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(0, (int)descriptor.Size, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(0, -(int)descriptor.Size, 0)))
                return false;

            // au temps 1/2
            corpsCeleste.ActualRotationTime = corpsCeleste.RotationTime / 2;
            corpsCeleste.Move();
            if (!limits.Includes(corpsCeleste.Position + new Vector3((int)descriptor.Size, 0, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(-(int)descriptor.Size, 0, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(0, (int)descriptor.Size, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(0, -(int)descriptor.Size, 0)))
                return false;

            // au temps 3/4
            corpsCeleste.ActualRotationTime = corpsCeleste.RotationTime * (3.0/4.0);
            corpsCeleste.Move();
            if (!limits.Includes(corpsCeleste.Position + new Vector3((int)descriptor.Size, 0, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(-(int)descriptor.Size, 0, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(0, (int)descriptor.Size, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(0, -(int)descriptor.Size, 0)))
                return false;

            return true;
        }
Example #3
0
        public bool CollidesWithOthers(CelestialBodyDescriptor celestialBody, List<CelestialBody> others)
        {
            LiteCelestialBody celestialBodyLite = LiteCelestialBody.ToLiteCelestialBody(celestialBody);

            List<LiteCelestialBody> othersLites = new List<LiteCelestialBody>();

            foreach (var c in others)
                othersLites.Add(LiteCelestialBody.ToLiteCelestialBody(c));

            for (int i = 0; i < othersLites.Count; i++)
            {
                LiteCelestialBody other = othersLites[i];

                double rotationTime = Math.Max(celestialBodyLite.RotationTime, other.RotationTime);

                for (double x = 0; x <= rotationTime; x += 250)
                {
                    celestialBodyLite.ActualRotationTime = (celestialBodyLite.StartingTime + x) % celestialBodyLite.RotationTime;
                    celestialBodyLite.Move();

                    other.ActualRotationTime = (other.StartingTime + x) % other.RotationTime;
                    other.Move();

                    if (celestialBodyLite.Circle.Intersects(other.Circle))
                        return true;
                }
            }

            return false;
        }
        private static CelestialBodyDescriptor GenerateCelestialBody(List<CelestialBody> CelestialBodies)
        {
            CelestialBodyDescriptor d = new CelestialBodyDescriptor()
            {
                Name = "Planete" + Main.Random.Next(0, int.MaxValue),
                Invincible = false,
                InBackground = false,
                CanSelect = true,
                PathPriority = -1,
                Image = "planete" + Main.Random.Next(1, 13).ToString()
            };

            PhysicalRectangle rp = Limits[d.Size];

            int size = Main.Random.Next(0, 3);
            d.Size = (size == 0) ? Size.Small : (size == 1) ? Size.Normal : Size.Big;
            d.Speed = float.MaxValue;
            d.Path = Vector3.Zero;
            d.Position = Vector3.Zero;
            d.Rotation = 0;
            d.StartingPosition = 0;

            return d;
        }
Example #5
0
        public void AddCelestialBody(Size size, Vector3 position, string name, string image, int speed, int pathPriority)
        {
            CelestialBodyDescriptor d = new CelestialBodyDescriptor();
            d.Name = name;
            d.Invincible = true;
            d.Position = position;
            d.StartingPosition = 0;
            d.PathPriority = pathPriority;
            d.Size = size;
            d.Speed = speed;
            d.Image = image;

            PlanetarySystem.Add(d);
        }
Example #6
0
 public void AddAsteroidBelt()
 {
     var c = new CelestialBodyDescriptor()
     {
         Name = "Asteroid belt",
         Path = new Vector3(700, -400, 0),
         Speed = 2560000,
         StartingPosition = 40,
         Size = Size.Small,
         Images = new List<string>() { "Asteroid" },
         PathPriority = int.MinValue + 1
     };
     
     PlanetarySystem.Add(c);
 }