public void cleanThreatToggles()
 {
     Threat1.GetComponentInChildren <Toggle>().isOn = false;
     Threat2.GetComponentInChildren <Toggle>().isOn = false;
     Threat3.GetComponentInChildren <Toggle>().isOn = false;
     Threat4.GetComponentInChildren <Toggle>().isOn = false;
 }
    /////////////////////////////////////////////////////////
    //               THE THREAT TEXT
    //                THREATS  PANEL
    //  Prepare an array with the threats selected to show
    //
    /////////////////////////////////////////////////////////
    public void TheThreatText()

    {
        string        conn1 = "URI=file:" + Application.dataPath + "/plugins/insector.db";
        IDbConnection dbconn1;

        dbconn1 = (IDbConnection) new SqliteConnection(conn1);
        dbconn1.Open();
        int i, q;

        for (i = (RandThreatNumer - 1), q = 0; i < (RandThreatNumer + 2) && q < 3; i++, q++)
        {
            IDbCommand dbcmd1 = dbconn1.CreateCommand();
            //string sqlQuery1 = "SELECT  THREAT_TXT ," + nameDevice + " from THREATS  where THREAT_ID = " + i;
            string sqlQuery1 = "SELECT  THREAT_TXT ," + nameDevice + " from THREATS  where THREAT_ID = " + i + " and SCENERY_ID =" + sceneryNumber;
            dbcmd1.CommandText = sqlQuery1;
            IDataReader reader1 = dbcmd1.ExecuteReader();

            while (reader1.Read())
            {
                threatDataA.threats[q] = new ThreatData {
                    threatText = (reader1.GetString(0)), ofThreat = (reader1.GetInt32(1))
                };
                tDisplayText[q].text = threatDataA.threats[q].threatText;
            }
            Threat4.GetComponentInChildren <Text>().text = "Nothing to do with this device";
            reader1.Close();
            reader1 = null;

            dbcmd1.Dispose();
            dbcmd1 = null;
        }
        dbconn1.Close();
        dbconn1 = null;
    }
    /////////////////////////////////////////////////////////
    //                  SHOW THREATS
    //                  THREATS PANEL
    //  Get the pannel ready and show the list of threats
    //
    /////////////////////////////////////////////////////////
    public void ShowThreats()
    {
        Threat1.GetComponentInChildren <Toggle>().isOn = false;
        Threat2.GetComponentInChildren <Toggle>().isOn = false;
        Threat3.GetComponentInChildren <Toggle>().isOn = false;
        Threat4.GetComponentInChildren <Toggle>().isOn = false;


        randThreatNumber();
        TheThreatText();
    }
    /////////////////////////////////////////////////////////
    //            THE CORRECTIONS TEXT
    //              CORRECTIONS PANEL
    //  Selection of different options of corections to the proposed threat
    //  and get ready the threats and corrections panels
    //
    /////////////////////////////////////////////////////////

    public void TheCorrectionsText()
    //Se sacan da la base de datos Tabla THREAT_SOLUTION las correcciones de las amenazas
    //Para probar sacamos tres amenazas a lo bruto sin tener en cuenta la amenaza ni el dispositvo ni el nivel del juego
    //Primero pongo en blando las etiquetas y los toggles que o son la amenaza en cuestion
    //Selecciono de la base de datos tres correciones y compruebo si son correctas para la amenaza
    //Cuento las correctas o un punto si ninguna
    //Vuelvo a llamar a show threats
    {
        //se obtiene el id de la selected threat

        string        conn1 = "URI=file:" + Application.dataPath + "/plugins/insector.db";
        IDbConnection dbconn1;

        dbconn1 = (IDbConnection) new SqliteConnection(conn1);
        dbconn1.Open();
        IDbCommand dbcmd1 = dbconn1.CreateCommand();

        string sqlQuery1 = "SELECT THREAT_ID  from THREATS where THREAT_TXT = '" + selectedThreat + "';";

        dbcmd1.CommandText = sqlQuery1;
        IDataReader reader1 = dbcmd1.ExecuteReader();

        while (reader1.Read())
        {
            selectedThreatId = (reader1.GetInt32(0));
        }

        //Es asi porque voy a sacar la amenaza que sale del numero aleatorio, la siguiente y la anterior (siempre tendre disponible la primera y la ultima)

        RandThreatNumer = UnityEngine.Random.Range(2, threatCount - 1);
        Debug.Log("el valor de RandThreatNumber es...." + RandThreatNumer);
        reader1.Close();
        reader1 = null;
        dbcmd1.Dispose();
        dbcmd1 = null;
        dbconn1.Close();
        dbconn1 = null;

        //Con el valor de la selectedThreat ya se pueden hacer las busquedas de las correcciones aleatoriamente

        hideGameInstructionsPanel();

        Threat4.GetComponentInChildren <Text>().text   = "";
        Threat4.GetComponentInChildren <Toggle>().isOn = false;

        if (Threat1.GetComponentInChildren <Text>().text != selectedThreat)
        {
            Threat1.GetComponentInChildren <Text>().text   = "";
            Threat1.GetComponentInChildren <Toggle>().isOn = false;
        }
        if (Threat2.GetComponentInChildren <Text>().text != selectedThreat)
        {
            Threat2.GetComponentInChildren <Toggle>().isOn = false;
            Threat2.GetComponentInChildren <Text>().text   = "";
        }
        if (Threat3.GetComponentInChildren <Text>().text != selectedThreat)
        {
            Threat3.GetComponentInChildren <Toggle>().isOn = false;
            Threat3.GetComponentInChildren <Text>().text   = "";
        }

        string        conn = "URI=file:" + Application.dataPath + "/plugins/insector.db";
        IDbConnection dbconn;

        dbconn = (IDbConnection) new SqliteConnection(conn);
        dbconn.Open();
        int t;

        for (t = 0; t < 3; t++)
        {
            IDbCommand dbcmd = dbconn.CreateCommand();
            //select de tres correciones. El numero de correctas será aleatorio. Se hara con dos select
            //una para las aleatorias correctas y otra para las aleatorias incorrectas ( A las correctas
            //les pondremos isCorrect a 1. La posicion con las que se presentarán en la pantalla será tambien aleatoria

            //string sqlQuery = "SELECT THREAT_SOLUTION_TXT, THREAT_CORRECTION_ID, VALID_FOR_THREAT FROM THREAT_SOLUTION where ROUTER = 1 and THREAT_CORRECTION_LEVEL = 1 AND instr ( VALID_FOR_THREAT, '1-')  ORDER BY random() LIMIT 1;";
            //Primero se prueba si seleccionar la correccion

            //string sqlQuery = "SELECT THREAT_SOLUTION_TXT, THREAT_CORRECTION_ID, VALID_FOR_THREAT FROM THREAT_SOLUTION where " +nameDevice +"= 1 and THREAT_CORRECTION_LEVEL = 1  ORDER BY random() LIMIT 1;";
            string sqlQuery = "SELECT THREAT_SOLUTION_TXT, THREAT_CORRECTION_ID, VALID_FOR_THREAT FROM THREAT_SOLUTION where THREAT_CORRECTION_LEVEL = " + playerLevel + "  ORDER BY random() LIMIT 1;";
            dbcmd.CommandText = sqlQuery;
            IDataReader reader = dbcmd.ExecuteReader();

            while (reader.Read())
            {
                validForThreats = (reader.GetString(2));

                if (validForThreats.Contains(selectedThreatId + "-"))
                {
                    tCorrectionDataA.corrections[t] = new TCorrectionData {
                        threatCorrectionText = (reader.GetString(0)), isCorrect = 1
                    };
                }
                else
                {
                    tCorrectionDataA.corrections[t] = new TCorrectionData {
                        threatCorrectionText = (reader.GetString(0)), isCorrect = 0
                    };
                }

                tCorrectionDisplayText[t].text = tCorrectionDataA.corrections[t].threatCorrectionText;
            }
            reader.Close();
            reader = null;

            dbcmd.Dispose();
            dbcmd = null;
        }
        dbconn.Close();
        dbconn = null;
    }