Ejemplo n.º 1
0
    IEnumerator dataPlanetRestGet()
    {
        PlanetType      dataPlanet = null;
        UnityWebRequest api        = UnityWebRequest.Get(restUrl + "/planettype/" + this.planetMass.ToString() + "&" + this.planetRadio.ToString() + "&" + this.solarTemp.ToString()
                                                         + "&" + this.solarTemp.ToString() + "&" + this.solarMass.ToString() + "&" + this.mayorAxis);

        yield return(api.SendWebRequest());

        if (api.isNetworkError || api.isHttpError)
        {
            Debug.Log(api.error);
        }
        else
        {
            dataPlanet = JsonUtility.FromJson <PlanetType>(api.downloadHandler.text);
        }
        float      solarMass   = starProvider.GetComponent <StarProvider>().uniqueStar().GetComponent <Star>().masa;
        float      starRadius  = starProvider.GetComponent <StarProvider>().uniqueStar().GetComponent <Star>().radio;
        float      rocheLimit  = starRadius * 0.0046f * Mathf.Pow((2.0f * bodyDensity(solarMass * 1.989f * Mathf.Pow(10, 30), starRadius * 695510000f)) / bodyDensity(planetMass * 5.972f * Mathf.Pow(10, 24), planetRadio * 6371000), 1 / 3f);
        GameObject planetNewGO = Instantiate(planet, transform.position, Quaternion.Euler(-90, 0, 0));
        GameObject botonNewGO  = Instantiate(botonPlaneta, contenedor) as GameObject;

        botonNewGO.GetComponent <BotonNaveUI>().Inicializar(planetNewGO.GetComponent <RecursosPlaneta>(), this.planeta);
        float  radioUnity = (1 + (0.1f * planetRadio)) * 0.05f;
        Planet planetNew  = planetNewGO.GetComponent <Planet>();

        planetNew.transform.localScale = Vector3.one * 2 * radioUnity;
        RandomMaterial randomPlanet = planetNewGO.GetComponent <RandomMaterial>();
        string         type         = dataPlanet.type;

        /* switch (type)
         * {
         *       case "Gaseoso":
         *               randomPlanet.tipo = TipoPlaneta.gaseoso;
         *               break;
         *       case "Habitable":
         *               randomPlanet.tipo = TipoPlaneta.habitable;
         *               break;
         *       case "Solido":
         *               randomPlanet.tipo = TipoPlaneta.solido;
         *               break;
         *       default:
         *               randomPlanet.tipo = TipoPlaneta.luna;
         *               break;
         * }*/
        print("TIPO: " + type);
        randomPlanet.AsignarTipo(type);
        randomPlanet.Generar();

        StarProvider starprov = starProvider.GetComponent <StarProvider>();
        Star         star     = starprov.uniqueStar().GetComponent <Star>();

        planetNew.setParameters(planeta, mayorAxis, excentricity, planetRadio, star, rocheLimit, type);
        planetList.Add(planetNewGO);
    }
Ejemplo n.º 2
0
    public void createStarButton()
    {
        StarProvider starProv = starProvider.GetComponent <StarProvider>();

        starProv.AddStar(this.name.text, float.Parse(this.mass.text), float.Parse(this.radius.text));

        //ColorEstrellaCtrol.singleton.Inicializar();

        resetForm();
        menu.active = true;
        InterJuego.SetActive(true);
        starModal.active = false;
    }
Ejemplo n.º 3
0
    public void Inicializar()
    {
        restUrl = "http://10.0.25.76:8080/";
        StartCoroutine(colorRestGet());
        StarProvider estrellaProv = estrellaProvider.GetComponent <StarProvider>();

        estrella = estrellaProv.starList[0];

        radioEstrellaUA    = estrella.GetComponent <Star>().radio;
        radioEstrellaUnity = ZonaHabitabilidad.ConvertirUA(radioEstrellaUA);

        // GameObject d = Instantiate(estrella, Vector3.zero, Quaternion.identity) as GameObject;
        //d.transform.localScale = Vector3.one * 2 * radioEstrellaUnity;
    }