public void Apply(Models.EphemerisResult ephemerisResult)
 {
     DateUTC               = ephemerisResult.DateUTC;
     JulianDay             = ephemerisResult.JulianDay;
     EphemerisTime         = ephemerisResult.EphemerisTime;
     SideralTime           = ephemerisResult.SideralTime;
     MeanEclipticObliquity = ephemerisResult.MeanEclipticObliquity;
     TrueEclipticObliquity = ephemerisResult.TrueEclipticObliquity;
     NutationLongitude     = ephemerisResult.NutationLongitude;
     NutationObliquity     = ephemerisResult.NutationObliquity;
     Planets.Clear();
     foreach (var p in ephemerisResult.Planets)
     {
         Planets.Add(p);
     }
     Houses.Clear();
     foreach (var h in ephemerisResult.Houses)
     {
         Houses.Add(h);
     }
     ASMCs.Clear();
     foreach (var h in ephemerisResult.ASMCs)
     {
         ASMCs.Add(h);
     }
 }
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Planets.Clear();
                var planets = await DataStore.GetItemsAsync(true);

                foreach (var planet in planets)
                {
                    Planets.Add(planet);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
예제 #3
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();
        }
예제 #4
0
        public void CreateSolarSystem()
        {
            Planet sun     = new Planet(60, Color.Yellow, new Point2D(Size.Width / 2, Size.Height / 2));
            Planet mercury = new Planet(sun, 80, 8, 0.5f, Color.Red, 10, 1);
            Planet venus   = new Planet(sun, 110, 9, 0.1f, Color.DarkOrange, 15, 1);
            Planet earth   = new Planet(sun, 150, 12, 0.2f, Color.Green, 18, 1);
            Planet moon    = new Planet(earth, 17, 3, 0.2f, Color.Gray, 55, 1);
            Planet mars    = new Planet(sun, 225, 10, 0.7f, Color.Red, 17, 1);
            Planet upiter  = new Planet(sun, 275, 25, 0.9f, Color.RosyBrown, 13, 1);
            Planet cerera  = new Planet(upiter, 45, 6, 0.2f, Color.Gray, 45, 1);
            Planet saturn  = new Planet(sun, 350, 45, 0.3f, Color.SandyBrown, 10, 1);
            Planet titan   = new Planet(saturn, 56, 7, 0.2f, Color.BlueViolet, 35, 1);
            Planet uran    = new Planet(sun, 435, 20, 0.9f, Color.Cyan, 12, 1);
            Planet neptune = new Planet(sun, 500, 18, 0.4f, Color.Blue, 7, 1);

            Planets.Add(sun);
            Planets.Add(mercury);
            Planets.Add(venus);
            Planets.Add(earth);
            Planets.Add(moon);
            Planets.Add(mars);
            Planets.Add(upiter);
            Planets.Add(cerera);
            Planets.Add(saturn);
            Planets.Add(titan);
            Planets.Add(uran);
            Planets.Add(neptune);
        }
        /// <summary>
        /// Executes the load planets command.
        /// </summary>
        async Task ExecuteLoadPlanetsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Planets.Clear();
                var planets = await this._service.GetAllPlanets().ConfigureAwait(false);

                Device.BeginInvokeOnMainThread(() =>
                {
                    foreach (var planet in planets)
                    {
                        Planets.Add(planet);
                    }
                });
            }
            catch (Exception ex)
            {
                // Proper handling of exception
            }
            finally
            {
                IsBusy = false;
            }
        }
예제 #6
0
        private async Task InitAsync(Film film)
        {
            IsLoading = true;
            if (film != null)
            {
                Film = film;

                Species.Clear();
                foreach (var specy in film.species)
                {
                    var currentSpecy = await _speciesRepository.GetSpecieAsync(specy) ??
                                       await _dataService.GetSingleByUrl <Specie>(specy);

                    Species.Add(currentSpecy);
                }
                Species = Species.OrderBy(item => item.name).ToObservableCollection();

                Starships.Clear();
                foreach (var starship in film.starships)
                {
                    var currentStarship = await _starshipRepository.GetStarshipAsync(starship) ??
                                          await _dataService.GetSingleByUrl <Starship>(starship);

                    Starships.Add(currentStarship);
                }
                Starships = Starships.OrderBy(item => item.name).ToObservableCollection();

                Vehicles.Clear();
                foreach (var vehicle in film.vehicles)
                {
                    var currentVehicle = await _vehiclesRepository.GetVehicleAsync(vehicle) ??
                                         await _dataService.GetSingleByUrl <Vehicle>(vehicle);

                    Vehicles.Add(currentVehicle);
                }
                Vehicles = Vehicles.OrderBy(item => item.name).ToObservableCollection();

                People.Clear();
                foreach (var character in film.characters)
                {
                    var currentPeople = await _peopleRepository.GetPeopleAsync(character) ??
                                        await _dataService.GetSingleByUrl <People>(character);

                    People.Add(currentPeople);
                }
                People = People.OrderBy(item => item.name).ToObservableCollection();

                Planets.Clear();
                foreach (var planet in film.planets)
                {
                    var currentPlanet = await _planetRepository.GetPlanetAsync(planet) ??
                                        await _dataService.GetSingleByUrl <Planet>(planet);

                    Planets.Add(currentPlanet);
                }
                Planets = Planets.OrderBy(item => item.name).ToObservableCollection();
            }
            IsLoading = false;
        }
예제 #7
0
        public void AddPlanet(float x, float y, float radius, int textureId, float angularVelacity)
        {
            var planet = new Planet(_engine, x, y, radius, textureId);

            planet.AngularVelocity = angularVelacity;
            planet.GenerateView();
            Planets.Add(planet);
        }
예제 #8
0
 protected Star()
 {
     foreach (string planetName in planetNames)
     {
         Planet p = new Planet(planetName, this);
         Planets.Add(p);
     }
 }
        public void AddPlanet(double density, double radius, Vector position, Vector speed)
        {
            Planet planet = new Planet(density, radius, position, speed);

            Planets.Add(planet);
            SpaceObjects.Add(planet);
            canvas.Children.Add(planet.image);
        }
예제 #10
0
 public void AddPlanet(Planet planet)
 {
     if (planet != null)
     {
         planet.LoadContent(Parent.Content);
         Planets.Add(planet);
     }
 }
예제 #11
0
 public void Load(string file)
 {
     if (!IsLoaded)
     {
         Planets.Clear();
         var listItems = JsonConvert.DeserializeObject <List <PlanetJsonData> >(Resources.Load <TextAsset>(file).text);
         listItems.ForEach(item => Planets.Add(item.id, new PlanetServerData(item)));
         IsLoaded = true;
     }
 }
예제 #12
0
        public void SetFromExternalDataSource(IEnumerable <PlanetServerData> planets)
        {
            Planets.Clear();
            planets.ToList().ForEach(item => Planets.Add(item.Id, item));
            IsLoaded = true;

            foreach (var p in Planets.Values)
            {
                //Debug.Log($"{p.ToString()}".Colored(ConsoleTextColor.orange));
            }
        }
예제 #13
0
        private void StorePlanet(StarDate time, Planet planet)
        {
            var record = new PlanetRecord
            {
                Time         = time,
                PlanetId     = planet.Id,
                OwnerId      = planet.Settlement?.OwnerId,
                Population   = planet.Settlement?.Population,
                ScannerRange = planet.Settlement?.Installations.Scanner,
            };

            Planets.Add(record);
        }
예제 #14
0
    private void GeneratePlanets()
    {
        int numPlanets = 10;

        Tuple <Vector2, int> Point = new Tuple <Vector2, int>(Vector2.zero, 0);

        for (int i = 0; i < numPlanets; i++)
        {
            Point = CalculatePoint(Point.Second, 50, 100);

            Planets.Add(new Planet(Point.First));
        }
    }
        public void populateComboBoxes()
        {
            //Populate Both ComboBoxes
            DataAccess db = new DataAccess();

            foreach (var item in db.GetAllFruits())
            {
                Fruits.Add(item.Name + " " + item.Color);
            }
            foreach (var item in db.GetAllPlanets())
            {
                Planets.Add(item.Name2 + " " + item.Color2);
            }
        }
예제 #16
0
        public void InitPlanets()
        {
            Planets.Add(new Planet {
                Id = 1, NumShips = 50, Owner = NoPlayer, Radius = 40, X = 50, Y = 60
            });
            Planets.Add(new Planet {
                Id = 2, NumShips = 50, Owner = NoPlayer, Radius = 40, X = 270, Y = 420
            });
            Planets.Add(new Planet {
                Id = 3, NumShips = 45, Owner = NoPlayer, Radius = 35, X = 160, Y = 240
            });
            Planets.Add(new Planet {
                Id = 4, NumShips = 20, Owner = NoPlayer, Radius = 25, X = 250, Y = 100
            });
            Planets.Add(new Planet {
                Id = 5, NumShips = 20, Owner = NoPlayer, Radius = 25, X = 70, Y = 380
            });

            Planets.Add(new Planet {
                Id = 6, NumShips = 15, Owner = NoPlayer, Radius = 20, X = 270, Y = 30
            });
            Planets.Add(new Planet {
                Id = 7, NumShips = 15, Owner = NoPlayer, Radius = 20, X = 140, Y = 125
            });
            Planets.Add(new Planet {
                Id = 8, NumShips = 15, Owner = NoPlayer, Radius = 20, X = 45, Y = 170
            });
            Planets.Add(new Planet {
                Id = 9, NumShips = 15, Owner = NoPlayer, Radius = 20, X = 35, Y = 275
            });


            Planets.Add(new Planet {
                Id = 10, NumShips = 15, Owner = NoPlayer, Radius = 20, X = 50, Y = 450
            });
            Planets.Add(new Planet {
                Id = 11, NumShips = 15, Owner = NoPlayer, Radius = 20, X = 180, Y = 355
            });
            Planets.Add(new Planet {
                Id = 12, NumShips = 15, Owner = NoPlayer, Radius = 20, X = 275, Y = 310
            });
            Planets.Add(new Planet {
                Id = 13, NumShips = 15, Owner = NoPlayer, Radius = 20, X = 285, Y = 205
            });
        }
예제 #17
0
    private void CreatePlanet(Vector2 position, Player owner, int currentType, int currentUpgradeLevel, int population)
    {
        Planet planet = Instantiate <Planet>("Planet", position);

        planet.Owner               = owner;
        planet.CurrentType         = currentType;
        planet.CurrentUpgradeLevel = currentUpgradeLevel;
        planet.Population          = population;
        planet.GameController      = this;

        // Add SpriteRenderer component
        var sr = planet.AddComponent <SpriteRenderer>();

        sr.Sprite = planet.CurrentUpgrade.Sprite;

        // Add TextRenderer component
        var tr = planet.AddComponent <TextRenderer>();

        tr.Font   = PlanetPopulationFont;
        tr.Offset = new Vector2(0, -58);
        tr.Size   = 0.75f;

        // Add AudioSource component
        var au = planet.AddComponent <AudioSource>();

        // Add upgrade menu
        var upgradeMenu = planet.AddComponent <UpgradeMenu>();

        upgradeMenu.UIFont       = PlanetPopulationFont;
        upgradeMenu.UpgradeText  = Instantiate <TextRenderer>("Text", Vector2.Zero);
        upgradeMenu.Convert1Text = Instantiate <TextRenderer>("Text", Vector2.Zero);
        upgradeMenu.Convert2Text = Instantiate <TextRenderer>("Text", Vector2.Zero);
        upgradeMenu.Hide();

        // Bind callbacks
        planet.LaunchShipHandler  += LaunchShip;
        planet.OnPopulationChange += UpdateTotalPopulation;

        // Add to list
        Planets.Add(planet);

        // Invoke callback
        OnPlanetCreated?.Invoke(planet);
    }
예제 #18
0
    public bool TryAdd(PlanetController planet)
    {
        bool result =
            false;

        if (!planet.IsAlive)
        {
            return(result);
        }

        if (Bounds.Contains(planet.Position))
        {
            Mass +=
                planet.Mass;
            centerOfMass +=
                planet.Position * planet.Mass;

            if (!IsLeaf)
            {
                AddToFirstFittingNode(planet);
            }
            else
            {
                if (Planets.Count < Capacity)
                {
                    Planets.Add(planet);
                }
                else
                {
                    Subdivide();

                    SinkPlanetsToNodes();
                    AddToFirstFittingNode(planet);
                }
            }

            result =
                true;
        }

        return(result);
    }
        private Planet BuildPlanet(int planetID, string[] tokens)
        {
            Planet result;
            int    owner    = ParseInt(tokens[3]);
            int    numShips = ParseInt(tokens[4]);

            if (!Planets.TryGetValue(planetID, out result))
            {
                double x          = ParseDouble(tokens[1]);
                double y          = ParseDouble(tokens[2]);
                int    growthRate = ParseInt(tokens[5]);
                result = new Planet(planetID, owner, numShips, growthRate, x, y);
                result.CreateTurns(40);
                Planets.Add(planetID, result);
            }
            else
            {
                result.SynchronizeWithGameStatus(owner, numShips);
            }
            return(result);
        }
예제 #20
0
 private void ExtractIds()
 {
     foreach (Uri characterUri in CharacterUris)
     {
         Characters.Add(extractId(characterUri));
     }
     foreach (Uri planetUri in PlanetUris)
     {
         Planets.Add(extractId(planetUri));
     }
     foreach (Uri speciesUri in SpeciesUris)
     {
         Species.Add(extractId(speciesUri));
     }
     foreach (Uri starshipUri in StarshipUris)
     {
         Starships.Add(extractId(starshipUri));
     }
     foreach (Uri vehicleUri in VehicleUris)
     {
         Vehicles.Add(extractId(vehicleUri));
     }
 }
예제 #21
0
 public SystemGeometry AddPlanet(PlanetGeometry planet)
 {
     Planets.Add(planet.Id, planet);
     return(this);
 }
예제 #22
0
        public void Open(string path)
        {
            FileName  = path;
            isOpening = true;
            Planets.Clear();
            _path = path;
            array = File.ReadAllBytes(path);

            Money = GetValueInt(moneyIdx);
            Level = GetValueByte(levelIdx);

            for (int i = 0; i < 105; i++)
            {
                int    planetZeroIdx = planetsStartIdx + (i * planetBytes);
                Planet planet        = new Planet();
                planet.Name = GetValueString(planetZeroIdx, planetNameLength).Trim('\0');

                planet.XPosIdx = planetZeroIdx + planetNameLength;
                planet.X       = GetValueShort(planet.XPosIdx);

                planet.YPosIdx = planetZeroIdx + planetNameLength + 2;
                planet.Y       = GetValueShort(planet.YPosIdx);

                planet.PopulationIdx = planetZeroIdx + planetPopulationIdx;
                planet.Population    = GetValueInt(planet.PopulationIdx);

                planet.OwnerIdx = planetZeroIdx + planetOwnerIdx;
                planet.Owner    = GetValueByte(planet.OwnerIdx);

                planet.RaceIdx = planetZeroIdx + planetRaceIdx;
                planet.Race    = GetValueByte(planet.RaceIdx);

                planet.TypeIdx = planetZeroIdx + planetTypeIdx;
                planet.Type    = GetValueByte(planet.TypeIdx);

                planet.SizeIdx = planetZeroIdx + 16;
                planet.Size    = GetValueByte(planet.SizeIdx);

                planet.SatIdx = planetZeroIdx + planetTypeIdx + 12;
                planet.HasSat = GetValueBool(planet.SatIdx);

                planet.SpySat1Idx = planetZeroIdx + planetTypeIdx + 13;
                planet.HasSpySat1 = GetValueBool(planet.SpySat1Idx);

                planet.SpySat2Idx = planetZeroIdx + planetTypeIdx + 14;
                planet.HasSpySat2 = GetValueBool(planet.SpySat2Idx);

                planet.Hubble2Idx = planetZeroIdx + planetTypeIdx + 15;
                planet.HasHubble2 = GetValueBool(planet.Hubble2Idx);

                planet.Orbit1Idx = planetZeroIdx + planetTypeIdx + 16;
                planet.Orbit1    = GetValueByte(planet.Orbit1Idx);

                planet.Orbit2Idx = planetZeroIdx + planetTypeIdx + 17;
                planet.Orbit2    = GetValueByte(planet.Orbit2Idx);

                planet.Orbit3Idx = planetZeroIdx + planetTypeIdx + 18;
                planet.Orbit3    = GetValueByte(planet.Orbit3Idx);

                planet.VisibilityIdx = planetZeroIdx + 51;
                planet.Visibility    = GetValueByte(planet.VisibilityIdx);

                Planets.Add(planet);
            }

            foreach (UnitsAndBuildings unit in UnitsAndBuildings)
            {
                unit.Count         = GetValueByte(unit.CountIdx);
                unit.ResearchState = GetValueByte(unit.ResearchStateIdx);
                unit.ResearchCost  = GetValueInt(unit.ResearchCostIdx);

                unit.Civ  = GetValueByte(unit.CivIdx);
                unit.Mech = GetValueByte(unit.MechIdx);
                unit.Comp = GetValueByte(unit.CompIdx);
                unit.Ai   = GetValueByte(unit.AiIdx);
                unit.Mil  = GetValueByte(unit.MilIdx);

                unit.Req1 = GetValue3xByte(unit.Req1Idx);
                unit.Req2 = GetValue3xByte(unit.Req2Idx);
                unit.Req3 = GetValue3xByte(unit.Req3Idx);
            }

            //var view = CollectionViewSource.GetDefaultView(Planets);71942
            //view.SortDescriptions.Add(new SortDescription("Name", ListSortDirection.Ascending));71952

            isOpening = false;
        }
예제 #23
0
 public void Add(Planet p)
 {
     Planets.Add(p);
 }
예제 #24
0
        // Parses a game state from a string. On success, returns 1. On failure,
        // returns 0.
        private int ParseGameState(String s)
        {
            Planets.Clear();
            Fleets.Clear();
            ClearDupeCache();
            //PORT: Make WindowsCompatible
            String[] lines    = s.Replace("\r\n", "\n").Split('\n');
            int      planetid = 0;

            for (int i = 0; i < lines.Length; ++i)
            {
                String line         = lines[i];
                int    commentBegin = line.IndexOf('#');
                if (commentBegin >= 0)
                {
                    line = line.Substring(0, commentBegin);
                }
                if (line.Trim().Length == 0)
                {
                    continue;
                }
                String[] tokens = line.Split(' ');
                if (tokens.Length == 0)
                {
                    continue;
                }
                if (tokens[0].Equals("P"))
                {
                    if (tokens.Length != 6)
                    {
                        return(0);
                    }
                    double x          = Double.parseDouble(tokens[1]);
                    double y          = Double.parseDouble(tokens[2]);
                    int    owner      = Integer.parseInt(tokens[3]);
                    int    numShips   = Integer.parseInt(tokens[4]);
                    int    growthRate = Integer.parseInt(tokens[5]);
                    Planet p          = new Planet(planetid++, owner, numShips, growthRate, x, y);
                    Planets.Add(p);
                    if (gamePlayback.Length > 0)
                    {
                        gamePlayback.Append(":");
                    }
                    gamePlayback.Append("" + x + "," + y + "," + owner + "," + numShips + "," + growthRate);
                }
                else if (tokens[0].Equals("F"))
                {
                    if (tokens.Length != 7)
                    {
                        return(0);
                    }
                    int   owner           = Integer.parseInt(tokens[1]);
                    int   numShips        = Integer.parseInt(tokens[2]);
                    int   source          = Integer.parseInt(tokens[3]);
                    int   destination     = Integer.parseInt(tokens[4]);
                    int   totalTripLength = Integer.parseInt(tokens[5]);
                    int   turnsRemaining  = Integer.parseInt(tokens[6]);
                    Fleet f = new Fleet(owner,
                                        numShips,
                                        source,
                                        destination,
                                        totalTripLength,
                                        turnsRemaining);
                    Fleets.Add(f);
                }
                else
                {
                    return(0);
                }
            }
            gamePlayback.Append("|");
            return(1);
        }
예제 #25
0
 public void AddPlanets(int x, int y)
 {
     Planets.Add(new Planet(x, y));
 }
예제 #26
0
 public void AddPlanet(Planet planet)
 {
     Planets.Add(planet);
 }