public async Task <IActionResult> PageIncrementer()
        {
            page = page;
            if (page == 0)
            {
                page = 1;
                page++;
            }
            else if (page == 1)
            {
                page = 2;
                page++;
            }
            else if (page == 2)
            {
                page = 3;
                page++;
            }


            var response = await _planetNameClient.GetPlanetInfo(page);

            var model = new PlanetModel();

            model.results = response.results;



            return(View("PlanetObj", model));
        }
Example #2
0
    void calculateAcceleration(Vector3d[] position)
    {
        // Vor der Berechnung muss die Kraft zurückgesetzt werden
        setForceToZero();

        for (int i = 0; i < attractors.Count; i++)
        {
            PlanetModel planet1 = attractors[i].GetComponent <PlanetModel>();
            for (int j = i + 1; j < attractors.Count; j++)
            {
                PlanetModel planet2 = attractors[j].GetComponent <PlanetModel>();

                // Falls eine temporäre Position existiert
                if (position != null)
                {
                    // Berechnen der Distanz zwischen den Positionen der Planeten
                    double distance = Vector3d.Distance(position[i], position[j]);
                    // Berechnen der Kraft durch das Gravitationsgesetz, SPEED ist Ersatz für Gravitationskonstante
                    double F = SPEED * (planet1.mass * planet2.mass) / (Math.Pow(distance, 2));
                    // Planet1 erfährt neue Kraft
                    planet1.force += (position[j] - position[i]) * F / distance;
                }
                else
                {
                    double distance = Vector3d.Distance(planet1.position, planet2.position);
                    double F        = SPEED * (planet1.mass * planet2.mass) / (Math.Pow(distance, 2));
                    planet1.force += (planet2.position - planet1.position) * F / distance;
                }
                // Actio und Reactio, drittes newtonsches Axiom
                planet2.force -= planet1.force;
            }
            // Berechnen der korrekten Beschleunigung, zweites newtonsches Axiom
            attractors[i].GetComponent <PlanetModel>().acceleration = attractors[i].GetComponent <PlanetModel>().force / attractors[i].GetComponent <PlanetModel>().mass;
        }
    }
Example #3
0
    public GridModel <HexModel> Generate(PlanetModel planetModel)
    {
        _resistanceConfig = GameConfig.Get <BellCurveConfig>();
        _planetModel      = planetModel;
        GameObject go     = GameObject.Find("Map");
        HexMap     hexMap = go.GetComponent <HexMap>();

        _map                   = new GridModel <HexModel>(hexMap.width.Value, hexMap.height.Value);
        _elements              = GameConfig.Get <ElementConfig>().ElementsList;
        _elementsDict          = GameConfig.Get <ElementConfig>().ElementsDictionary;
        _elementsProbabilities = new List <WeightedValue>();
        _hexScoreUpdateCommand = GameModel.Get <HexScoreUpdateCommand>();
        _hexUpdateCommand      = GameModel.Get <HexUpdateCommand>();

        for (int i = 0; i < _elements.Count; i++)
        {
            _elementsProbabilities.Add(new WeightedValue(_elements[i].Index, _elements[i].Rarity));
        }

        Vector2 defaultRange = new Vector2(float.MaxValue, float.MinValue);

        for (int i = 0; i < 7; i++)
        {
            Ranges[i] = defaultRange;
        }

        GenerateMap(hexMap);
        return(_map);
    }
Example #4
0
    private void setDiffEquations()
    {
        Vector3d[] tempPosition = new Vector3d[attractors.Count];
        Vector3d[] ka0          = new Vector3d[attractors.Count];
        Vector3d[] ka1          = new Vector3d[attractors.Count];
        Vector3d[] ka2          = new Vector3d[attractors.Count];
        Vector3d[] ka3          = new Vector3d[attractors.Count];
        Vector3d[] kv0          = new Vector3d[attractors.Count];
        Vector3d[] kv1          = new Vector3d[attractors.Count];
        Vector3d[] kv2          = new Vector3d[attractors.Count];
        Vector3d[] kv3          = new Vector3d[attractors.Count];


        // Euler-Verfahren angewandt
        rungeKutta1(kv0, ka0);
        // 2te Positionsbestimmung durch Mid-Point-Verfahren
        rungeKutta2(kv0, kv1, ka0, tempPosition);
        // 3te Positionsbestimmung durch Mid-Point-Verfahren
        rungeKutta3(kv1, kv2, ka1, tempPosition);
        // 4te Positionsbestimmung
        rungeKutta4(kv2, kv3, ka2, ka3, tempPosition);


        // Neue Position durch den Durchschnitt berechnen
        for (int i = 0; i < attractors.Count; i++)
        {
            PlanetModel planet = attractors[i].GetComponent <PlanetModel>();
            planet.velocity = planet.velocity + 1.0 / 6.0 * (ka0[i] + 2 * ka1[i] + 2 * ka2[i] + ka3[i]);
            planet.position = planet.position + 1.0 / 6.0 * (kv0[i] + 2 * kv1[i] + 2 * kv2[i] + kv3[i]);
        }
    }
Example #5
0
	public PlanetModel FindPlanet(EquatorialCoords eq){
		PlanetModel planet = null;
		if( planetPositionsDictionary.TryGetValue(eq, out planet) ){
			return planet;
		}
		return null;
	}
Example #6
0
 // Start is called before the first frame update
 void Start()
 {
     activeModel       = GameObject.Instantiate(planetModel[0], transform);
     planetModelScript = activeModel.GetComponentInChildren <PlanetModel>();
     prepareLevel();
     AudioManager.instance.playMusic(0);
 }
        public static async Task <PlanetModel> GetSpeciesHomeworld(string id)
        {
            string url = id;

            PlanetModel cached = planetCache.Where(x => x.Id == id).FirstOrDefault();

            if (cached != null)
            {
                return(cached);
            }

            using (HttpResponseMessage response = await apiClient.GetAsync(url))
            {
                if (response.IsSuccessStatusCode)
                {
                    PlanetModel output = await response.Content.ReadAsAsync <PlanetModel>();

                    output.Id = id;

                    return(output);
                }
                else
                {
                    throw new Exception(response.ReasonPhrase);
                }
            }
        }
Example #8
0
 private void OnPlanetChange(PlanetModel value)
 {
     _planet       = value;
     _selectedLife = _planet.Life;
     //if( _selectedLife.Resistance.Count > 0 )
     //  UpdatePlanetMapColors();
 }
    public void Execute()
    {
        _planet = _planetController.SelectedPlanet;
        for (int i = 0; i <= 100; i++)
        {
            _planet.Props[R.Temperature].HexDistribution[i].Weight = 0f;
            _planet.Props[R.Pressure].HexDistribution[i].Weight    = 0f;
            _planet.Props[R.Humidity].HexDistribution[i].Weight    = 0f;
            _planet.Props[R.Radiation].HexDistribution[i].Weight   = 0f;
        }

        for (int x = 0; x < _planet.Map.Width; x++)
        {
            for (int y = 0; y < _planet.Map.Height; y++)
            {
                _hex = _planet.Map.Table[x][y];
                _hexUpdateCommand.Execute(_hex);

                _planet.Props[R.Temperature].HexDistribution[Mathf.FloorToInt(_hex.Props[R.Temperature].Value * 100)].Weight += .05f;
                _planet.Props[R.Pressure].HexDistribution[Mathf.FloorToInt(_hex.Props[R.Pressure].Value * 100)].Weight       += .05f;
                _planet.Props[R.Humidity].HexDistribution[Mathf.FloorToInt(_hex.Props[R.Humidity].Value * 100)].Weight       += .05f;
                _planet.Props[R.Radiation].HexDistribution[Mathf.FloorToInt(_hex.Props[R.Radiation].Value * 100)].Weight     += .05f;
            }
        }
    }
Example #10
0
	public CelestialBody FindCelestialBody(EquatorialCoords eq){
		int index = 0;

		//is it a star?
		if (starPositionsDictionary.TryGetValue(eq, out index)){			
			return stars [ index ] as StarModel;	
		}

		//is it a planet?
		PlanetModel planet = null;
		foreach(KeyValuePair<string, PlanetModel> current in planets){
			if(current.Value.EquatorialCoords.EqualsThreshold(eq, 5)){
				planet = current.Value;
				break;
			}
		}		
		if(planet != null){ 
			return planet as PlanetModel;
		}


		//is it the moon?
		if(moon.EquatorialCoords.Equals(eq)){
			return moon as MoonModel;
		}

		//is it the sun?
		if (sun.EquatorialCoords.Equals (eq)) {
			return sun as SunModel;
		}

		return null;
	}
Example #11
0
        public async Task <List <ResidentModel> > GetResidentsByPlanetNameAsync(string name)
        {
            List <ResidentModel> residents = new List <ResidentModel>();
            List <PlanetModel>   planets   = await GetAllPlanetsAsync();

            PlanetModel planet = planets.FirstOrDefault <PlanetModel>(x => x.PlanetName == name);

            foreach (string url in planet.PlanetResidents)
            {
                using (HttpResponseMessage response = await ApiHelper.ApiClient.GetAsync(url))
                {
                    if (response.IsSuccessStatusCode)
                    {
                        string responseString = await response.Content.ReadAsStringAsync();

                        //response
                        ResidentModel resident = JsonConvert.DeserializeObject <ResidentModel>(responseString);
                        residents.Add(resident);
                    }
                    else
                    {
                        //Failed response
                        throw new Exception(response.ReasonPhrase);
                    }
                }
            }

            return(residents);
        }
Example #12
0
        public async Task <PlanetModel> GetPlanetByIdAsync(int id)
        {
            StringBuilder url = new StringBuilder();

            //base address https://swapi.co/api/
            url.Append(ApiHelper.ApiClient.BaseAddress.ToString());
            url.Append($"planets/{id}");

            using (HttpResponseMessage response = await ApiHelper.ApiClient.GetAsync(url.ToString()))
            {
                if (response.IsSuccessStatusCode)
                {
                    string responseString = await response.Content.ReadAsStringAsync();

                    //response
                    PlanetModel planet = JsonConvert.DeserializeObject <PlanetModel>(responseString);
                    return(planet);
                }
                else
                {
                    //Failed response
                    throw new Exception(response.ReasonPhrase);
                }
            }
        }
Example #13
0
 private void OnPlanetChange(PlanetModel value)
 {
     _planet     = value;
     Temperature = _planet.Props[R.Temperature];
     Pressure    = _planet.Props[R.Pressure];
     Humidity    = _planet.Props[R.Humidity];
     Radiation   = _planet.Props[R.Radiation];
 }
 private static PlanetApiModel ToPlanetApiModel(PlanetModel model)
 {
     return(new PlanetApiModel()
     {
         Id = model.Id,
         Name = model.Name,
     });
 }
Example #15
0
    private void OnPlanetChange(PlanetModel value)
    {
        for (int i = 0; i < _compounds.Count; i++)
        {
            _compounds[i].Setup(value.Life.Elements);
        }

        SetModel();
    }
Example #16
0
 public async Task <PlanetModel> PutPlanetAsync(PlanetModel planet)
 {
     return(ToPlanetModel(await PlanetRepository
                          .InsertPlanetAsync(new PlanetProjection()
     {
         Name = planet.Name,
     })
                          ));
 }
Example #17
0
    private void OnPlanetChange(PlanetModel value)
    {
        disposables.Clear();
        _planet = value;

        LiquidTransform.localScale = new Vector3((_planet.Map.Width * _hexConfig.xOffset) + 1, 2, (_planet.Map.Height * _hexConfig.zOffset) + 1);

        _planet.Props[R.Humidity]._Value.Subscribe(OnLiquidLevelChange).AddTo(disposables);
    }
        public void OnFightClick()
        {
            var model = PlanetModel.GeneratePlanet(PlanetDifficulty.BabyMode);

            CurrentInterfaceState = InterfaceState.World;

            PlanetVisualizer.result  = model.FightMe(_otherController.DNA);
            PlanetVisualizer.enabled = true;
        }
        public async Task <PlanetApiModel> PutPlanet([FromBody] PlanetModel planet)
        {
            var result = await PlanetService.PutPlanetAsync(new PlanetModel()
            {
                Name = planet.Name,
            });

            return(ToPlanetApiModel(result));
        }
Example #20
0
 public void afterLevelingUp()
 {
     if (GameManager.instance.currentLevel != 0)
     {
         lastActiveModel.transform.Find("PlanetItems").Find("Trail").gameObject.SetActive(false);
         activeModel       = activeNextModel;
         planetModelScript = activeModel.GetComponentInChildren <PlanetModel>();
     }
     prepareLevel();
 }
Example #21
0
        public static async Task <List <PersonModel> > DisplayAllCharacters(List <PersonModel> people)
        {
            string lookUpAnother = "";

            do
            {
                try
                {
                    foreach (PersonModel p in people)
                    {
                        string id = p.Url.Split('/')[5];
                        p.Id = id;
                        Console.WriteLine($"{p.Id} {p.FullName}");
                    }

                    Console.Write("\nPlease enter an ID number (1-88): ");
                    string idText = Console.ReadLine();

                    PersonModel person = await GetStarWarsCharacter(idText);

                    PlanetModel planet = await PlanetController.GetStarWarsPlanets(person.Homeworld);

                    List <VehicleModel> vehicle = await VehicleController.GetStarWarsVehicles(person.Vehicles);

                    List <StarshipModel> starship = await StarshipController.GetStarWarsStarShips(person.Starships);

                    List <FilModel> film = await FilmController.GetStarWarsFilms(person.Films);

                    List <SpeciesModel> species = await SpeciesController.GetStarWarsSpecies(person.Species);

                    Console.WriteLine("============================================================");
                    Console.WriteLine($"Name: { person.FullName } | Gender: { person.Gender }");
                    Console.WriteLine($"Species: { SpeciesController.FormatSpeciesLine(species) } race");
                    Console.WriteLine($"Born: { person.BirthYear }");
                    Console.WriteLine($"Homeworld: { planet.Name }");
                    Console.WriteLine($"{ FormatMeasurementLine(person) }");
                    Console.WriteLine($"Hair: { person.HairColor } | Skin: { person.SkinColor } | " +
                                      $"Eyes: { person.Eye_Color}");

                    Console.WriteLine($"Vehicles: { VehicleController.FormatVehicleLine(vehicle) }");
                    Console.WriteLine($"Starships: { StarshipController.FormatStarshipLine(starship) }");
                    Console.WriteLine($"Films: { FilmController.FormatFilmLine(film) }");
                    Console.WriteLine("============================================================");
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Error: { ex.Message }");
                }

                Console.Write("Do you want to look up another character (y/n)?");
                lookUpAnother = Console.ReadLine();
            } while (lookUpAnother.ToLower() == "y");

            return(null);
        }
Example #22
0
        public IActionResult Get(string name)
        {
            PlanetModel planet = repo.GetPlanetByName(name);

            if (planet == null)
            {
                return(NotFound());
            }

            return(Ok(jconv.Convert(planet)));
        }
        public GetPlanetViewModel GetViewModel(PlanetModel model)
        {
            var response = new GetPlanetViewModel();

            if (model != null)
            {
                response.PlanetModel = model;
            }

            return(response);
        }
Example #24
0
    protected virtual void Awake()
    {
        sim      = SimController.INSTANCE;
        skyModel = sim.skyModel;

        distance = 1.0f * sim.radius;
        model    = GetModel();

        SetPosition();
        SetScale();
    }
Example #25
0
 private void OnPlanetChange(PlanetModel value)
 {
     _life = value.Life;
     RemoveAllChildren(Container);
     for (int i = 0; i < _life.BuildingsState.Count; i++)
     {
         GameObject         ability_go        = Instantiate(AbilityUnlockPrefab, Container);
         BuildingUnlockView abilityUnlockView = ability_go.GetComponent <BuildingUnlockView>();
         abilityUnlockView.Setup(_life.BuildingsState[i], EffectPrefab);
     }
 }
Example #26
0
 public static Core.Models.Planets.Planet ToPlanet(this PlanetModel planetModel)
 {
     return(new Core.Models.Planets.Planet
     {
         Id = Guid.Parse(planetModel.Id),
         Description = planetModel.Description,
         Name = planetModel.Name,
         Status = (PlanetStatus)planetModel.Status,
         Units = planetModel.Units,
         ImagePath = planetModel.ImagePath
     });
 }
Example #27
0
    private void rungeKutta2(Vector3d[] kv0, Vector3d[] kv1, Vector3d[] ka0, Vector3d[] tempPosition)
    {
        // Berechnet die Veränderung der Position an kv1 + neue temporäre Position
        for (int i = 0; i < attractors.Count; i++)
        {
            PlanetModel planet = attractors[i].GetComponent <PlanetModel>();
            kv1[i]          = (planet.velocity + ka0[i] / 2) * dt;
            tempPosition[i] = planet.position + kv0[i] / 2;
        }

        // Berechnen der Beschleunigung an der temporären Position
        calculateAcceleration(tempPosition);
    }
Example #28
0
    private void OnPlanetModelChange(PlanetModel value)
    {
        RemoveAllChildren(gameObject.transform);

        _unitsGO = new Dictionary <UnitModel, GameObject>();
        _life    = value.Life;
        for (int i = 0; i < _life.Units.Count; i++)
        {
            AddUnit(_life.Units[i]);
        }
        disposables.Clear();
        _life.Units.ObserveAdd().Subscribe(_ => AddUnit(_.Value)).AddTo(disposables);
        _life.Units.ObserveRemove().Subscribe(_ => RemoveUnit(_.Value)).AddTo(disposables);
    }
Example #29
0
    private void OnPlanetModelChange(PlanetModel value)
    {
        RemoveAllChildren(gameObject.transform);

        _children = new Dictionary <LifeElementModel, GameObject>();
        _life     = value.Life;
        foreach (KeyValuePair <int, LifeElementModel> item in _life.Elements)
        {
            Add(item.Value);
        }
        disposables.Clear();
        _life.Elements.ObserveAdd().Subscribe(_ => Add(_.Value)).AddTo(disposables);
        _life.Elements.ObserveRemove().Subscribe(_ => Remove(_.Value)).AddTo(disposables);
    }
Example #30
0
    // Euler-Verfahren
    private void rungeKutta1(Vector3d[] kv0, Vector3d[] ka0)
    {
        // Initiale Berechnung der Beschleunigung
        calculateAcceleration(null);

        for (int i = 0; i < attractors.Count; i++)
        {
            PlanetModel planet = attractors[i].GetComponent <PlanetModel>();
            // Berechnet die Veränderung der Position
            kv0[i] = planet.velocity * dt;
            // Berechnet die Veränderung der Geschwindigkeit
            ka0[i] = planet.acceleration * dt;
        }
    }
Example #31
0
 public static string EmitPlanetName(PlanetModel planet) => planet.Name;