示例#1
0
        public Constellation WithLines(int Index, List <int> HRNums)
        {
            for (int i = 0; i < HRNums.Count - 1; i++)
            {
                Star s1 = physics.StarDictionary[HRNums[i]];
                Star s2 = physics.StarDictionary[HRNums[i + 1]];

                if (!Stars.Contains(s1))
                {
                    Stars.Add(s1);
                }
                if (!Stars.Contains(s2))
                {
                    Stars.Add(s2);
                }

                switch (Index)
                {
                case 0:
                    normalShape.AddLine(new Line(s1.Position, s2.Position));
                    break;

                case 1:
                    altShape.AddLine(new Line(s1.Position, s2.Position));
                    break;
                }
                StarPairs.Add(new Tuple <Star, Star>(s1, s2));
            }
            return(this);
        }
示例#2
0
        private async void SaveButton_Clicked(object sender, EventArgs e)
        {
            if (TypeItem == CollectionPage.TypeItemsOfColl.Constellation)
            {
                Constellations.Add(newConstellation);
                newConstellation.Name = nameEntry.Text;
            }
            else if (TypeItem == CollectionPage.TypeItemsOfColl.Star)
            {
                Stars.Add(newStar);
                newStar.Name       = nameEntry.Text;
                newStar.Weight     = Convert.ToDouble(weightEntry.Text);
                newStar.Radius     = Convert.ToDouble(radiusEntry.Text);
                newStar.Luminosity = Convert.ToDouble(luminosityEntry.Text);
                newStar.type       = (Star.typeOfStar)typePicker.SelectedIndex;
                if (searchParentListView.SelectedItem != null)
                {
                    newStar.Constellation = (Constellation)searchParentListView.SelectedItem;
                }
            }
            else if (TypeItem == CollectionPage.TypeItemsOfColl.Planet)
            {
                Planets.Add(newPlanet);
                newPlanet.Name   = nameEntry.Text;
                newPlanet.Weight = Convert.ToDouble(weightEntry.Text);
                newPlanet.Radius = Convert.ToDouble(radiusEntry.Text);
                if (searchParentListView.SelectedItem != null)
                {
                    newPlanet.Star = (Star)searchParentListView.SelectedItem;
                }
            }

            await Navigation.PopAsync();
        }
示例#3
0
        private void addStar(Random random)
        {
            int       height   = formArea.Height;
            int       width    = formArea.Width;
            Point     location = new Point(random.Next(0, width), random.Next(0, height));
            ShapeStar newStar  = new ShapeStar(location, Brushes.White);

            Stars.Add(newStar);
        }
示例#4
0
        public override void AddElements(Galaxi galaxi)
        {
            int n = row;
            int m = col;

            while (n >= 0 && m >= 0)
            {
                Stars.Add(galaxi.dimention[n, m]);
                Suma += galaxi.dimention[n, m];
                n--;
                m--;
            }
        }
示例#5
0
        public override void AddElements(Galaxi galaxi)
        {
            int n = row;
            int m = col;

            while (m < galaxi.dimention.GetLength(1) && n >= 0)
            {
                Stars.Add(galaxi.dimention[n, m]);
                Suma += galaxi.dimention[n, m];
                n--;
                m++;
            }
        }
示例#6
0
        private void GeneratePositions()
        {
            for (int i = 0; i < Density; i++)
            {
                var x = random.Next((int)From.X, (int)Until.X);
                var y = random.Next((int)From.Y, (int)Until.Y);

                var size       = random.Next(1, 3);
                var factor     = random.Next(1, 3) * 0.1f;
                var brightness = random.Next(50, 255);

                Stars.Add(new Star(new Vector2(x, y), brightness, factor, size));
            }
        }
示例#7
0
        public void LoadStarsFromFile()
        {
            string line;

            // each line of input file is parsed and appropriate values are stored to List of Star objects
            while ((line = File.ReadLine()) != null)
            {
                foreach (Match m in Regex.Matches(line, Pattern))
                {
                    int posX = int.Parse(m.Groups[1].Value);
                    int posY = int.Parse(m.Groups[2].Value);
                    int velX = int.Parse(m.Groups[3].Value);
                    int velY = int.Parse(m.Groups[4].Value);

                    Stars.Add(new Star(posX, posY, velX, velY));
                }
            }

            File.Close();
        }
示例#8
0
        public void RecalculateConstellationPoints(ViewportFoV reference, bool calculateConnections)
        {
            // calculate all star positions for the constellation once and add them to the star collection for drawing if they're visible
            foreach (var star in constellation.Stars)
            {
                var starPosition = star.Coords.XYProjection(reference);
                star.Position = new PointF((float)starPosition.X, (float)starPosition.Y);
                var isInBounds = !reference.IsOutOfViewportBounds(star.Position);
                var contains   = Stars.Contains(star);
                if (isInBounds && !contains)
                {
                    Stars.Add(star);
                }
                else if (!isInBounds && contains)
                {
                    Stars.Remove(star);
                }
            }

            if (calculateConnections)
            {
                // now we check what lines are visible in the fov and only add those connections as well
                foreach (var starConnection in constellation.StarConnections)
                {
                    var isInBounds = !(reference.IsOutOfViewportBounds(starConnection.Item1.Position) &&
                                       reference.IsOutOfViewportBounds(starConnection.Item2.Position));
                    var contains = Points.Contains(starConnection);
                    if (isInBounds && !contains)
                    {
                        Points.Add(starConnection);
                    }
                    else if (!isInBounds && contains)
                    {
                        Points.Remove(starConnection);
                    }
                }

                var p = constellationCenter.XYProjection(reference);
                CenterPoint = new PointF((float)p.X, (float)p.Y);
            }
        }
示例#9
0
 public SystemGeometry AddStar(StarGeometry star)
 {
     Stars.Add(star.Id, star);
     return(this);
 }
示例#10
0
        private DeepSpaceData()
        {
            this.Stars              = new ArrayList();
            this.Messier            = new ArrayList();
            this.Constellation      = new ArrayList();
            this.ConstellationNames = new ArrayList();

            Assembly     asembly      = Assembly.GetExecutingAssembly();
            Stream       txtStream    = asembly.GetManifestResourceStream("SpaceObjects.Resources.HYG.txt");
            StreamReader streamReader = new StreamReader(txtStream);

            string delimStr = ";";

            char[]           delimiter = delimStr.ToCharArray();
            NumberFormatInfo provider  = new NumberFormatInfo();

            provider.NumberDecimalSeparator = ".";
            while (streamReader.Peek() >= 0)
            {
                string[] split = streamReader.ReadLine().Split(delimiter, 20);
                Stars.Add(
                    new Star(
                        split[0],
                        split[1],
                        Convert.ToDouble(split[2], provider) * 15,
                        Convert.ToDouble(split[3], provider),
                        Convert.ToDouble(split[4], provider),
                        split[5]));
            }
            Stars.TrimToSize();

            asembly      = Assembly.GetExecutingAssembly();
            txtStream    = asembly.GetManifestResourceStream("SpaceObjects.Resources.Messier.txt");
            streamReader = new StreamReader(txtStream);

            while (streamReader.Peek() >= 0)
            {
                string[] split = streamReader.ReadLine().Split(delimiter, 20);
                Messier.Add(new Messier(split[0], Convert.ToDouble(split[1], provider) * 15,
                                        Convert.ToDouble(split[2], provider), split[3], split[4]));
            }
            Messier.TrimToSize();

            asembly      = Assembly.GetExecutingAssembly();
            txtStream    = asembly.GetManifestResourceStream("SpaceObjects.Resources.Constellations.txt");
            streamReader = new StreamReader(txtStream);

            while (streamReader.Peek() >= 0)
            {
                string str = streamReader.ReadLine();
                if (str[0] != 'C')
                {
                    string[] split = str.Split(delimiter, 20);
                    Constellation.Add(new ConstellationLine(Convert.ToDouble(split[0], provider) * 15, Convert.ToDouble(split[1], provider),
                                                            Convert.ToDouble(split[2], provider) * 15, Convert.ToDouble(split[3], provider)));
                }
                else
                {
                    string[]    split       = str.Split(delimiter, 4);
                    SkyPosition skyPosition = new SkyPosition();
                    skyPosition.Rectascence = Convert.ToDouble(split[2], provider) * 15;
                    skyPosition.Declination = Convert.ToDouble(split[3], provider);
                    ConstellationNames.Add(new ConstellationName(split[1], skyPosition));
                }
            }
            Constellation.TrimToSize();
            ConstellationNames.TrimToSize();
        }
示例#11
0
        public void LoadMap()
        {
            Blocks  = new List <Block>();
            Ladders = new List <Ladder>();
            Doors   = new List <Door>();
            Nodes   = new List <Node>();
            if (!KeyCollected)
            {
                stars = new List <Star>();
            }
            key = null;
            Block  Block;
            Ladder Ladder;
            Toilet Toilet;
            Star   Star;
            Door   Door;
            Key    Key;
            Block  Fence;
            Node   Node;

            for (int i = 0; i < ActiveMap.Map.GetLength(0); i++)
            {
                for (int j = 0; j < ActiveMap.Map.GetLength(1); j++)
                {
                    switch (ActiveMap.Map[i, j])
                    {
                    case 0:
                        break;

                    case 1:
                        Block = new Block(new Vector2(j * 50, i * 50));
                        if (i == 0)
                        {
                            Block.Texture = FloorTexture;
                        }
                        else if (ActiveMap.Map[i - 1, j] != 1)
                        {
                            Block.Texture = FloorTexture;
                            Node          = new Node(new Vector2(j * 50, (i - 1) * 50));
                            Nodes.Add(Node);
                        }
                        else
                        {
                            Block.Texture = WallTexture;
                        }
                        Blocks.Add(Block);
                        break;

                    case 2:
                        Ladder = new Ladder(new Vector2(j * 50, i * 50))
                        {
                            Texture = LadderTexture
                        };
                        Ladders.Add(Ladder);
                        Node = new Node(new Vector2(j * 50, i * 50));
                        Nodes.Add(Node);
                        if (ActiveMap.Map[i - 1, j] == 0)
                        {
                            Node = new Node(new Vector2(j * 50, (i - 1) * 50));
                            Nodes.Add(Node);
                        }
                        break;

                    case 3:     //toilet
                        Toilet = new Toilet(new Vector2(j * 50, i * 50))
                        {
                            Texture = toiletTexture
                        };
                        Goal = Toilet;
                        break;

                    case 4:     //end

                        break;

                    case 5:     //key
                        if (!KeyCollected)
                        {
                            Key = new Key(new Vector2(j * 50, i * 50))
                            {
                                Texture = keyTexture
                            };
                            key = Key;
                        }
                        break;

                    case 6:     //star
                        if (!KeyCollected)
                        {
                            Star = new Star(new Vector2(j * 50, i * 50))
                            {
                                Texture = starTexture
                            };
                            Stars.Add(Star);
                        }
                        break;

                    case 7:     //door
                        if (!KeyCollected)
                        {
                            if (ActiveMap.Map[i + 1, j] == 7)
                            {
                                Door = new Door(new Vector2(j * 50, i * 50))
                                {
                                    Texture = doorTextureTop
                                };
                            }
                            else
                            {
                                Door = new Door(new Vector2(j * 50, i * 50))
                                {
                                    Texture = doorTexture
                                };
                            }
                            Doors.Add(Door);
                        }
                        break;

                    case 8:
                        Flag = new Flag(new Vector2(j * 50, i * 50))
                        {
                            Texture = flagTexture
                        };
                        break;

                    case 9:
                        Fence = new Block(new Vector2(j * 50, i * 50))
                        {
                            Texture = fenceTexture
                        };
                        Fences.Add(Fence);
                        break;
                    }
                }
            }

            for (int i = 0; i < Nodes.Count; i++)
            {
                Debug.WriteLine(i + ". " + Nodes[i].Position);
            }

            for (int i = 0; i < Enemies.Count; i++)
            {
                Enemies[i].Texture = EnemyTexture;
            }
        }
示例#12
0
 public void AddStar(Star star)
 {
     Stars.Add(star);
 }