public bool fillData()
    {
        Debug.Log("Fill Config");
        jsonString = File.ReadAllText(Application.dataPath + "/Resources/Json/DatosMunicipios.Json");
        if (jsonString == null)
        {
            return(false);
        }
        //itemData = JsonMapper.ToObject (jsonString);
        TodosMunicipios = new List <UnMunicipio> ();
        var N    = JSON.Parse(jsonString);
        int cont = 0;

        for (int i = 0; i < N.Count; i++)
        {
            um = new UnMunicipio();
            //scenes = new List<Escena> ();
            um.codigo = N [i] ["codigo"];
            um.nombre = N [i] ["nombre"];
            //Personas
            um.bibliotecas    = N [i] ["bibliotecas"];
            um.bibliobuses    = N [i] ["bibliobuses"];
            um.teleasistencia = N [i] ["teleasistencia"];
            um.hestia         = N [i] ["hestia"];
            um.governobert    = N [i] ["governobert"];
            um.xaloc          = N [i] ["xaloc"];
            um.km2            = N [i] ["km2"];
            //um.km22=N [i] ["KM22"];
            //Sostenibilidad
            um.CambioClimatico  = N [i] ["CambioClimatico"];
            um.Sostenibilidad   = N [i] ["Sostenibilidad"];
            um.EconomiaCircular = N [i] ["EconomiaCircular"];
            //um.emissions=N [i] ["emissions"];
            um.CalderesBiomassa    = N [i] ["CalderesBiomassa"];
            um.FotovoltaiquesAuto  = N [i] ["FotovoltaiquesAuto"];
            um.FotovoltaiquesVenta = N [i] ["FotovoltaiquesVenta"];
            um.AnalisisParticulas  = N [i] ["AnalisisParticulas"];
            um.AguaFuentes         = N [i] ["AguaFuentes"];
            um.MedidaSonido        = N [i] ["MedidaSonido"];
            um.SoporteTecnico      = N [i] ["SoporteTecnico"];
            um.AparatosPrestados   = N [i] ["AparatosPrestados"];
            um.Turismo             = N [i] ["Turismo"];
            //Tecnologia
            um.AsesoramientoJuridico = N [i] ["AsesoramientoJuridico"];
            um.GestionInformacion    = N [i] ["GestionInformacion"];
            um.GestionFormacion      = N [i] ["GestionFormacion"];
            um.HERMES = N [i] ["HERMES"];
            um.GestionContabilidad = N [i] ["GestionContabilidad"];
            um.GestionPadron       = N [i] ["GestionPadron"];
            um.GestionWebs         = N [i] ["GestionWebs"];
            um.Muniapps            = N [i] ["Muniapps"];
            um.PlataformaUrbana1   = N [i] ["PlataformaUrbana1"];
            um.PlataformaUrbana2   = N [i] ["PlataformaUrbana2"];
            um.Hibrid = N[i]["Hibrid"];
            um.SITMUN = N [i] ["SITMUN"];
            um.InfraestructurasInformacion = N [i] ["InfraestructurasInformacion"];
            //Posicion
            um.posX = N [i] ["posX"];
            um.posY = N [i] ["posY"];
            um.posZ = N [i] ["posZ"];

            TodosMunicipios.Add(um);

            //Debug.Log ("Nombre: "+um.nombre);
            //Debug.Log ("x: "+um.posX+" y: "+um.posY+" z: "+um.posZ);
            //if (um.bibliobuses != 0) {
            //Debug.Log ("Hay biblio: " + um.bibliotecas);
            cont++;
            GameObject Marker = Instantiate(marcador, new Vector3(um.posX, um.posY, um.posZ), Quaternion.identity);
            //GameObject Marker=Instantiate (marcador, new Vector3 (um.posX, um.posY, um.posZ), Quaternion.identity);
            Vector3 v = new Vector3(um.posX, um.posY, um.posZ);
            //v.y = -27;
            //Marker.transform.position= v;
            //GameObject Marker=Instantiate (marcador, new Vector3 (um.posX, um.posY, um.posZ), Quaternion.identity);
            //GameObject Marker=Instantiate (marcador, new Vector3 (um.posX, 70, um.posZ), Quaternion.identity);

            MarkerBehaviour MB = Marker.GetComponentInChildren <MarkerBehaviour> ();

            MB.codigo = um.codigo;
            MB.setYpos(um.posY);
            TapaBehaviour TB = Marker.GetComponentInChildren <TapaBehaviour> ();
            TB.codigo = um.codigo;
            //MB.pos = new Vector3 (um.posX,um.posY,um.posZ);
            //MB.yPos = um.posY;
            //Marker.transform.position= new Vector3 (um.posX,um.posY,um.posZ);
            Marker.transform.position = new Vector3(um.posX, um.posY - 27, um.posZ);
            //}
        }

        //LEYENDAS
        Debug.Log("Fill Config leyendas");
        jsonString = File.ReadAllText(Application.dataPath + "/Resources/Json/json_maqueta_es_en_ca.Json");
        if (jsonString == null)
        {
            Debug.Log("Error json");
            return(false);
        }
        TodasLeyendas = new List <Leyenda> ();
        var J     = JSON.Parse(jsonString);
        int conta = 0;

        Debug.Log("Temas:" + J.Count);
        for (int i = 0; i < J.Count; i++)
        {
            Debug.Log("Temas:" + i);

            Debug.Log("Contenidos tema:" + J[i]["contenidos"].Count);
            for (int j = 0; j < J[i]["contenidos"].Count; j++)
            {
                Debug.Log(" Subcontenidos:" + J [i] ["contenidos"] [j] ["Subcontenidos"].Count);
                if (J [i] ["contenidos"] [j] ["Subcontenidos"].Count > 0)
                {
                    ly = new Leyenda();
                    Debug.Log(" Rellena subcontenido");
                    for (int k = 0; k < J[i]["contenidos"][j]["Subcontenidos"].Count; k++)
                    {
                        ly.codigo      = J [i] ["contenidos"] [j] ["Subcontenidos"] [k] ["id"];
                        ly.codigoPadre = J [i] ["contenidos"] [j] ["id"];
                        ly.leyenda_esp = J [i] ["contenidos"] [j] ["Subcontenidos"] [k] ["idiomas"][0]["leyenda"];
                        ly.leyenda_ing = J [i] ["contenidos"] [j] ["Subcontenidos"] [k] ["idiomas"][1]["leyenda"];
                        ly.leyenda_cat = J [i] ["contenidos"] [j] ["Subcontenidos"] [k] ["idiomas"][2]["leyenda"];
                        Debug.Log("Codigo:" + ly.codigo + " leyenda" + ly.leyenda_esp);
                        TodasLeyendas.Add(ly);
                    }
                }
                else
                {
                    ly = new Leyenda();
                    Debug.Log(" Rellena contenido");
                    ly.codigo      = J [i] ["contenidos"] [j] ["id"];
                    ly.codigoPadre = J [i] ["contenidos"] [j] ["id"];
                    ly.leyenda_esp = J [i] ["contenidos"] [j] ["idiomas"] [0] ["leyenda"];
                    ly.leyenda_ing = J [i] ["contenidos"] [j] ["idiomas"] [1] ["leyenda"];
                    ly.leyenda_cat = J [i] ["contenidos"] [j] ["idiomas"] [2] ["leyenda"];
                    Debug.Log("Codigo:" + ly.codigo + " leyenda" + ly.leyenda_esp);
                    TodasLeyendas.Add(ly);
                }
            }
            Debug.Log("End for");
        }
        //FIN LEYENDAS


        Debug.Log("Datos recuperados. ");
        Debug.Log("Pintados: " + cont);
        //Instantiate(marcador,new Vector3(TodosMunicipios[0].posX,TodosMunicipios[0].posY,TodosMunicipios[0].posZ),Quaternion.identity);
        AnimationTrigger atScript = AnimStarters.GetComponent <AnimationTrigger>();

        //atScript.isGrowing = true;
        return(true);
    }
Beispiel #2
0
    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.name == "Maqueta1" || col.gameObject.name == "Maqueta2" || col.gameObject.name == "Maqueta3")
        {
            //Debug.Log ("IGNORE");
        }
        else
        {
            if (this.gameObject.name == "Tablet1" || this.gameObject.name == "Tablet2" || this.gameObject.name == "Tablet3")
            {
                if (col.gameObject.name != "MarkerLeyenda1" && col.gameObject.name != "MarkerLeyenda2" && col.gameObject.name != "MarkerLeyenda3")           //Conos y control movimiento

                //col.gameObject.GetComponent<Renderer> ().material.color = colorToChange; //color del cono

                {
                    AnimationTrigger at = gameObject.GetComponent <AnimationTrigger>();
                    if (at.contenido != "Mesura" && at.contenido != "Plataforma")                       //Si es tapa
                    //if (at.contenido != "Mesura") {
                    {
                        MarkerFlicker mf = col.gameObject.GetComponent <MarkerFlicker> ();
                        //mf.c = colorToChange;
                    }
                    //Debug.Log (mb);
                    if (col.gameObject.name != "Tapa1")
                    {
                        MarkerBehaviour mb = col.gameObject.GetComponent <MarkerBehaviour>();

                        /*if(isSuperposition){
                         *      mb.isSuperposition=true;
                         * }*/
                        mb.animationDecision(at.contenido, this.gameObject.name, colorToChange);
                    }
                    //mb.StartState = true;
                    //Debug.Log ("HIT: "+col.gameObject.name);
                }
                if (col.gameObject.name == "Tapa1")               //control de la vision y el color
                {
                    AnimationTrigger at = gameObject.GetComponent <AnimationTrigger>();
                    if (at.contenido != "Mesura" && at.contenido != "Plataforma")
                    {
                        //if (at.contenido != "Mesura") {
                        LineRenderer line = col.gameObject.GetComponent <LineRenderer> ();
                        line.enabled = false;
                        TapaBehaviour tb = col.gameObject.GetComponent <TapaBehaviour> ();
                        tb.isNeuronal   = false;
                        tb.isPlataforma = false;
                        if (isSuperposition)
                        {
                            tb.isSuperposition = true;
                            tb.animationDecision("super", this.gameObject.name);

                            /*Material[] m = tb.GetComponent<Renderer>().materials;
                             * Color cv = m[1].color;
                             * cv.a = 1;
                             * m[1].color = cv; */
                        }
                        else
                        {
                            col.gameObject.GetComponent <Renderer> ().material.color = colorToChange;
                            MarkerFlicker mf = col.gameObject.GetComponent <MarkerFlicker> ();
                            //mf.c = colorToChange;
                        }
                        //cont++;
                        //Debug.Log ("HIT:NOT MESURA ");
                    }
                    else if (at.contenido == "Mesura" || at.contenido == "Plataforma")                      //Mesura y Plataforma
                    {
                        TapaBehaviour tb   = col.gameObject.GetComponent <TapaBehaviour> ();
                        LineRenderer  line = col.gameObject.GetComponent <LineRenderer> ();
                        line.enabled = false;

                        tb.animationDecision(at.contenido, this.gameObject.name);
                        //Debug.Log ("HIT:MESURA and PlAT "+at.contenido + "  "+this.gameObject.name);
                    }
                }
            }

            if (this.gameObject.name == "Tablet1Apagado" || this.gameObject.name == "Tablet2Apagado" || this.gameObject.name == "Tablet3Apagado")
            {
                if (col.gameObject.name != "Tapa1")
                {
                    MarkerBehaviour  mb = col.gameObject.GetComponent <MarkerBehaviour> ();
                    AnimationTrigger at = gameObject.GetComponent <AnimationTrigger> ();
                    //Debug.Log (col.gameObject.name);
                    //Debug.Log (mb);
                    mb.animationDecision(at.contenido, this.gameObject.name, colorToChange);
                    //Debug.Log ("HIT");
                }
                else
                {
                    TapaBehaviour tb = col.gameObject.GetComponent <TapaBehaviour> ();
                    tb.isNeuronal = false;
                }
            }
            if (this.gameObject.name == "ApagaSuperpos")
            {
                if (col.gameObject.name != "Tapa1")
                {
                    MarkerBehaviour  mb = col.gameObject.GetComponent <MarkerBehaviour> ();
                    AnimationTrigger at = gameObject.GetComponent <AnimationTrigger> ();
                    TapaBehaviour    tb = col.gameObject.GetComponent <TapaBehaviour> ();

                    //Debug.Log (col.gameObject.name);
                    //Debug.Log (mb);
                    mb.animationDecision(at.contenido, this.gameObject.name, colorToChange);
                    //tb.isSuperposition = false;
                    //Debug.Log ("HIT");
                }
                else
                {
                    TapaBehaviour tb = col.gameObject.GetComponent <TapaBehaviour> ();
                    tb.isNeuronal = false;
                    Material[] m  = tb.GetComponent <Renderer>().materials;
                    Color      cv = m[1].color;
                    cv.a       = 0;
                    m[1].color = cv;
                }
            }
            if (this.gameObject.name == "ControlJSonCollider")
            {
                GameObject sc = GameObject.Find("SceneControl");
                rmd = sc.GetComponent <ReadMunicipiData> ();
                //Debug.Log ("HITJSON");

                int code = col.gameObject.GetComponent <MarkerBehaviour> ().codigo;
                for (int i = 0; i < rmd.TodosMunicipios.Count; i++)
                {
                    //Debug.Log ("State:0 m1[i]:"+m1[i]+" Codigo:"+codigo);
                    if (code == rmd.TodosMunicipios [i].codigo)
                    {
                        float f = col.transform.position.y;
                        //float f=col.transform.parent.position.y;
                        Debug.Log("ParentPosy:" + f);
                        var v = rmd.TodosMunicipios [i];
                        v.posY = f;
                        rmd.TodosMunicipios[i] = v;
                        Debug.Log("Y nueva:" + rmd.TodosMunicipios[i].posY);
                        cont++;
                        Debug.Log("EscritosJson: " + cont);
                        break;
                    }
                }
            }
        }
    }