Exemple #1
0
    public static Nebulosa PostNebulosa(Nebulosa nebulosa)
    {
        var httpWebRequest = (HttpWebRequest)WebRequest.Create(ApiCalls.url + "/api/nebulosas");

        httpWebRequest.ContentType = "application/json";
        httpWebRequest.Method      = "POST";

        using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
        {
            string json = JsonUtility.ToJson(nebulosa);
            //json = json.Replace("\"id\":0,", "");


            streamWriter.Write(json);
            streamWriter.Flush();
            streamWriter.Close();
        }

        var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

        using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
        {
            var result = streamReader.ReadToEnd();


            nebulosa = JsonUtility.FromJson <Nebulosa>(result);
        }
        return(nebulosa);
    }
Exemple #2
0
        public IHttpActionResult PutNebulosa(Nebulosa nebulosa)
        {
            nebulosa.grafo = null;
            nebulosa.sistemasPlanetarios = null;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }



            db.Entry(nebulosa).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!NebulosaExists(nebulosa.id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #3
0
    public void iniciarAlgoritmo(Nebulosa nebulosa)
    {
        SistemaPlanetario nodoInicialTemporal = null;

        nebulosaG = nebulosa;
        // buscar el nodo inicial
        foreach (var item in nebulosa.sistemasPlanetarios)
        {
            if (item.inicial)
            {
                nodoInicialTemporal = item;
            }
            if (item.tieneTeletransportador)
            {
                if (nodoInicialTemporal == null)
                {
                    nodoInicialTemporal = item;
                }
                nodoInicial = item;
            }
        }
        List <SistemaPlanetario> camino = new List <SistemaPlanetario>();

        nave = GameObject.FindGameObjectWithTag("Nave").GetComponent <NaveEspacial>();
        double[] materiales = new double[4];
        materiales[0] = nave.iridio;
        materiales[1] = nave.paladio;
        materiales[2] = nave.platino;
        materiales[3] = nave.elementoZero;
        if (nodoInicialTemporal != null)
        {
            buscarCamino(nodoInicialTemporal, 0, nebulosa.grafo, nave.combustible, camino, 0f, nave.sondas, materiales);
        }
    }
Exemple #4
0
        public IHttpActionResult GetNebulosa(int id)
        {
            Nebulosa nebulosa = db.Nebulosas.Include(xx => xx.sistemasPlanetarios).Include(yy => yy.grafo).FirstOrDefault(xx => xx.id == id);

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

            return(Ok(nebulosa));
        }
Exemple #5
0
        public IHttpActionResult PostNebulosa(Nebulosa nebulosa)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Nebulosas.Add(nebulosa);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = nebulosa.id }, nebulosa));
        }
Exemple #6
0
    private Nebulosa crearNebulosa()
    {
        Nebulosa nebulosa = new Nebulosa();

        nebulosa.nombre = "";//Falta
        nebulosa.x      = Random.Range(-65.0f, 65.0f);
        nebulosa.y      = 0;
        nebulosa.z      = Random.Range(-65.0f, 65.0f);
        nebulosa.sistemasPlanetarios = new List <SistemaPlanetario>();
        nebulosa.danger = ParseBool();
        return(nebulosa);
    }
Exemple #7
0
    /// <summary>
    /// Envía en mensaje DELETE al servidor con  el id de la nebulosa a eliminar.
    /// </summary>
    /// <param name="nebulosa"></param>
    /// <returns></returns>
    public static IEnumerator deleteNebulosaCOR(Nebulosa nebulosa)
    {
        string          accion = "Api/nebulosas/" + nebulosa.id;
        UnityWebRequest wr     = UnityWebRequest.Delete(ApiCalls.url + accion);

        yield return(wr.SendWebRequest());

        if (wr.isNetworkError || wr.isHttpError)
        {
            Debug.Log("ERROR: " + wr.error);
        }
    }
Exemple #8
0
    IEnumerator getNebulosa()
    {
        string          accion = "Api/nebulosas/" + nebulosa.id;
        UnityWebRequest wr     = UnityWebRequest.Get(ApiCalls.url + accion);

        yield return(wr.SendWebRequest());

        if (wr.isNetworkError || wr.isHttpError)
        {
            Debug.Log("ERROR: " + wr.error);
        }
        else
        {
            string          json     = wr.downloadHandler.text;
            Nebulosa        nebulosa = JsonUtility.FromJson <Nebulosa>(json);
            TextMeshProUGUI nombre   = infoNebulosa.transform.Find("Nombre").GetComponent <TextMeshProUGUI>();
            nombre.text = nebulosa.nombre;
        }
    }
Exemple #9
0
        public IHttpActionResult DeleteNebulosa(int id)
        {
            Nebulosa nebulosa = db.Nebulosas.Find(id);

            if (nebulosa == null)
            {
                return(NotFound());
            }
            List <AristaSistema> aristas = db.AristaSistemas.Where(xx => xx.origenFK == id || xx.destinoFK == id).ToList();

            if (aristas != null)
            {
                db.AristaSistemas.RemoveRange(aristas);
            }

            db.Nebulosas.Remove(nebulosa);
            db.SaveChanges();

            return(Ok(nebulosa));
        }
Exemple #10
0
 /// <summary>
 /// Esta corrutina envia esta atenta cuando se selecciona una nebulosa ,cuando lo hace la elimina llamando a la corrutina deleteNebulosa
 /// </summary>
 /// <returns></returns>
 IEnumerator eliminarNebulosaCOR()
 {
     while (eliminar)
     {
         // This would cast rays only against colliders in layer 8.
         // But instead we want to collide against everything except layer 8. The ~ operator does this, it inverts a bitmask.
         if (Input.GetMouseButtonDown(0))
         {
             RaycastHit hit;
             Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
             // Does the ray intersect any objects excluding the player layer
             if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerDelete))
             {
                 Nebulosa nebulosa = hit.transform.gameObject.GetComponent <NebulosaPrefab>().nebulosa;
                 StartCoroutine(deleteNebulosaCOR(nebulosa));
                 Destroy(hit.transform.gameObject);
             }
         }
         yield return(null);
     }
 }
Exemple #11
0
 public void setNebulosa(Nebulosa _nebulosa)
 {
     nebulosa = _nebulosa;
 }
Exemple #12
0
    public void nuevaViaLactea()
    {
        //TMP_InputField totalNebulosas=canvasMenuCrear.transform.Find("Canvas/Nebulosas/Total").GetComponent<TMP_InputField>();
        //TMP_InputField totalSistemasPlanetarios=canvasMenuCrear.transform.Find("Canvas/SistemasPlanetarios/Total").GetComponent<TMP_InputField>();
        //TMP_InputField totalSistemasPlanetas= canvasMenuCrear.transform.Find("Canvas/Planetas/Total").GetComponent<TMP_InputField>();

        Slider maxNebulosas           = canvasMenuCrear.transform.Find("Canvas/Nebulosas/Slider").GetComponent <Slider>();
        Slider maxSistemasPlanetarios = canvasMenuCrear.transform.Find("Canvas/SistemasPlanetarios/Slider").GetComponent <Slider>();
        Slider maxPlanetas            = canvasMenuCrear.transform.Find("Canvas/Planetas/Slider").GetComponent <Slider>();

        Toggle         random          = canvasMenuCrear.transform.Find("Canvas/Info/Toggle").GetComponent <Toggle>();
        TMP_InputField nombreViaLactea = canvasMenuCrear.transform.Find("Canvas/Info/Nombre").GetComponent <TMP_InputField>();


        ViaLactea viaLactea = new ViaLactea();

        viaLactea.nombre    = nombreViaLactea.text;
        viaLactea.Nebulosas = new List <Nebulosa>();



        if (random.isOn)
        {
            int nebulosas = Random.Range((int)maxNebulosas.minValue, (int)maxNebulosas.value);
            for (int i = 0; i < nebulosas; i++)
            {
                Nebulosa nebulosaTemp = crearNebulosa();
                viaLactea.Nebulosas.Add(nebulosaTemp);
                int sistemas = Random.Range((int)maxSistemasPlanetarios.minValue, (int)maxSistemasPlanetarios.value);
                for (int j = 0; j < sistemas; j++)
                {
                    SistemaPlanetario sistemaTemp = crearsistemaPlanetario();
                    viaLactea.Nebulosas[i].sistemasPlanetarios.Add(sistemaTemp);
                    for (int k = 0; k < (int)maxPlanetas.value; k++)
                    {
                        Planeta planeta = crearPlaneta();
                        viaLactea.Nebulosas[i].sistemasPlanetarios[j].nodos.Add(planeta);
                    }
                }
            }
        }
        else
        {
            for (int i = 0; i < (int)maxNebulosas.value; i++)
            {
                Nebulosa nebulosa = crearNebulosa();
                viaLactea.Nebulosas.Add(nebulosa);
                for (int j = 0; j < (int)maxSistemasPlanetarios.value; j++)
                {
                    SistemaPlanetario sistema = crearsistemaPlanetario();
                    viaLactea.Nebulosas[i].sistemasPlanetarios.Add(sistema);

                    for (int k = 0; k < (int)maxPlanetas.value; k++)
                    {
                        Planeta planeta = crearPlaneta();
                        viaLactea.Nebulosas[i].sistemasPlanetarios[j].nodos.Add(planeta);
                    }
                }
            }
        }


        viaLactea = ViaLacteaService.PostViaLactea(viaLactea);
        CargarViaLactea cargar = GameObject.FindGameObjectWithTag("ViaLactea").GetComponent <CargarViaLactea>();

        cargar.setViaLactea(viaLactea);

        StartCoroutine(CameraAnimations.animacionSalirMenuCrear("Editor"));

        StartCoroutine(irAEditor());
    }