Пример #1
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();
        }
Пример #2
0
        private static void CreateConstellations(int amount)
        {
            var next = TimeCoordinate.FiveToEight;

            if (LoadedConstellations > 0)
            {
                if (Constellations.Where(c => c.TimeCoordinate == TimeCoordinate.FiveToEight).Count() > Constellations.Where(c => c.TimeCoordinate == TimeCoordinate.NineToEleven).Count())
                {
                    next = TimeCoordinate.NineToEleven;
                }
                else if (Constellations.Where(c => c.TimeCoordinate == TimeCoordinate.NineToEleven).Count() > Constellations.Where(c => c.TimeCoordinate == TimeCoordinate.Midnight).Count())
                {
                    next = TimeCoordinate.Midnight;
                }
                else if (Constellations.Where(c => c.TimeCoordinate == TimeCoordinate.Midnight).Count() > Constellations.Where(c => c.TimeCoordinate == TimeCoordinate.OneToFour).Count())
                {
                    next = TimeCoordinate.OneToFour;
                }
            }

            for (int i = 0; i < amount; i++)
            {
                int    ra  = 0;
                double dec = 0.0;

                do
                {
                    ra  = Utility.RandomMinMax(0, MaxRA);
                    dec = Utility.RandomMinMax(0, (int)MaxDEC) + Utility.RandomList(.2, .4, .6, .8, .0);
                }while (CheckExists(next, ra, dec));

                var info = new ConstellationInfo(next, ra, dec, ConstellationInfo.RandomStarPositions());
                Constellations.Add(info);

                info.Identifier = Constellations.Count - 1;

                switch (next)
                {
                case TimeCoordinate.FiveToEight: next = TimeCoordinate.NineToEleven; break;

                case TimeCoordinate.NineToEleven: next = TimeCoordinate.Midnight; break;

                case TimeCoordinate.Midnight: next = TimeCoordinate.OneToFour; break;

                case TimeCoordinate.OneToFour: next = TimeCoordinate.FiveToEight; break;
                }
            }
        }
Пример #3
0
        public static void OnLoad()
        {
            Persistence.Deserialize(
                FilePath,
                reader =>
            {
                reader.ReadInt();

                LoadedConstellations = reader.ReadInt();

                for (int i = 0; i < LoadedConstellations; i++)
                {
                    Constellations.Add(new ConstellationInfo(reader));
                }
            });
        }
Пример #4
0
        private static void CreateConstellations(int amount)
        {
            TimeCoordinate next = TimeCoordinate.FiveToEight;

            if (LoadedConstellations > 0)
            {
                int count = 0;
                for (var index = 0; index < Constellations.Count; index++)
                {
                    var c = Constellations[index];

                    if (c.TimeCoordinate == TimeCoordinate.NineToEleven)
                    {
                        count++;
                    }
                }

                int count1 = 0;
                for (var index = 0; index < Constellations.Count; index++)
                {
                    var c = Constellations[index];
                    if (c.TimeCoordinate == TimeCoordinate.FiveToEight)
                    {
                        count1++;
                    }
                }

                if (count1 > count)
                {
                    next = TimeCoordinate.NineToEleven;
                }
                else
                {
                    int count2 = 0;
                    for (var index = 0; index < Constellations.Count; index++)
                    {
                        var c = Constellations[index];
                        if (c.TimeCoordinate == TimeCoordinate.Midnight)
                        {
                            count2++;
                        }
                    }

                    int count3 = 0;
                    for (var index = 0; index < Constellations.Count; index++)
                    {
                        var c = Constellations[index];
                        if (c.TimeCoordinate == TimeCoordinate.NineToEleven)
                        {
                            count3++;
                        }
                    }

                    if (count3 > count2)
                    {
                        next = TimeCoordinate.Midnight;
                    }
                    else
                    {
                        int count4 = 0;
                        for (var index = 0; index < Constellations.Count; index++)
                        {
                            var c = Constellations[index];
                            if (c.TimeCoordinate == TimeCoordinate.OneToFour)
                            {
                                count4++;
                            }
                        }

                        int count5 = 0;
                        for (var index = 0; index < Constellations.Count; index++)
                        {
                            var c = Constellations[index];
                            if (c.TimeCoordinate == TimeCoordinate.Midnight)
                            {
                                count5++;
                            }
                        }

                        if (count5 > count4)
                        {
                            next = TimeCoordinate.OneToFour;
                        }
                    }
                }
            }

            for (int i = 0; i < amount; i++)
            {
                int    ra  = 0;
                double dec = 0.0;

                do
                {
                    ra  = Utility.RandomMinMax(0, MaxRA);
                    dec = Utility.RandomMinMax(0, (int)MaxDEC) + Utility.RandomList(.2, .4, .6, .8, .0);
                }while (CheckExists(next, ra, dec));

                ConstellationInfo info = new ConstellationInfo(next, ra, dec, ConstellationInfo.RandomStarPositions());
                Constellations.Add(info);

                info.Identifier = Constellations.Count - 1;

                switch (next)
                {
                case TimeCoordinate.FiveToEight: next = TimeCoordinate.NineToEleven; break;

                case TimeCoordinate.NineToEleven: next = TimeCoordinate.Midnight; break;

                case TimeCoordinate.Midnight: next = TimeCoordinate.OneToFour; break;

                case TimeCoordinate.OneToFour: next = TimeCoordinate.FiveToEight; break;
                }
            }
        }