// Private methods private async Task LoadPlanets() { var result = await _planetsService.GetPlanetsAsync(_nextPage); List <IPlanet> planetsToAdd = new List <IPlanet>(); for (int i = 0; i < result.Results.Count(); i++) { if (i % 2 == 0) { planetsToAdd.Add(result.Results.ElementAt(i).ToPlanet()); } else { planetsToAdd.Add(result.Results.ElementAt(i).ToPlanet2()); } } if (string.IsNullOrEmpty(_nextPage)) { Planets.Clear(); } Planets.AddRange(planetsToAdd); _nextPage = result.Next; }
/// <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; } }
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; } }
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); } }
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; }
private void SinkPlanetsToNodes() { foreach (var planet in Planets) { AddToFirstFittingNode(planet); } Planets.Clear(); }
/// <summary> /// Défini la liste des planètes par défaut /// </summary> public void SetDefaultPlanets() { Planets.Clear(); Planets.AddRange(new Planet[] { Planet.Sun, Planet.Moon, Planet.Mercury, Planet.Venus, Planet.Mars, Planet.Jupiter, Planet.Saturn, Planet.Uranus, Planet.Neptune, Planet.Pluto, Planet.MeanNode, Planet.TrueNode, Planet.MeanApog, Planet.OscuApog, Planet.Earth }); }
public void Clear() { for (int i = 0; i < Nodes.Length; ++i) { Nodes [i] = null; } Planets.Clear(); }
public void reset() { foreach (ISpaceObject so in SpaceObjects) { canvas.Children.Remove(so.GetImage()); } SpaceObjects.Clear(); Planets.Clear(); Asteroids.Clear(); }
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; } }
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)); } }
// Private methods private async Task LoadPlanets() { var result = await _planetsService.GetPlanetsAsync(_nextPage); if (string.IsNullOrEmpty(_nextPage)) { Planets.Clear(); } Planets.AddRange(result.Results); _nextPage = result.Next; }
/// <summary> /// Reset the result /// </summary> public void Reset() { DateUTC = new DateUT(); JulianDay = new JulianDay(); EphemerisTime = new EphemerisTime(); SideralTime = 0; MeanEclipticObliquity = 0; TrueEclipticObliquity = 0; NutationLongitude = 0; NutationObliquity = 0; Planets.Clear(); Houses.Clear(); ASMCs.Clear(); }
void Restart() { foreach (var planet in Planets) { Destroy(planet.GameObject); } Planets.Clear(); foreach (var ship in Ships) { Destroy(ship.GameObject); } Ships.Clear(); _gameOverText.Text = ""; IsGameOver = false; Awake(); Start(); }
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; }
public void Dispose() { Triangle?.Dispose(); PaintFinishedLine.Dispose(); Planets.Clear(); }
// 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); }