private void insertarElemento()
    {
        if (accion == taccion.insertar) {
            if (Time.realtimeSinceStartup > tiempoUltimoModeloInsercion + tiempoModeloInsercion) {
                tiempoUltimoModeloInsercion = Time.realtimeSinceStartup;
                int posX = 0;
                int posY = 0;
                RaycastHit hit;
                int tipo = (int)elementoInsercion - 1;
                if (principal.raycastRoca (Input.mousePosition, ref posX, ref posY, out hit)) {
                    //Vector3 coordsVert = principal.vida.tablero[posY, posX].coordsVert;
                    //Vector3 coordsVert = new Vector3(principal.vida.tablero[posY, posX].coordsVert.x,principal.vida.tablero[posY, posX].coordsVert.y,hit.normal.z);
                    //Mover la malla
                    //modeloInsercion.transform.position = coordsVert;
                    modeloInsercion.transform.position = hit.point;
                    Vector3 normal = modeloInsercion.transform.position - modeloInsercion.transform.parent.position;
                    //modeloInsercion.transform.position = principal.vida.objetoRoca.transform.TransformPoint (modeloInsercion.transform.position);
                    modeloInsercion.transform.rotation = Quaternion.LookRotation (normal);
                    modeloInsercion.GetComponentInChildren<Renderer>().material.SetFloat ("_FiltroOn", 1.0f);
                    modeloInsercion.GetComponentInChildren<Renderer>().material.SetColor ("_Tinte", Color.red);
                    forzarTooltip = false;
                    //Edificio
                    if (tipo >= 0 && tipo < 5) {
                        TipoEdificio tedif = principal.vida.tiposEdificios[tipo];
                        if (principal.recursosSuficientes (tedif.energiaConsumidaAlCrear, tedif.compBasConsumidosAlCrear, tedif.compAvzConsumidosAlCrear, tedif.matBioConsumidoAlCrear)) {
                            if (principal.vida.compruebaAnadeEdificio (tedif, posY, posX))
                                modeloInsercion.GetComponentInChildren<Renderer>().material.SetColor ("_Tinte", Color.green);
                            else {
                                forzarTooltip = true;
                                mensajeForzarTooltip = "Habitat incompatible o ya ocupado";
                            }
                        } else {
                            forzarTooltip = true;
                            mensajeForzarTooltip = "No hay recursos suficientes";
                        }
                        //Vegetal
                    } else if (tipo >= 5 && tipo < 15) {
                        tipo -= 5;
                        EspecieVegetal especie = (EspecieVegetal)principal.vida.especies[tipo];
                        if (principal.vida.compruebaAnadeVegetal (especie, especie.habitabilidadInicial, 0.0f, posY, posX))
                            modeloInsercion.GetComponentInChildren<Renderer>().material.SetColor ("_Tinte", Color.green);
                        else {
                            forzarTooltip = true;
                            mensajeForzarTooltip = "Habitat incompatible o ya ocupado";
                        }
                        //Animal (herbivoro o carnivoro)
                    } else if (tipo >= 15 && tipo < 25) {
                        tipo -= 5;
                        EspecieAnimal especie = (EspecieAnimal)principal.vida.especies[tipo];
                        if (principal.vida.compruebaAnadeAnimal (especie, posY, posX))
                            modeloInsercion.GetComponentInChildren<Renderer>().material.SetColor ("_Tinte", Color.green);
                        else {
                            forzarTooltip = true;
                            mensajeForzarTooltip = "Habitat incompatible o ya ocupado";
                        }
                    }
                    //Probamos inserción
                    if (Input.GetMouseButton (0)) {
                        tipo = (int)elementoInsercion - 1;
                        //Edificio
                        if (tipo >= 0 && tipo < 5) {
                            TipoEdificio tedif = principal.vida.tiposEdificios[tipo];
                            if (principal.recursosSuficientes (tedif.energiaConsumidaAlCrear, tedif.compBasConsumidosAlCrear, tedif.compAvzConsumidosAlCrear, tedif.matBioConsumidoAlCrear)) {
                                float eficiencia = 1.0f;
                                int radioAccion;
                                List<Tupla<int,int,bool>> matrizRadioAccion;
                                if(eficiencia < 0.25f)
                                {
                                    radioAccion = 0;
                                    matrizRadioAccion = new List<Tupla<int, int, bool>>();
                                }
                                else if(eficiencia < 0.5f)
                                {
                                    radioAccion = 2;
                                    matrizRadioAccion = FuncTablero.calculaMatrizRadio2Circular(posY,posX);
                                }
                                else if(eficiencia < 0.75f)
                                {
                                    radioAccion = 3;
                                    matrizRadioAccion = FuncTablero.calculaMatrizRadio3Circular(posY,posX);
                                }
                                else if(eficiencia < 1.0f)
                                {
                                    radioAccion = 4;
                                    matrizRadioAccion = FuncTablero.calculaMatrizRadio4Circular(posY,posX);
                                }
                                else
                                {
                                    radioAccion = 5;
                                    matrizRadioAccion = FuncTablero.calculaMatrizRadio5Circular(posY,posX);
                                }
                                int numMetales = 0;
                                if(tedif.metalesAUsar == T_elementos.comunes)
                                    numMetales = principal.vida.calculaMetalesComunes(matrizRadioAccion);
                                else if(tedif.metalesAUsar == T_elementos.raros)
                                    numMetales = principal.vida.calculaMetalesRaros(matrizRadioAccion);

                                if (principal.vida.anadeEdificio (tedif, posY, posX, eficiencia,numMetales,matrizRadioAccion,radioAccion, hit.point)) {
                                    principal.consumeRecursos (tedif.energiaConsumidaAlCrear, tedif.compBasConsumidosAlCrear, tedif.compAvzConsumidosAlCrear, tedif.matBioConsumidoAlCrear);
                                    principal.vida.tablero[posY, posX].edificio.modelo.GetComponentInChildren<Animation>().Play();
                                    if (elementoInsercion == telementoInsercion.centralEnergia && etapaJuego == tEtapaJuego.inicio)
                                        etapaJuego = InterfazPrincipal.tEtapaJuego.centralConstruida;
                                    if (elementoInsercion == telementoInsercion.fabricaCompBas && etapaJuego == tEtapaJuego.centralConstruida)
                                        etapaJuego = InterfazPrincipal.tEtapaJuego.fabCompBasConstruida;
                                    if (elementoInsercion == telementoInsercion.granja && etapaJuego == tEtapaJuego.mejoraBiologicoComprada)
                                        etapaJuego = InterfazPrincipal.tEtapaJuego.granjaConstruida;
                                    if (elementoInsercion == telementoInsercion.fabricaCompAdv && etapaJuego == tEtapaJuego.mejoraAvanzadosComprada)
                                        etapaJuego = InterfazPrincipal.tEtapaJuego.fabCompAdvComprada;
                                } else {
                                    GameObject mensaje = GameObject.FindGameObjectWithTag("Particulas").GetComponent<Particulas>().mensajeErrorPosicion;
                                    Vector3 posicionMensaje = Vector3.Lerp(modeloInsercion.transform.position, Camera.main.transform.position, 0.15f);
                                    Instantiate(mensaje, posicionMensaje, Quaternion.LookRotation(Camera.main.transform.forward));
                                    Audio_SoundFX efectos = sonidoFX.GetComponent<Audio_SoundFX> ();
                                    efectos.playNumber (Random.Range (1, 3));
                                    //Sonidos de error son el 1 y 2
                                }
                            } else {
                                GameObject mensaje = GameObject.FindGameObjectWithTag("Particulas").GetComponent<Particulas>().mensajeNoRecursos;
                                Vector3 posicionMensaje = Vector3.Lerp(modeloInsercion.transform.position, Camera.main.transform.position, 0.15f);
                                Instantiate(mensaje, posicionMensaje, Quaternion.LookRotation(Camera.main.transform.forward));
                                Audio_SoundFX efectos = sonidoFX.GetComponent<Audio_SoundFX> ();
                                efectos.playNumber (Random.Range (1, 3));
                                //Sonidos de error son el 1 y 2
                            }
                            elementoInsercion = telementoInsercion.ninguno;
                            accion = taccion.ninguna;
                            //principal.objetoRoca.renderer.sharedMaterials[3].SetFloat("_FiltroOn", 0);
                            //Vegetal
                        } else if (tipo >= 5 && tipo < 15) {
                            tipo -= 5;
                            EspecieVegetal especie = (EspecieVegetal)principal.vida.especies[tipo];
                            TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                            List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(especie));
                            if (principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                                if (principal.vida.anadeVegetal (especie, especie.habitabilidadInicial, 0.0f, posY, posX, hit.point)) {

                                    principal.consumeRecursos(costes[0], costes[1], costes[2], costes[3]);
                                    elementoInsercion = telementoInsercion.ninguno;
                                    accion = taccion.ninguna;
                                }
                                else {	//No se puede ahi
                                    GameObject mensaje = GameObject.FindGameObjectWithTag("Particulas").GetComponent<Particulas>().mensajeErrorPosicion;
                                    Vector3 posicionMensaje = Vector3.Lerp(modeloInsercion.transform.position, Camera.main.transform.position, 0.15f);
                                    Instantiate(mensaje, posicionMensaje, Quaternion.LookRotation(Camera.main.transform.forward));
                                    Audio_SoundFX efectos = sonidoFX.GetComponent<Audio_SoundFX> ();
                                    efectos.playNumber (Random.Range (1, 3));
                                }
                            }
                            else {	//Sin recursos
                                GameObject mensaje = GameObject.FindGameObjectWithTag("Particulas").GetComponent<Particulas>().mensajeNoRecursos;
                                Vector3 posicionMensaje = Vector3.Lerp(modeloInsercion.transform.position, Camera.main.transform.position, 0.15f);
                                Instantiate(mensaje, posicionMensaje, Quaternion.LookRotation(Camera.main.transform.forward));
                                Audio_SoundFX efectos = sonidoFX.GetComponent<Audio_SoundFX> ();
                                efectos.playNumber (Random.Range (1, 3));
                            }
                            //Animal (herbivoro o carnivoro)
                        } else if (tipo >= 15 && tipo < 25) {
                            tipo -= 5;
                            EspecieAnimal especie = (EspecieAnimal)principal.vida.especies[tipo];
                            TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                            List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(especie));
                            if (principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                                if (principal.vida.anadeAnimal (especie, posY, posX,hit.point)) {
                                    principal.consumeRecursos(costes[0], costes[1], costes[2], costes[3]);
                                    elementoInsercion = telementoInsercion.ninguno;
                                    accion = taccion.ninguna;
                                }
                                else {
                                    GameObject mensaje = GameObject.FindGameObjectWithTag("Particulas").GetComponent<Particulas>().mensajeErrorPosicion;
                                    Vector3 posicionMensaje = Vector3.Lerp(modeloInsercion.transform.position, Camera.main.transform.position, 0.15f);
                                    Instantiate(mensaje, posicionMensaje, Quaternion.LookRotation(Camera.main.transform.forward));
                                    Audio_SoundFX efectos = sonidoFX.GetComponent<Audio_SoundFX> ();
                                    efectos.playNumber (Random.Range (1, 3));
                                    //Sonidos de error son el 1 y 2
                                }
                            }
                            else {	//No hay recursos suficientes
                                GameObject mensaje = GameObject.FindGameObjectWithTag("Particulas").GetComponent<Particulas>().mensajeNoRecursos;
                                Vector3 posicionMensaje = Vector3.Lerp(modeloInsercion.transform.position, Camera.main.transform.position, 0.15f);
                                Instantiate(mensaje, posicionMensaje, Quaternion.LookRotation(Camera.main.transform.forward));
                                Audio_SoundFX efectos = sonidoFX.GetComponent<Audio_SoundFX> ();
                                efectos.playNumber (Random.Range (1, 3));
                            }
                        }
                        Destroy (modeloInsercion);
                        //Desactivamos inserción
                    } else if (Input.GetMouseButton (1)) {
                        elementoInsercion = telementoInsercion.ninguno;
                        accion = taccion.ninguna;
                        Destroy (modeloInsercion);
                    }
                }
            }
        }
    }
    private void insertarPortal()
    {
        if (accion == taccion.insertarPortal && etapaJuego < tEtapaJuego.portalConstruido) {
            int posX = 0;
            int posY = 0;
            RaycastHit hit;
            if (principal.raycastRoca (Input.mousePosition, ref posX, ref posY, out hit)) {
                //Mover la malla
                modeloInsercion.transform.position = hit.point;
                Vector3 normal = modeloInsercion.transform.position - modeloInsercion.transform.parent.position;
                modeloInsercion.transform.rotation = Quaternion.LookRotation (normal);
                modeloInsercion.GetComponentInChildren<Renderer>().material.SetFloat ("_FiltroOn", 1.0f);
                modeloInsercion.GetComponentInChildren<Renderer>().material.SetColor ("_Tinte", Color.red);
                List<int> costes = mejoras.costeHab8;
                Casilla temp = principal.vida.tablero[posY, posX];
                if (principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    if (temp.habitat == T_habitats.llanura && temp.edificio == null)
                        modeloInsercion.GetComponentInChildren<Renderer>().material.SetColor ("_Tinte", Color.green);
                    else {
                        forzarTooltip = true;
                        mensajeForzarTooltip = "Habitat incompatible o ya ocupado";
                    }
                } else {
                    forzarTooltip = true;
                    mensajeForzarTooltip = "No hay recursos suficientes";
                }
                //Probamos inserción
                if (Input.GetMouseButton (0)) {
                    if (principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                        if (temp.habitat == T_habitats.llanura && temp.edificio == null) {
                            principal.consumeRecursos (costes[0], costes[1], costes[2], costes[3]);
                            modeloInsercion.GetComponentInChildren<Renderer>().material.SetColor ("_Tinte", Color.white);
                            modeloInsercion.GetComponentInChildren<Renderer>().material.SetFloat ("_FiltroOn", 0.0f);
                            modeloInsercion.GetComponentInChildren<Animation>().Play();
                            etapaJuego = InterfazPrincipal.tEtapaJuego.portalConstruido;
                        } else {
                            GameObject mensaje = GameObject.FindGameObjectWithTag("Particulas").GetComponent<Particulas>().mensajeErrorPosicion;
                            Vector3 posicionMensaje = Vector3.Lerp(modeloInsercion.transform.position, Camera.main.transform.position, 0.15f);
                            Instantiate(mensaje, posicionMensaje, Quaternion.LookRotation(Camera.main.transform.forward));
                            Audio_SoundFX efectos = sonidoFX.GetComponent<Audio_SoundFX> ();
                            efectos.playNumber (Random.Range (1, 3));
                            Destroy (modeloInsercion);
                            //Sonidos de error son el 1 y 2
                        }
                    } else {
                        GameObject mensaje = GameObject.FindGameObjectWithTag("Particulas").GetComponent<Particulas>().mensajeNoRecursos;
                        Vector3 posicionMensaje = Vector3.Lerp(modeloInsercion.transform.position, Camera.main.transform.position, 0.15f);
                        Instantiate(mensaje, posicionMensaje, Quaternion.LookRotation(Camera.main.transform.forward));
                        Audio_SoundFX efectos = sonidoFX.GetComponent<Audio_SoundFX> ();
                        efectos.playNumber (Random.Range (1, 3));
                        Destroy (modeloInsercion);
                        //Sonidos de error son el 1 y 2
                    }
                    elementoInsercion = telementoInsercion.ninguno;
                    accion = taccion.ninguna;

                } else if (Input.GetMouseButton (1)) {
                    elementoInsercion = telementoInsercion.ninguno;
                    accion = taccion.ninguna;
                    Destroy (modeloInsercion);
                }
            }
        }
    }
    //Dibuja el bloque seleccion de la ventana que contiene los diferentes edificios, animales o vegetales seleccionables según que botón se haya pulsado en el bloque izquierdo
    private void bloqueSeleccion()
    {
        int posicionBloque = 0;
        int posicionBloqueMejoras = 0;
        switch (aspectRatio) {
        case taspectRatio.aspectRatio16_9:
            posicionBloque = 40;
            posicionBloqueMejoras = 37;
            break;
        case taspectRatio.aspectRatio16_10:
            posicionBloque = 45;
            posicionBloqueMejoras = 42;
            break;
        case taspectRatio.aspectRatio4_3:
            posicionBloque = 55;
            posicionBloqueMejoras = 52;
            break;
        default:
            break;
        }

        switch (accion) {
        case taccion.ninguna:
        case taccion.insertar:
        case taccion.mostrarInfoDetallada:
        case taccion.mostrarMenu:
            break;
        case taccion.seleccionarVegetal:
            Rect areaTemp = new Rect (cuantoW * 22, cuantoH * posicionBloque, cuantoW * 36, cuantoH * 4);
            GUILayout.BeginArea (areaTemp, new GUIContent (), "BloqueSeleccionVegetales");
            elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.ninguno;
            GUILayout.BeginVertical ();
            GUILayout.Space (cuantoH);
            GUILayout.BeginHorizontal (GUILayout.Height (cuantoH * 2));
            GUILayout.Space (cuantoW * 2.5f);
            if (GUILayout.Button (new GUIContent ("", "Seta"), "BotonInsertarSeta")) {
                TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(principal.vida.especiesVegetales[0]));
                if (!principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.seta;
                modeloInsercion = principal.vida.especiesVegetales[0].modelos[UnityEngine.Random.Range (0, principal.vida.especiesVegetales[0].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.seta;
                seleccionarObjetoInsercion ();
            }
            GUILayout.Space (cuantoW);
            if (GUILayout.Button (new GUIContent ("", "Flor"), "BotonInsertarFlor")) {
                TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(principal.vida.especiesVegetales[1]));
                if (!principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.flor;
                modeloInsercion = principal.vida.especiesVegetales[1].modelos[UnityEngine.Random.Range (0, principal.vida.especiesVegetales[1].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.flor;
                seleccionarObjetoInsercion ();
            }
            GUILayout.Space (cuantoW);
            if (GUILayout.Button (new GUIContent ("", "Caña"), "BotonInsertarCana")) {
                TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(principal.vida.especiesVegetales[2]));
                if (!principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.cana;
                modeloInsercion = principal.vida.especiesVegetales[2].modelos[UnityEngine.Random.Range (0, principal.vida.especiesVegetales[2].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.cana;
                seleccionarObjetoInsercion ();
            }
            GUILayout.Space (cuantoW);
            if (GUILayout.Button (new GUIContent ("", "Arbusto"), "BotonInsertarArbusto")) {
                TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(principal.vida.especiesVegetales[3]));
                if (!principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.arbusto;
                modeloInsercion = principal.vida.especiesVegetales[3].modelos[UnityEngine.Random.Range (0, principal.vida.especiesVegetales[3].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.arbusto;
                seleccionarObjetoInsercion ();
            }
            GUILayout.Space (cuantoW);
            if (GUILayout.Button (new GUIContent ("", "Estromatolito"), "BotonInsertarEstromatolito")) {
                TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(principal.vida.especiesVegetales[4]));
                if (!principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.estromatolito;
                modeloInsercion = principal.vida.especiesVegetales[4].modelos[UnityEngine.Random.Range (0, principal.vida.especiesVegetales[4].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.estromatolito;
                seleccionarObjetoInsercion ();
            }
            GUILayout.Space (cuantoW);
            if (GUILayout.Button (new GUIContent ("", "Cactus"), "BotonInsertarCactus")) {
                TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(principal.vida.especiesVegetales[5]));
                if (!principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.cactus;
                modeloInsercion = principal.vida.especiesVegetales[5].modelos[UnityEngine.Random.Range (0, principal.vida.especiesVegetales[5].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.cactus;
                seleccionarObjetoInsercion ();
            }
            GUILayout.Space (cuantoW);
            if (GUILayout.Button (new GUIContent ("", "Palmera"), "BotonInsertarPalmera")) {
                TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(principal.vida.especiesVegetales[6]));
                if (!principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.palmera;
                modeloInsercion = principal.vida.especiesVegetales[6].modelos[UnityEngine.Random.Range (0, principal.vida.especiesVegetales[6].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.palmera;
                seleccionarObjetoInsercion ();
            }
            GUILayout.Space (cuantoW);
            if (GUILayout.Button (new GUIContent ("", "Pino"), "BotonInsertarPino")) {
                TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(principal.vida.especiesVegetales[7]));
                if (!principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.pino;
                modeloInsercion = principal.vida.especiesVegetales[7].modelos[UnityEngine.Random.Range (0, principal.vida.especiesVegetales[7].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.pino;
                seleccionarObjetoInsercion ();
            }
            GUILayout.Space (cuantoW);
            if (GUILayout.Button (new GUIContent ("", "Ciprés"), "BotonInsertarCipres")) {
                TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(principal.vida.especiesVegetales[8]));
                if (!principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.cipres;
                modeloInsercion = principal.vida.especiesVegetales[8].modelos[UnityEngine.Random.Range (0, principal.vida.especiesVegetales[8].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.cipres;
                seleccionarObjetoInsercion ();
            }
            GUILayout.Space (cuantoW);
            if (GUILayout.Button (new GUIContent ("", "Pino Alto"), "BotonInsertarPinoAlto")) {
                TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(principal.vida.especiesVegetales[9]));
                if (!principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.pinoAlto;
                modeloInsercion = principal.vida.especiesVegetales[9].modelos[UnityEngine.Random.Range (0, principal.vida.especiesVegetales[9].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.pinoAlto;
                seleccionarObjetoInsercion ();
            }
            GUILayout.Space (cuantoW * 2.5f);
            GUILayout.EndHorizontal ();
            GUILayout.Space (cuantoH);
            GUILayout.EndVertical ();
            GUILayout.EndArea ();
            break;
        case taccion.seleccionarAnimal:
            GUILayout.BeginArea (new Rect (cuantoW * 22, cuantoH * posicionBloque, cuantoW * 36, cuantoH * 4), new GUIContent (), "BloqueSeleccionAnimales");
            GUILayout.BeginVertical ();
            elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.ninguno;
            GUILayout.Space (cuantoH);
            GUILayout.BeginHorizontal (GUILayout.Height (cuantoH * 2));
            GUILayout.Space (cuantoW * 1.5f);
            if (GUILayout.Button (new GUIContent ("", "Insertar insectos herbivoros"), "BotonInsertarHerbivoro1")) {
                TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(principal.vida.especiesAnimales[0]));
                if (!principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.herbivoro1;
                modeloInsercion = principal.vida.especiesAnimales[0].modelos[UnityEngine.Random.Range (0, principal.vida.especiesAnimales[0].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.herbivoro1;
                seleccionarObjetoInsercion ();
            }
            GUILayout.Space (cuantoW);
            if (GUILayout.Button (new GUIContent ("", "Insertar peque\u00f1os roedores"), "BotonInsertarHerbivoro2")) {
                TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(principal.vida.especiesAnimales[1]));
                if (!principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.herbivoro2;
                modeloInsercion = principal.vida.especiesAnimales[1].modelos[UnityEngine.Random.Range (0, principal.vida.especiesAnimales[1].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.herbivoro2;
                seleccionarObjetoInsercion ();
            }
            GUILayout.Space (cuantoW);
            if (GUILayout.Button (new GUIContent ("", "Insertar grandes vacunos"), "BotonInsertarHerbivoro3")) {
                TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(principal.vida.especiesAnimales[2]));
                if (!principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.herbivoro3;
                modeloInsercion = principal.vida.especiesAnimales[2].modelos[UnityEngine.Random.Range (0, principal.vida.especiesAnimales[2].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.herbivoro3;
                seleccionarObjetoInsercion ();
            }
            GUILayout.Space (cuantoW);
            if (GUILayout.Button (new GUIContent ("", "Insertar herbivoros de la sabana"), "BotonInsertarHerbivoro4")) {
                TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(principal.vida.especiesAnimales[3]));
                if (!principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.herbivoro4;
                modeloInsercion = principal.vida.especiesAnimales[3].modelos[UnityEngine.Random.Range (0, principal.vida.especiesAnimales[3].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.herbivoro4;
                seleccionarObjetoInsercion ();
            }
            GUILayout.Space (cuantoW);
            if (GUILayout.Button (new GUIContent ("", "Insertar tortuga gigante"), "BotonInsertarHerbivoro5")) {
                TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(principal.vida.especiesAnimales[4]));
                if (!principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.herbivoro5;
                modeloInsercion = principal.vida.especiesAnimales[4].modelos[UnityEngine.Random.Range (0, principal.vida.especiesAnimales[4].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.herbivoro5;
                seleccionarObjetoInsercion ();
            }
            GUILayout.Space (cuantoW * 3);
            if (GUILayout.Button (new GUIContent ("", "Insertar zorro"), "BotonInsertarCarnivoro1")) {
                TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(principal.vida.especiesAnimales[5]));
                if (!principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.carnivoro1;
                modeloInsercion = principal.vida.especiesAnimales[5].modelos[UnityEngine.Random.Range (0, principal.vida.especiesAnimales[5].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.carnivoro1;
                seleccionarObjetoInsercion ();
            }
            GUILayout.Space (cuantoW);
            if (GUILayout.Button (new GUIContent ("", "Insertar lobo"), "BotonInsertarCarnivoro2")) {
                TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(principal.vida.especiesAnimales[6]));
                if (!principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.carnivoro2;
                modeloInsercion = principal.vida.especiesAnimales[6].modelos[UnityEngine.Random.Range (0, principal.vida.especiesAnimales[6].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.carnivoro2;
                seleccionarObjetoInsercion ();
            }
            GUILayout.Space (cuantoW);
            if (GUILayout.Button (new GUIContent ("", "Insertar tigre"), "BotonInsertarCarnivoro3")) {
                TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(principal.vida.especiesAnimales[7]));
                if (!principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.carnivoro3;
                modeloInsercion = principal.vida.especiesAnimales[7].modelos[UnityEngine.Random.Range (0, principal.vida.especiesAnimales[7].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.carnivoro3;
                seleccionarObjetoInsercion ();
            }
            GUILayout.Space (cuantoW);
            if (GUILayout.Button (new GUIContent ("", "Insertar oso"), "BotonInsertarCarnivoro4")) {
                TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(principal.vida.especiesAnimales[8]));
                if (!principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.carnivoro4;
                modeloInsercion = principal.vida.especiesAnimales[8].modelos[UnityEngine.Random.Range (0, principal.vida.especiesAnimales[8].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.carnivoro4;
                seleccionarObjetoInsercion ();
            }
            GUILayout.Space (cuantoW);
            if (GUILayout.Button (new GUIContent ("", "Insertar tiranosaurio"), "BotonInsertarCarnivoro5")) {
                TiposSeres tiposSeres = GameObject.FindGameObjectWithTag ("TiposSeres").GetComponent<TiposSeres> ();
                List<int> costes = tiposSeres.getCostes(tiposSeres.getNumeroSer(principal.vida.especiesAnimales[9]));
                if (!principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.carnivoro5;
                modeloInsercion = principal.vida.especiesAnimales[9].modelos[UnityEngine.Random.Range (0, principal.vida.especiesAnimales[9].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.carnivoro5;
                seleccionarObjetoInsercion ();
            }
            GUILayout.Space (cuantoW * 1.5f);
            GUILayout.EndHorizontal ();
            GUILayout.Space (cuantoH);
            GUILayout.EndVertical ();
            GUILayout.EndArea ();
            break;
        case taccion.seleccionarEdificio:
            GUILayout.BeginArea (new Rect (cuantoW * 32, cuantoH * posicionBloque, cuantoW * 16, cuantoH * 4), new GUIContent (), "BloqueSeleccionEdificios");
            GUILayout.BeginVertical ();
            elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.ninguno;
            GUILayout.Space (cuantoH);
            GUILayout.BeginHorizontal (GUILayout.Height (cuantoH * 2));
            GUILayout.Space (cuantoW);
            if (GUILayout.Button (new GUIContent ("", "Central de energía"), "BotonInsertarCenEn")) {
                TipoEdificio temp = principal.vida.tiposEdificios[1];
                int eneTemp = temp.energiaConsumidaAlCrear;
                int compBasTemp = temp.compBasConsumidosAlCrear;
                int compAdvTemp = temp.compAvzConsumidosAlCrear;
                int matBioTemp = temp.matBioConsumidoAlCrear;
                if (!principal.recursosSuficientes(eneTemp, compBasTemp, compAdvTemp, matBioTemp)) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.centralEnergia;
                modeloInsercion = principal.vida.tiposEdificios[1].modelos[UnityEngine.Random.Range (0, principal.vida.tiposEdificios[1].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.centralEnergia;
                seleccionarObjetoInsercion ();
            }
            GUILayout.Space (cuantoW);
            string tooltip = "";
            if (etapaJuego < tEtapaJuego.centralConstruida) {
                GUI.enabled = false;
                tooltip = "Debes construir primero una central de energia!";
            }
            else
                tooltip = "Fábrica de componentes básicos";
            if (GUILayout.Button (new GUIContent ("", tooltip), "BotonInsertarFabComBas")) {
                TipoEdificio temp = principal.vida.tiposEdificios[0];
                int eneTemp = temp.energiaConsumidaAlCrear;
                int compBasTemp = temp.compBasConsumidosAlCrear;
                int compAdvTemp = temp.compAvzConsumidosAlCrear;
                int matBioTemp = temp.matBioConsumidoAlCrear;
                if (!principal.recursosSuficientes(eneTemp, compBasTemp, compAdvTemp, matBioTemp)) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.fabricaCompBas;
                modeloInsercion = principal.vida.tiposEdificios[0].modelos[UnityEngine.Random.Range (0, principal.vida.tiposEdificios[0].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.fabricaCompBas;
                seleccionarObjetoInsercion ();
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (etapaJuego < tEtapaJuego.mejoraBiologicoComprada) {
                GUI.enabled = false;
                tooltip = "Debes investigar esta tecnologia primero.";
            }
            else
                tooltip = "Granja";
            if (GUILayout.Button (new GUIContent ("", tooltip), "BotonInsertarGranja")) {
                TipoEdificio temp = principal.vida.tiposEdificios[2];
                int eneTemp = temp.energiaConsumidaAlCrear;
                int compBasTemp = temp.compBasConsumidosAlCrear;
                int compAdvTemp = temp.compAvzConsumidosAlCrear;
                int matBioTemp = temp.matBioConsumidoAlCrear;
                if (!principal.recursosSuficientes(eneTemp, compBasTemp, compAdvTemp, matBioTemp)) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.granja;
                modeloInsercion = principal.vida.tiposEdificios[2].modelos[UnityEngine.Random.Range (0, principal.vida.tiposEdificios[2].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
                //principal.objetoRoca.renderer.sharedMaterials[3].SetFloat("_FiltroOn", 1);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.granja;
                seleccionarObjetoInsercion ();
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (etapaJuego < tEtapaJuego.mejoraAvanzadosComprada) {
                GUI.enabled = false;
                tooltip = "Debes investigar esta tecnologia primero.";
            }
            else
                tooltip = "Fábrica de componentes avanzados";
            if (GUILayout.Button (new GUIContent ("", tooltip), "BotonInsertarFabComAdv")) {
                TipoEdificio temp = principal.vida.tiposEdificios[3];
                int eneTemp = temp.energiaConsumidaAlCrear;
                int compBasTemp = temp.compBasConsumidosAlCrear;
                int compAdvTemp = temp.compAvzConsumidosAlCrear;
                int matBioTemp = temp.matBioConsumidoAlCrear;
                if (!principal.recursosSuficientes(eneTemp, compBasTemp, compAdvTemp, matBioTemp)) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.fabricaCompAdv;
                modeloInsercion = principal.vida.tiposEdificios[3].modelos[UnityEngine.Random.Range (0, principal.vida.tiposEdificios[3].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
                //principal.objetoRoca.renderer.sharedMaterials[3].SetFloat("_FiltroOn", 1);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.fabricaCompAdv;
                seleccionarObjetoInsercion ();
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (etapaJuego < tEtapaJuego.mejoraAvanzadosComprada) {
                GUI.enabled = false;
                tooltip = "Debes investigar esta tecnologia primero.";
            }
            else
                tooltip = "Central de energía avanzada";
            if (GUILayout.Button (new GUIContent ("", tooltip), "BotonInsertarCenEnAdv")) {
                TipoEdificio temp = principal.vida.tiposEdificios[4];
                int eneTemp = temp.energiaConsumidaAlCrear;
                int compBasTemp = temp.compBasConsumidosAlCrear;
                int compAdvTemp = temp.compAvzConsumidosAlCrear;
                int matBioTemp = temp.matBioConsumidoAlCrear;
                if (!principal.recursosSuficientes(eneTemp, compBasTemp, compAdvTemp, matBioTemp)) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                accion = taccion.insertar;
                elementoInsercion = telementoInsercion.centralEnergiaAdv;
                modeloInsercion = principal.vida.tiposEdificios[4].modelos[UnityEngine.Random.Range (0, principal.vida.tiposEdificios[4].modelos.Count)];
                modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
                //principal.objetoRoca.renderer.sharedMaterials[3].SetFloat("_FiltroOn", 1);
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.insercion;
                elementoInsercionDerecho = InterfazPrincipal.telementoInsercion.centralEnergiaAdv;
                seleccionarObjetoInsercion ();
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            GUILayout.EndHorizontal ();
            GUILayout.Space (cuantoH);
            GUILayout.EndVertical ();
            GUILayout.EndArea ();
            break;
        case taccion.seleccionarMejora:
            mejoraHover = -1;
            GUILayout.BeginArea (new Rect (cuantoW * 22, cuantoH * posicionBloqueMejoras, cuantoW * 36, cuantoH * 7), new GUIContent (), "BloqueSeleccionMejoras");
            GUILayout.BeginVertical ();
            GUILayout.Space (cuantoH);
            GUILayout.BeginHorizontal (GUILayout.Height (cuantoH * 2));
            GUILayout.Space (cuantoW * 6.5f);
            //Sensores -----------------------------------------------------
            if (mejoras.mejorasCompradas[0])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Sistema de Sondeo General"), "BotonMejoraInformacion")) {
                List<int> costeT = mejoras.getCosteMejora(0);
                if (!principal.recursosSuficientes(costeT[0], costeT[1], costeT[2], costeT[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                principal.consumeRecursos(costeT[0], costeT[1], costeT[2], costeT[3]);
                mejoras.compraMejora0();
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.mejoras;
                mejoraHover = 0;
                List<int> costeT = mejoras.getCosteMejora(0);
                infoSeleccion.Clear();
                infoSeleccion.Add("Sistema de Sondeo General");
                infoSeleccion.Add(mejoras.getDescripcionMejora(mejoraHover));
                infoSeleccion.Add(costeT[0].ToString());	//Coste ener
                infoSeleccion.Add(costeT[1].ToString());	//Coste comp bas
                infoSeleccion.Add(costeT[2].ToString());	//comp adv
                infoSeleccion.Add(costeT[3].ToString());	//mat bio
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (!mejoras.mejorasCompradas[0] || mejoras.mejorasCompradas[1])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Deteccion de Ecosistemas"), "BotonMejoraHabitats")) {
                List<int> costeT = mejoras.getCosteMejora(1);
                if (!principal.recursosSuficientes(costeT[0], costeT[1], costeT[2], costeT[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                principal.consumeRecursos(costeT[0], costeT[1], costeT[2], costeT[3]);
                mejoras.compraMejora1 ();
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.mejoras;
                mejoraHover = 1;
                List<int> costeT = mejoras.getCosteMejora(1);
                infoSeleccion.Clear();
                infoSeleccion.Add("Deteccion de Ecosistemas");
                infoSeleccion.Add(mejoras.getDescripcionMejora(mejoraHover));
                infoSeleccion.Add(costeT[0].ToString());	//Coste ener
                infoSeleccion.Add(costeT[1].ToString());	//Coste comp bas
                infoSeleccion.Add(costeT[2].ToString());	//comp adv
                infoSeleccion.Add(costeT[3].ToString());	//mat bio
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (!mejoras.mejorasCompradas[0] || mejoras.mejorasCompradas[2])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Espectometro"), "BotonMejoraMetalesRaros")) {
                List<int> costeT = mejoras.getCosteMejora(2);
                if (!principal.recursosSuficientes(costeT[0], costeT[1], costeT[2], costeT[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                principal.consumeRecursos(costeT[0], costeT[1], costeT[2], costeT[3]);
                mejoras.compraMejora2 ();
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.mejoras;
                mejoraHover = 2;
                List<int> costeT = mejoras.getCosteMejora(2);
                infoSeleccion.Clear();
                infoSeleccion.Add("Espectometro");
                infoSeleccion.Add(mejoras.getDescripcionMejora(mejoraHover));
                infoSeleccion.Add(costeT[0].ToString());	//Coste ener
                infoSeleccion.Add(costeT[1].ToString());	//Coste comp bas
                infoSeleccion.Add(costeT[2].ToString());	//comp adv
                infoSeleccion.Add(costeT[3].ToString());	//mat bio
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (!mejoras.mejorasCompradas[0] || mejoras.mejorasCompradas[3])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Sensor Biometrico"), "BotonMejoraVida")) {
                List<int> costeT = mejoras.getCosteMejora(3);
                if (!principal.recursosSuficientes(costeT[0], costeT[1], costeT[2], costeT[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                principal.consumeRecursos(costeT[0], costeT[1], costeT[2], costeT[3]);
                mejoras.compraMejora3 ();
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.mejoras;
                mejoraHover = 3;
                List<int> costeT = mejoras.getCosteMejora(3);
                infoSeleccion.Clear();
                infoSeleccion.Add("Sensor Biometrico");
                infoSeleccion.Add(mejoras.getDescripcionMejora(mejoraHover));
                infoSeleccion.Add(costeT[0].ToString());	//Coste ener
                infoSeleccion.Add(costeT[1].ToString());	//Coste comp bas
                infoSeleccion.Add(costeT[2].ToString());	//comp adv
                infoSeleccion.Add(costeT[3].ToString());	//mat bio
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW * 6);
            //Motores ------------------------------------------------------
            //Se pueden añadir mas condiciones como el coste
            if (mejoras.mejorasCompradas[4])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Motores auxiliares Basicos"), "BotonMejoraMotor1")) {
                List<int> costeT = mejoras.getCosteMejora(4);
                if (!principal.recursosSuficientes(costeT[0], costeT[1], costeT[2], costeT[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                principal.consumeRecursos(costeT[0], costeT[1], costeT[2], costeT[3]);
                mejoras.compraMejora4 ();
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.mejoras;
                mejoraHover = 4;
                List<int> costeT = mejoras.getCosteMejora(4);
                infoSeleccion.Clear();
                infoSeleccion.Add("Motores auxiliares Basicos");
                infoSeleccion.Add(mejoras.getDescripcionMejora(mejoraHover));
                infoSeleccion.Add(costeT[0].ToString());	//Coste ener
                infoSeleccion.Add(costeT[1].ToString());	//Coste comp bas
                infoSeleccion.Add(costeT[2].ToString());	//comp adv
                infoSeleccion.Add(costeT[3].ToString());	//mat bio
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (!mejoras.mejorasCompradas[4] || mejoras.mejorasCompradas[5])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Motores Orbitales"), "BotonMejoraMotor2")) {
                List<int> costeT = mejoras.getCosteMejora(5);
                if (!principal.recursosSuficientes(costeT[0], costeT[1], costeT[2], costeT[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                principal.consumeRecursos(costeT[0], costeT[1], costeT[2], costeT[3]);
                mejoras.compraMejora5 ();
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.mejoras;
                mejoraHover = 5;
                List<int> costeT = mejoras.getCosteMejora(5);
                infoSeleccion.Clear();
                infoSeleccion.Add("Motores Orbitales");
                infoSeleccion.Add(mejoras.getDescripcionMejora(mejoraHover));
                infoSeleccion.Add(costeT[0].ToString());	//Coste ener
                infoSeleccion.Add(costeT[1].ToString());	//Coste comp bas
                infoSeleccion.Add(costeT[2].ToString());	//comp adv
                infoSeleccion.Add(costeT[3].ToString());	//mat bio
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (mejoras.mejorasCompradas[6])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Aislamiento magnético"), "BotonMejoraMotor3")) {
                List<int> costeT = mejoras.getCosteMejora(6);
                if (!principal.recursosSuficientes(costeT[0], costeT[1], costeT[2], costeT[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                principal.consumeRecursos(costeT[0], costeT[1], costeT[2], costeT[3]);
                mejoras.compraMejora6 ();
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.mejoras;
                mejoraHover = 6;
                List<int> costeT = mejoras.getCosteMejora(6);
                infoSeleccion.Clear();
                infoSeleccion.Add("Aislamiento magnético");
                infoSeleccion.Add(mejoras.getDescripcionMejora(mejoraHover));
                infoSeleccion.Add(costeT[0].ToString());	//Coste ener
                infoSeleccion.Add(costeT[1].ToString());	//Coste comp bas
                infoSeleccion.Add(costeT[2].ToString());	//comp adv
                infoSeleccion.Add(costeT[3].ToString());	//mat bio
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (mejoras.mejorasCompradas[7])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Subir la nave de órbita"), "BotonMejoraMotor4")) {
                List<int> costeT = mejoras.getCosteMejora(7);
                if (!principal.recursosSuficientes(costeT[0], costeT[1], costeT[2], costeT[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                principal.consumeRecursos(costeT[0], costeT[1], costeT[2], costeT[3]);
                mejoras.compraMejora7 ();
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.mejoras;
                mejoraHover = 7;
                List<int> costeT = mejoras.getCosteMejora(7);
                infoSeleccion.Clear();
                infoSeleccion.Add("Subir la nave de órbita");
                infoSeleccion.Add(mejoras.getDescripcionMejora(mejoraHover));
                infoSeleccion.Add(costeT[0].ToString());	//Coste ener
                infoSeleccion.Add(costeT[1].ToString());	//Coste comp bas
                infoSeleccion.Add(costeT[2].ToString());	//comp adv
                infoSeleccion.Add(costeT[3].ToString());	//mat bio
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW * 1.5f);
            GUILayout.EndHorizontal ();
            GUILayout.Space (cuantoH);
            GUILayout.BeginHorizontal (GUILayout.Height (cuantoH * 2));
            GUILayout.Space (cuantoW * 6.5f);
            //Energia ------------------------------------------------------
            if (mejoras.mejorasCompradas[8])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Condensador Auxiliar"), "BotonMejoraEnergia1")) {
                List<int> costeT = mejoras.getCosteMejora(8);
                if (!principal.recursosSuficientes(costeT[0], costeT[1], costeT[2], costeT[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                principal.consumeRecursos(costeT[0], costeT[1], costeT[2], costeT[3]);
                mejoras.compraMejora8 ();
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.mejoras;
                mejoraHover = 8;
                List<int> costeT = mejoras.getCosteMejora(8);
                infoSeleccion.Clear();
                infoSeleccion.Add("Condensador Auxiliar");
                infoSeleccion.Add(mejoras.getDescripcionMejora(mejoraHover));
                infoSeleccion.Add(costeT[0].ToString());	//Coste ener
                infoSeleccion.Add(costeT[1].ToString());	//Coste comp bas
                infoSeleccion.Add(costeT[2].ToString());	//comp adv
                infoSeleccion.Add(costeT[3].ToString());	//mat bio
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (mejoras.mejorasCompradas[9])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Acumulador de Energia en Anillo"), "BotonMejoraEnergia2")) {
                List<int> costeT = mejoras.getCosteMejora(9);
                if (!principal.recursosSuficientes(costeT[0], costeT[1], costeT[2], costeT[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                principal.consumeRecursos(costeT[0], costeT[1], costeT[2], costeT[3]);
                mejoras.compraMejora9 ();
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.mejoras;
                mejoraHover = 9;
                List<int> costeT = mejoras.getCosteMejora(9);
                infoSeleccion.Clear();
                infoSeleccion.Add("Acumulador de Energia en Anillo");
                infoSeleccion.Add(mejoras.getDescripcionMejora(mejoraHover));
                infoSeleccion.Add(costeT[0].ToString());	//Coste ener
                infoSeleccion.Add(costeT[1].ToString());	//Coste comp bas
                infoSeleccion.Add(costeT[2].ToString());	//comp adv
                infoSeleccion.Add(costeT[3].ToString());	//mat bio
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (!mejoras.mejorasCompradas[9] || mejoras.mejorasCompradas[10])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Array de Paneles Solares"), "BotonMejoraEnergia3")) {
                List<int> costeT = mejoras.getCosteMejora(10);
                if (!principal.recursosSuficientes(costeT[0], costeT[1], costeT[2], costeT[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                principal.consumeRecursos(costeT[0], costeT[1], costeT[2], costeT[3]);
                mejoras.compraMejora10 ();
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.mejoras;
                mejoraHover = 10;
                List<int> costeT = mejoras.getCosteMejora(10);
                infoSeleccion.Clear();
                infoSeleccion.Add("Array de Paneles Solares");
                infoSeleccion.Add(mejoras.getDescripcionMejora(mejoraHover));
                infoSeleccion.Add(costeT[0].ToString());	//Coste ener
                infoSeleccion.Add(costeT[1].ToString());	//Coste comp bas
                infoSeleccion.Add(costeT[2].ToString());	//comp adv
                infoSeleccion.Add(costeT[3].ToString());	//mat bio
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (!mejoras.mejorasCompradas[8] || !mejoras.mejorasCompradas[9] || !mejoras.mejorasCompradas[10] || mejoras.mejorasCompradas[11])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Generador de Fusión"), "BotonMejoraEnergia4")) {
                List<int> costeT = mejoras.getCosteMejora(11);
                if (!principal.recursosSuficientes(costeT[0], costeT[1], costeT[2], costeT[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                principal.consumeRecursos(costeT[0], costeT[1], costeT[2], costeT[3]);
                mejoras.compraMejora11 ();
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.mejoras;
                mejoraHover = 11;
                List<int> costeT = mejoras.getCosteMejora(11);
                infoSeleccion.Clear();
                infoSeleccion.Add("Generador de Fusión");
                infoSeleccion.Add(mejoras.getDescripcionMejora(mejoraHover));
                infoSeleccion.Add(costeT[0].ToString());	//Coste ener
                infoSeleccion.Add(costeT[1].ToString());	//Coste comp bas
                infoSeleccion.Add(costeT[2].ToString());	//comp adv
                infoSeleccion.Add(costeT[3].ToString());	//mat bio
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW * 6);
            //Almacenamiento -----------------------------------------------
            if (mejoras.mejorasCompradas[13] || etapaJuego < tEtapaJuego.fabCompBasConstruida)
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Tecnologia de Material Biologico"), "BotonMejoraAlmacen1")) {
                List<int> costeT = mejoras.getCosteMejora(13);
                if (!principal.recursosSuficientes(costeT[0], costeT[1], costeT[2], costeT[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                principal.consumeRecursos(costeT[0], costeT[1], costeT[2], costeT[3]);
                mejoras.compraMejora13 ();
                if (etapaJuego == tEtapaJuego.fabCompBasConstruida)
                    etapaJuego = tEtapaJuego.mejoraBiologicoComprada;
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.mejoras;
                mejoraHover = 13;
                List<int> costeT = mejoras.getCosteMejora(13);
                infoSeleccion.Clear();
                infoSeleccion.Add("Contenedor biologico");
                infoSeleccion.Add(mejoras.getDescripcionMejora(mejoraHover));
                infoSeleccion.Add(costeT[0].ToString());	//Coste ener
                infoSeleccion.Add(costeT[1].ToString());	//Coste comp bas
                infoSeleccion.Add(costeT[2].ToString());	//comp adv
                infoSeleccion.Add(costeT[3].ToString());	//mat bio
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (mejoras.mejorasCompradas[12] || !mejoras.mejorasCompradas[13])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Tecnologia de Componentes Avanzados"), "BotonMejoraAlmacen2")) {
                List<int> costeT = mejoras.getCosteMejora(12);
                if (!principal.recursosSuficientes(costeT[0], costeT[1], costeT[2], costeT[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                principal.consumeRecursos(costeT[0], costeT[1], costeT[2], costeT[3]);
                mejoras.compraMejora12 ();
                etapaJuego = tEtapaJuego.mejoraAvanzadosComprada;
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.mejoras;
                mejoraHover = 12;
                List<int> costeT = mejoras.getCosteMejora(12);
                infoSeleccion.Clear();
                infoSeleccion.Add("Contenedor avanzado");
                infoSeleccion.Add(mejoras.getDescripcionMejora(mejoraHover));
                infoSeleccion.Add(costeT[0].ToString());	//Coste ener
                infoSeleccion.Add(costeT[1].ToString());	//Coste comp bas
                infoSeleccion.Add(costeT[2].ToString());	//comp adv
                infoSeleccion.Add(costeT[3].ToString());	//mat bio
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (!mejoras.mejorasCompradas[12] || !mejoras.mejorasCompradas[13] || mejoras.mejorasCompradas[14])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Ampliacion de Carga 1"), "BotonMejoraAlmacen3")) {
                List<int> costeT = mejoras.getCosteMejora(14);
                if (!principal.recursosSuficientes(costeT[0], costeT[1], costeT[2], costeT[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                principal.consumeRecursos(costeT[0], costeT[1], costeT[2], costeT[3]);
                mejoras.compraMejora14 ();
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.mejoras;
                mejoraHover = 14;
                List<int> costeT = mejoras.getCosteMejora(14);
                infoSeleccion.Clear();
                infoSeleccion.Add("Ampliacion de Carga 1");
                infoSeleccion.Add(mejoras.getDescripcionMejora(mejoraHover));
                infoSeleccion.Add(costeT[0].ToString());	//Coste ener
                infoSeleccion.Add(costeT[1].ToString());	//Coste comp bas
                infoSeleccion.Add(costeT[2].ToString());	//comp adv
                infoSeleccion.Add(costeT[3].ToString());	//mat bio
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (!mejoras.mejorasCompradas[14] || mejoras.mejorasCompradas[15])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Ampliacion de Carga 2"), "BotonMejoraAlmacen4")) {
                List<int> costeT = mejoras.getCosteMejora(15);
                if (!principal.recursosSuficientes(costeT[0], costeT[1], costeT[2], costeT[3])) {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                    break;
                }
                principal.consumeRecursos(costeT[0], costeT[1], costeT[2], costeT[3]);
                mejoras.compraMejora15 ();
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.mejoras;
                mejoraHover = 15;
                List<int> costeT = mejoras.getCosteMejora(15);
                infoSeleccion.Clear();
                infoSeleccion.Add("Ampliacion de Carga 2");
                infoSeleccion.Add(mejoras.getDescripcionMejora(mejoraHover));
                infoSeleccion.Add(costeT[0].ToString());	//Coste ener
                infoSeleccion.Add(costeT[1].ToString());	//Coste comp bas
                infoSeleccion.Add(costeT[2].ToString());	//comp adv
                infoSeleccion.Add(costeT[3].ToString());	//mat bio
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW * 1.5f);
            GUILayout.EndHorizontal ();
            GUILayout.Space (cuantoH);
            GUILayout.EndVertical ();
            GUILayout.EndArea ();
            break;
        case taccion.seleccionarHabilidad:
            habilidadHover = -1;
            GUILayout.BeginArea (new Rect (cuantoW * 22, cuantoH * posicionBloque, cuantoW * 36, cuantoH * 4), new GUIContent (), "BloqueSeleccionHabilidades");
            GUILayout.BeginVertical ();
            GUILayout.Space (cuantoH);
            GUILayout.BeginHorizontal (GUILayout.Height (cuantoH * 2));
            GUILayout.Space (cuantoW * 1.5f);
            if (!mejoras.mejorasCompradas[1] && !mejoras.mejorasCompradas[2] && !mejoras.mejorasCompradas[3])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Desactiva todos los filtros"), "BotonHabilidadVisionNormal")) {
                for(int i = 0; i < togglesFiltros.Length; i++)
                    togglesFiltros[i] = false;

                materiales.habitats.SetFloat ("_FiltroOn", 0.0f);
                materiales.recursos.SetFloat ("_ComunesOn", 0.0f);
                materiales.recursos.SetFloat ("_RarosOn", 0.0f);
                materiales.recursos.SetFloat ("_EdificiosOn", 0.0f);

                for (int i = 0; i < materiales.plantas.Count; i++) {
                    materiales.plantas[i].SetFloat ("_FiltroOn", 0.0f);
                    materiales.plantas[i].SetColor ("_Tinte", Color.white);
                }
                for (int i = 0; i < materiales.herbivoros.Count; i++) {
                    materiales.herbivoros[i].SetFloat ("_FiltroOn", 0.0f);
                    materiales.herbivoros[i].SetColor ("_Tinte", Color.white);
                }

                for (int i = 0; i < materiales.carnivoros.Count; i++) {
                    materiales.carnivoros[i].SetFloat ("_FiltroOn", 0.0f);
                    materiales.carnivoros[i].SetColor ("_Tinte", Color.white);
                }

            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (!mejoras.mejorasCompradas[2])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Activa filtro de recursos"), "BotonHabilidadFiltroRecursos")) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.filtroRecursos;
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (!mejoras.mejorasCompradas[1])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Activa filtro de hábitats"), "BotonHabilidadFiltroHabitats")) {
                if (materiales.habitats.GetFloat ("_FiltroOn") == 0.0f)
                {
                    filtroHabitats = true;
                    materiales.habitats.SetFloat ("_FiltroOn", 1.0f);
                }
                else {
                    filtroHabitats = false;
                    materiales.habitats.SetFloat ("_FiltroOn", 0.0f);
                }
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (!mejoras.mejorasCompradas[3])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Activa filtro de vegetales"), "BotonHabilidadFiltroVegetales")) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.filtroVegetales;
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (!mejoras.mejorasCompradas[3])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Activa filtro de animales"), "BotonHabilidadFiltroAnimales")) {
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.filtroAnimales;
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW * 3);
            if (!mejoras.mejorasCompradas[8])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Activa el Foco Solar"), "BotonHabilidad6")) {
                if (Camera.main.light.enabled)
                {
                    habilidadFoco = false;
                    Camera.main.light.enabled = false;
                }
                else
                {
                    habilidadFoco = true;
                    Camera.main.light.enabled=true;
                }
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                habilidadHover = 0;
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.habilidades;
                infoSeleccion.Clear();
                infoSeleccion.Add("Foco Solar");
                infoSeleccion.Add(mejoras.getDescripcionHabilidad(habilidadHover));
                infoSeleccion.Add("10");	//Coste ener
                infoSeleccion.Add("0");	//Coste comp bas
                infoSeleccion.Add("0");	//comp adv
                infoSeleccion.Add("0");	//mat bio
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (!mejoras.mejorasCompradas[10] && !fertilizanteActivo)
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Activa el Fertilizante Ecoquímico"), "BotonHabilidad7")) {
                List<int> costes = mejoras.costeHab5;
                if (principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    accion = InterfazPrincipal.taccion.lanzarFertilizante;
                }
                else {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                }
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                habilidadHover = 1;
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.habilidades;
                List<int> costes = mejoras.costeHab5;
                infoSeleccion.Clear();
                infoSeleccion.Add("Fertilizante Ecoquimico");
                infoSeleccion.Add(mejoras.getDescripcionHabilidad(habilidadHover));
                infoSeleccion.Add(costes[0].ToString());	//Coste ener
                infoSeleccion.Add(costes[1].ToString());	//Coste comp bas
                infoSeleccion.Add(costes[2].ToString());	//comp adv
                infoSeleccion.Add(costes[3].ToString());	//mat bio
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (!mejoras.mejorasCompradas[10] && !virusActivo)
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Activa el Virus Selectivo Poblacional"), "BotonHabilidad8")) {
                List<int> costes = mejoras.costeHab7;
                if (principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    accion = InterfazPrincipal.taccion.lanzarVirus;
                }
                else {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                }
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                habilidadHover = 3;
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.habilidades;
                List<int> costes = mejoras.costeHab7;
                infoSeleccion.Clear();
                infoSeleccion.Add("Virus pandemico");
                infoSeleccion.Add(mejoras.getDescripcionHabilidad(habilidadHover));
                infoSeleccion.Add(costes[0].ToString());	//Coste ener
                infoSeleccion.Add(costes[1].ToString());	//Coste comp bas
                infoSeleccion.Add(costes[2].ToString());	//comp adv
                infoSeleccion.Add(costes[3].ToString());	//mat bio
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (!mejoras.mejorasCompradas[11])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Activa la Bomba de Implosión Controlada"), "BotonHabilidad9")) {
                List<int> costes = mejoras.costeHab6;
                if (principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    accion = InterfazPrincipal.taccion.lanzarBomba;
                }
                else {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                }
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                habilidadHover = 2;
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.habilidades;
                List<int> costes = mejoras.costeHab6;
                infoSeleccion.Clear();
                infoSeleccion.Add("Bomba de implosion");
                infoSeleccion.Add(mejoras.getDescripcionHabilidad(habilidadHover));
                infoSeleccion.Add(costes[0].ToString());	//Coste ener
                infoSeleccion.Add(costes[1].ToString());	//Coste comp bas
                infoSeleccion.Add(costes[2].ToString());	//comp adv
                infoSeleccion.Add(costes[3].ToString());	//mat bio
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW);
            if (!mejoras.mejorasCompradas[11])
                GUI.enabled = false;
            if (GUILayout.Button (new GUIContent ("", "Activa el Portal Espacio/temporal (finaliza la partida)"), "BotonHabilidad10")) {
                List<int> costes = mejoras.costeHab8;
                if (principal.recursosSuficientes(costes[0], costes[1], costes[2], costes[3])) {
                    accion = InterfazPrincipal.taccion.insertarPortal;
                    modeloInsercion = GameObject.FindGameObjectWithTag("ModelosEdificios").GetComponent<ModelosEdificios>().portal;
                    modeloInsercion = FuncTablero.creaMesh (new Vector3 (0, 0, 0), modeloInsercion);
                }
                else {
                    sonidoFX.GetComponent<Audio_SoundFX>().playNumber(2);
                }
            }
            if (Event.current.type == EventType.Repaint && GUILayoutUtility.GetLastRect ().Contains (Event.current.mousePosition)) {
                habilidadHover = 4;
                tipoMenuDerecho = InterfazPrincipal.tMenuDerecho.habilidades;
                List<int> costes = mejoras.costeHab8;
                infoSeleccion.Clear();
                infoSeleccion.Add("Portal espacio-temporal");
                infoSeleccion.Add(mejoras.getDescripcionHabilidad(habilidadHover));
                infoSeleccion.Add(costes[0].ToString());	//Coste ener
                infoSeleccion.Add(costes[1].ToString());	//Coste comp bas
                infoSeleccion.Add(costes[2].ToString());	//comp adv
                infoSeleccion.Add(costes[3].ToString());	//mat bio
            }
            GUI.enabled = true;
            GUILayout.Space (cuantoW * 1.5f);
            GUILayout.EndHorizontal ();
            GUILayout.Space (cuantoH);
            GUILayout.EndVertical ();
            GUILayout.EndArea ();
            break;
        default:
            break;
        }
    }