Example #1
0
    void OnGUI()
    {
        centeredStyle           = GUI.skin.GetStyle("Label");
        centeredStyle.alignment = TextAnchor.UpperCenter;

        // are you a patient or therapist
        if (window_ID == 1)
        {
            loginRect = GUILayout.Window(window_ID, new Rect(Screen.width / 2 - 110, Screen.height / 2 - 150, 220, 180), DoMyWindow, "");
        }

        // patient login
        if (window_ID == 2)
        {
            patientRect = GUILayout.Window(window_ID, new Rect(Screen.width / 2 - 150, Screen.height / 2 - 150, 300, 200), DoMyWindow, "");
        }

        // therapist login
        if (window_ID == 3)
        {
            therapistRect = GUILayout.Window(window_ID, new Rect(Screen.width / 2 - 150, Screen.height / 2 - 150, 300, 200), DoMyWindow, "");
        }

        // New user - Patient or Therapist?
        if (window_ID == 4)
        {
            newUserRect = GUILayout.Window(window_ID, new Rect(Screen.width / 2 - 110, Screen.height / 2 - 150, 220, 200), DoMyWindow, "");
        }

        // new patient sign-up
        if (window_ID == 5)
        {
            newPatientRect = GUILayout.Window(window_ID, new Rect(Screen.width / 2 - 235, Screen.height / 2 - 200, 460, 340), DoMyWindow, "");
        }

        // new therapist sign-up
        if (window_ID == 6)
        {
            newTherapistRect = GUILayout.Window(window_ID, new Rect(Screen.width / 2 - 200, Screen.height / 2 - 150, 400, 200), DoMyWindow, "");
        }

        if (GUI.Button(new Rect(Screen.width - 220, 20, newUser.width, newUser.height), newUser))
        {
            window_ID = 4;
        }

        if (GUI.Button(new Rect(20, Screen.height - 80, exit.width, exit.height), exit))
        {
            db.CloseDB();
            Application.LoadLevel("TitleScreen");
        }
    }
Example #2
0
    // Use this for initialization
    void Start()
    {
        dbAccess db = GetComponent <dbAccess>();

        db.OpenDB("game.db");
        count = db.getCount("loadCount", "id", "count");
        db.CloseDB();



        last = count + 5;
        db.updatetData("loadCount", "count", last);
        db.CloseDB();
    }
Example #3
0
    public ArrayList ReadDBDataFromRound(int ID)
    {
        Debug.Log("Reading Data by round_id");

        ArrayList balls = new ArrayList();
        dbAccess  db    = GetComponent <dbAccess>();

        db.OpenDB("VBBS.db");

        // SELECT * FROM ball where match_id = 1
        // "ID, time, start_X, start_Y, end_X, end_Y, attacker, team_player, enemy_player, skill, good, score, score_reason, team_change, team_switch, team_position, team_score, enemy_score, enemy_change, enemy_switch, enemy_position, match_ID"
        IDataReader reader = db.BasicQuery("SELECT attacker, team_player, enemy_player,	skill, good, score,	score_reason FROM balls where round_ID =" + ID);

        string path = "Assets/Resources/test.txt";

        // Write some text to the test.txt file
        System.IO.StreamWriter writer = new System.IO.StreamWriter(path, true);

        while (reader.Read())
        {
            Ball b = new Ball(reader.GetInt32(0), reader.GetInt32(1), reader.GetInt32(2), reader.GetInt32(3), reader.GetInt32(4), reader.GetInt32(5), reader.GetInt32(6));

            string l = "attacker: " + b.attacker + " ,teamplayer: " + b.team_player + ",enemyplayer: " + b.enemy_player + ",skill: " + b.skill + ",good: " + b.good + ",score: " + b.score + ",reason: " + b.score_reason;

            writer.WriteLine(l);

            balls.Add(b);
        }
        writer.Close();
        db.CloseDB();
        Debug.Log("Total Ball Count: " + balls.Count);
        return(balls);
    }
Example #4
0
    // Use this for initialization
    void Start()
    {
        resultado.text = " ";
        // Retrieve next word from database
        description = "something went wrong with the database";

        db = GetComponent <dbAccess>();

        if (!System.IO.File.Exists(Application.persistentDataPath + "/" + "InGame.db"))
        {
            db.OpenDB("InGame.db");
        }
        else
        {
            db.OpenDB("InGame.db");
        }

        //reader = db.BasicQuery("drop table if exists users");
        reader = db.BasicQuery("SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'users';");


        string[] col     = { "kp", "nombre", "pw" };
        string[] colType = { "integer primary key autoincrement", "text", "text" };

        if (!db.CreateTable("users", col, colType))
        {
            Debug.Log("Error creating table");
        }

        db.CloseDB();
    }
Example #5
0
 void OnDestroy()
 {
     if (db != null)
     {
         db.CloseDB();
     }
 }
    void newQuestion()
    {
        answerResultWindow.SetActive(false);

        Question q = new Question();

        if (Application.platform == RuntimePlatform.WebGLPlayer)
        {
            FetchQuestion();
            q.QuestionText   = node.ChildNodes[1].InnerText;
            q.CorrectAnswer  = node.ChildNodes[2].InnerText;
            q.WrongAnswer1   = node.ChildNodes[3].InnerText;
            q.WrongAnswer2   = node.ChildNodes[4].InnerText;
            q.WrongAnswer3   = node.ChildNodes[5].InnerText;
            q.SubmissionName = node.ChildNodes[6].InnerText;
            q.Passage        = node.ChildNodes[7].InnerText;
        }
        else
        {
            dbAccess db = GetComponent <dbAccess>();

            db.OpenDB("Questions.db");

            ArrayList result = db.RandomSelect("QUESTIONS", "*");

            string[] s = ((string[])result[0]);
            q.QuestionText   = s[1];
            q.CorrectAnswer  = s[2];
            q.WrongAnswer1   = s[3];
            q.WrongAnswer2   = s[4];
            q.WrongAnswer3   = s[5];
            q.SubmissionName = s[6];
            q.Passage        = s[7];

            db.CloseDB();
        }

        question = q;
        questionObj.GetComponent <Text>().text = question.QuestionText;
        List <string> answerList = new List <string>();

        answerList.Add(question.CorrectAnswer);
        answerList.Add(question.WrongAnswer1);
        answerList.Add(question.WrongAnswer2);
        answerList.Add(question.WrongAnswer3);
        Shuffle(answerList);
        setupAnswerButton(button1Text, button1, answerList[0], question.CorrectAnswer);
        setupAnswerButton(button2Text, button2, answerList[1], question.CorrectAnswer);
        setupAnswerButton(button3Text, button3, answerList[2], question.CorrectAnswer);
        setupAnswerButton(button4Text, button4, answerList[3], question.CorrectAnswer);
        if (question.SubmissionName != null && question.SubmissionName != "")
        {
            submissionName.GetComponent <Text>().text = question.SubmissionName;
        }
        else
        {
            submissionName.GetComponent <Text>().text = "Anonymous";
        }
    }
 // This function will insert our calibration data points as a row in the calibration database table
 void SaveData()
 {
     // Instantiate instance of db access controller and open up our database
     db_control = new dbAccess ();
     db_control.OpenDB ();
     db_control.InsertInto(right_calibration_table, rightCalibrationPoints);
     db_control.InsertInto(left_calibration_table, leftCalibrationPoints);
     db_control.CloseDB ();
 }
Example #8
0
    public void DeleteMatch()
    {
        dbAccess db = GetComponent <dbAccess>();

        db.OpenDB("VBBS.db");

        IDataReader reader = db.BasicQuery("DELETE from matches WHERE ID = " + match_id);

        db.CloseDB();
    }
Example #9
0
    public void SetRoundScore(int teamScore, int enemyScore)
    {
        Debug.Log("Round has ended");

        dbAccess db = GetComponent <dbAccess>();

        db.OpenDB("VBBS.db");

        db.BasicQuery("UPDATE rounds SET team_score = " + teamScore + ", enemy_score = " + enemyScore + " WHERE round_id = " + round_id);
        db.CloseDB();
    }
Example #10
0
    public void create()
    {
        db.OpenDB("InGame.db");
        int n = db.CheckValue("users", "pw", "nombre", "=", "'" + ncreate.text + "'");

        //para evitar repetir un usuario
        if (n > 0)
        {
            db.OpenDB("InGame.db");
            string[] inscol      = { "nombre", "pw" };
            string[] inscolvalue = { "'" + ncreate.text + "'", "'" + pwcreate.text + "'" };

            db.InsertIntoSpecific("users", inscol, inscolvalue);
            db.CloseDB();
            resultado.text = "usuario creado";
        }
        else
        {
            resultado.text = "usuario ya existe";
        }
    }
Example #11
0
    public void InsertNewMatch(string date, string time, string location, string name, string team, string enemy, int matchStyle, int ruleStyle)
    {
        dbAccess db = GetComponent <dbAccess>();

        db.OpenDB("VBBS.db");

        string attr   = "date, time, location, name, team, enemy, matchStyle, ruleStyle";
        string values = "'" + date + "','" + time + "','" + location + "','" + name + "','" + team + "','" + enemy + "'," + matchStyle + "," + ruleStyle;

        db.BasicQuery("INSERT INTO matches (" + attr + ") values (" + values + ")");
        IDataReader reader = db.BasicQuery("SELECT last_insert_rowid();");

        if (reader.Read())
        {
            match_id = reader.GetInt32(0);
        }
        db.CloseDB();
    }
Example #12
0
    public void InsertNewRound()
    {
        dbAccess db = GetComponent <dbAccess>();

        db.OpenDB("VBBS.db");

        string attr   = "team_score, enemy_score, match_ID";
        string values = "0,0," + match_id;

        db.BasicQuery("INSERT INTO rounds (" + attr + ") values (" + values + ")");
        IDataReader reader = db.BasicQuery("SELECT last_insert_rowid();");

        if (reader.Read())
        {
            round_id = reader.GetInt32(0);
        }
        db.CloseDB();
    }
Example #13
0
    public ArrayList GetAllRound()
    {
        dbAccess db = GetComponent <dbAccess>();

        db.OpenDB("VBBS.db");

        IDataReader reader = db.BasicQuery("Select * from rounds");

        ArrayList rounds = new ArrayList();

        while (reader.Read())
        {
            int id = reader.GetInt32(0);
            rounds.Add(id);
        }
        db.CloseDB();
        return(rounds);
    }
Example #14
0
    public ArrayList GetAllMatch()
    {
        dbAccess db = GetComponent <dbAccess>();

        db.OpenDB("VBBS.db");

        IDataReader reader = db.BasicQuery("Select * from matches");

        ArrayList matches = new ArrayList();

        while (reader.Read())
        {
            Match match = new Match(reader.GetInt32(0), reader.GetString(1), reader.GetString(4), reader.GetString(5), reader.GetString(6));
            matches.Add(match);
        }

        db.CloseDB();
        return(matches);
    }
Example #15
0
    public bool RemoveLastBall()
    {
        if (last_ball_id == -1)
        {
            return(false);
        }

        dbAccess db = GetComponent <dbAccess>();

        db.OpenDB("VBBS.db");

        IDataReader reader = db.BasicQuery("SELECT score FROM balls WHERE ID = " + last_ball_id);
        int         score  = 0;

        while (reader.Read())
        {
            score = reader.GetInt32(0);
        }

        if (score == 1)
        {
            model.team_score--;
            Text txt = scoreA.GetComponent <Text>();
            txt.text = model.team_score.ToString();
        }
        else if (score == 2)
        {
            model.enemy_score--;
            Text txt = scoreB.GetComponent <Text>();
            txt.text = model.enemy_score.ToString();
        }

        try
        {
            db.BasicQuery("DELETE FROM balls WHERE ID = " + last_ball_id);
        }
        catch (System.Exception e) {
            Debug.Log(e);
            return(false);
        }
        db.CloseDB();
        return(true);
    }
Example #16
0
    // Use this for initialization
    void Start()
    {
        Debug.Log("starting SQLiteLoad app");

        // Retrieve next word from database
        description = "something went wrong with the database";

        dbAccess db = GetComponent <dbAccess>();

        db.OpenDB("English.db");

        ArrayList result = db.SingleSelectWhere("petdef", "*", "word", "=", "'bag'");

        if (result.Count > 0)
        {
            description = ((string[])result[0])[2];
        }

        db.CloseDB();
    }
Example #17
0
    public void InsertNewBall()
    {
        Debug.Log("Start Inserting Ball");

        dbAccess db = GetComponent <dbAccess>();

        db.OpenDB("VBBS.db");

        string ball_attr = "time, start_X, start_Y, end_X, end_Y, attacker, team_player, enemy_player, skill, good, score, score_reason, team_change, team_switch, team_position, team_score, enemy_score, enemy_change, enemy_switch, enemy_position, round_ID";

        db.InsertIntoSingle("balls", ball_attr, model.encode() + round_id);

        IDataReader reader = db.BasicQuery("SELECT last_insert_rowid();");

        if (reader.Read())
        {
            last_ball_id = reader.GetInt32(0);
        }

        db.CloseDB();
    }
Example #18
0
    public void finishSession()
    {
        ID = 0;

        db = new dbAccess();
        db.OpenDB(dbName);

        // If not accidental login
        if (sessionTime > 0)
        {
            TimeSpan duration = TimeSpan.FromSeconds((int)sessionTime);
            db.UpdateSpecific(patientTable, "SessionLength", sessionTime.ToString(), "SessionID", sessionNum);
            db.UpdateSpecific(patientTable, "NumOfPlays", numPlays.ToString(), "SessionID", sessionNum);
        }
        // If accidental login, delete the row made for this session
        else
        {
            db.DeleteRow(patientTable, "SessionID", sessionNum);
        }

        db.CloseDB();
    }
Example #19
0
    public void finishSession()
    {
        ID = 0;

        db = new dbAccess();
        db.OpenDB(dbName);

        // If not accidental login
        if(sessionTime > 0)
        {
            TimeSpan duration = TimeSpan.FromSeconds((int)sessionTime);
            db.UpdateSpecific(patientTable, "SessionLength", sessionTime.ToString(), "SessionID", sessionNum);
            db.UpdateSpecific(patientTable, "NumOfPlays", numPlays.ToString(), "SessionID", sessionNum);
        }
        // If accidental login, delete the row made for this session
        else
        {
            db.DeleteRow(patientTable, "SessionID", sessionNum);
        }

        db.CloseDB();
    }
Example #20
0
    public void newStats(float timePlayed, string bbsActivity, int bbsGrade)
    {
        numPlays++;
        if (numPlays <= 100)
        {
            db = new dbAccess();
            db.OpenDB(dbName);

            // Get Play Duration
            string   playColumn = "Play" + numPlays.ToString();
            TimeSpan duration   = TimeSpan.FromSeconds((int)timePlayed);

            // Store values into DB
            string playString = duration.ToString() + "|" + bbsActivity + "|" + bbsGrade.ToString();
            db.UpdateSpecific(patientTable, playColumn, playString, "SessionID", sessionNum);

            // Update session stats
            sessionTime += timePlayed;

            db.CloseDB();
        }
    }
Example #21
0
    public ArrayList ReadDBData()
    {
        ArrayList balls = new ArrayList();

        Debug.Log("Start Reading Data");

        dbAccess db = GetComponent <dbAccess>();

        db.OpenDB("VBBS.db");

        IDataReader reader = db.BasicQuery("SELECT attacker, team_player, enemy_player,	skill, good, score,	score_reason FROM balls");

        while (reader.Read())
        {
            Ball b = new Ball(reader.GetInt32(0), reader.GetInt32(1), reader.GetInt32(2), reader.GetInt32(3), reader.GetInt32(4), reader.GetInt32(5), reader.GetInt32(6));
            balls.Add(b);
        }

        db.CloseDB();
        Debug.Log("Total Ball Count: " + balls.Count);

        return(balls);
    }
Example #22
0
    public void CheckCorrect(string exhibit)
    {
        if (Answer1.isOn == true)
        {
            Debug.Log("Answer 1 was chosen");
            Debug.Log(exhibit);
            //Debug.Log(Answer1.GetComponentInChildren<Text>().text);

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                Debug.Log("Entered Windows");
                string        conn = "URI=file:" + Application.dataPath + "/StreamingAssets/museumDatabase.db";                   //Path to database.
                IDbConnection dbconn;
                dbconn = (IDbConnection) new SqliteConnection(conn);
                dbconn.Open();                          //Open connection to the database.
                IDbCommand dbcmd = dbconn.CreateCommand();


                sqlQuery = "SELECT * FROM exhibit WHERE exhibitID = " + "'" + exhibit + "'";



                dbcmd.CommandText = sqlQuery;
                IDataReader reader = dbcmd.ExecuteReader();
                while (reader.Read())
                {
                    quizSqlAnswer = reader.GetString(6);
                }


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

            if (Application.platform == RuntimePlatform.Android)
            {
                dbAccess db = GetComponent <dbAccess>();


                db.OpenDB("museumDatabase.db");

                //ArrayList result = db.SingleSelectWhere("exhibit", "*", "exhibitID", "=", "'ExhibitB'");


                if (PlayerPrefs.GetString("language") == "UnitedKingdom")
                {
                    result = db.SingleSelectWhere("exhibit", "*", "exhibitID", "=", "'" + exhibit + "'");
                }


                if (result.Count > 0)
                {
                    quizSqlAnswer = "";
                    foreach (string[] s in result)
                    {
                        for (int x = 0; x < s.Length; x++)
                        {
                            //description += "\n" + s[x];
                        }
                        quizSqlAnswer = s[6];
                    }
                }



                db.CloseDB();
            }


            Debug.Log("SQL Result is " + quizSqlAnswer);
            if (quizSqlAnswer == Answer1.GetComponentInChildren <Text>().text)
            {
                Debug.Log("Compared with SQL. Answer 1 Correct");
                Debug.Log(exhibit + "Quiz");
                PlayerPrefs.SetString(exhibit + "Quiz", "Correct");
                ResultImage.texture = (Texture)CorrectSign;
                ResultImageHolder.SetActive(true);
            }
            else
            {
                Debug.Log("Compared with SQL. Answer 1 Incorrect");
                PlayerPrefs.SetString(exhibit + "Quiz", "Incorrect");
                ResultImage.texture = (Texture)IncorrectSign;
                ResultImageHolder.SetActive(true);
            }

            StartCoroutine(MyMethod());
        }

        if (Answer2.isOn == true)
        {
            Debug.Log("Answer 2 was chosen");
            Debug.Log(exhibit);

            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                Debug.Log("Entered Windows");
                string        conn = "URI=file:" + Application.dataPath + "/StreamingAssets/museumDatabase.db";                   //Path to database.
                IDbConnection dbconn;
                dbconn = (IDbConnection) new SqliteConnection(conn);
                dbconn.Open();                          //Open connection to the database.
                IDbCommand dbcmd = dbconn.CreateCommand();


                sqlQuery = "SELECT * FROM exhibit WHERE exhibitID = " + "'" + exhibit + "'";



                dbcmd.CommandText = sqlQuery;
                IDataReader reader = dbcmd.ExecuteReader();
                while (reader.Read())
                {
                    quizSqlAnswer = reader.GetString(6);
                }


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

            if (Application.platform == RuntimePlatform.Android)
            {
                dbAccess db = GetComponent <dbAccess>();


                db.OpenDB("museumDatabase.db");

                //ArrayList result = db.SingleSelectWhere("exhibit", "*", "exhibitID", "=", "'ExhibitB'");


                if (PlayerPrefs.GetString("language") == "UnitedKingdom")
                {
                    result = db.SingleSelectWhere("exhibit", "*", "exhibitID", "=", "'" + exhibit + "'");
                }


                if (result.Count > 0)
                {
                    quizSqlAnswer = "";
                    foreach (string[] s in result)
                    {
                        for (int x = 0; x < s.Length; x++)
                        {
                            //description += "\n" + s[x];
                        }
                        quizSqlAnswer = s[6];
                    }
                }



                db.CloseDB();
            }


            Debug.Log("SQL Result is " + quizSqlAnswer);

            if (quizSqlAnswer == Answer2.GetComponentInChildren <Text>().text)
            {
                Debug.Log("Compared with SQL. Answer 2 Correct");
                PlayerPrefs.SetString(exhibit + "Quiz", "Correct");
                ResultImage.texture = (Texture)CorrectSign;
                ResultImageHolder.SetActive(true);
            }
            else
            {
                Debug.Log("Compared with SQL. Answer 2 Incorrect");
                PlayerPrefs.SetString(exhibit + "Quiz", "Incorrect");
                ResultImage.texture = (Texture)IncorrectSign;
                ResultImageHolder.SetActive(true);
            }

            StartCoroutine(MyMethod());
        }



        if (Answer3.isOn == true)
        {
            Debug.Log("Answer 3 was chosen");
            Debug.Log(exhibit);


            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                Debug.Log("Entered Windows");
                string        conn = "URI=file:" + Application.dataPath + "/StreamingAssets/museumDatabase.db";                   //Path to database.
                IDbConnection dbconn;
                dbconn = (IDbConnection) new SqliteConnection(conn);
                dbconn.Open();                          //Open connection to the database.
                IDbCommand dbcmd = dbconn.CreateCommand();


                sqlQuery = "SELECT * FROM exhibit WHERE exhibitID = " + "'" + exhibit + "'";



                dbcmd.CommandText = sqlQuery;
                IDataReader reader = dbcmd.ExecuteReader();
                while (reader.Read())
                {
                    quizSqlAnswer = reader.GetString(6);
                }


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

            if (Application.platform == RuntimePlatform.Android)
            {
                dbAccess db = GetComponent <dbAccess>();


                db.OpenDB("museumDatabase.db");

                //ArrayList result = db.SingleSelectWhere("exhibit", "*", "exhibitID", "=", "'ExhibitB'");


                if (PlayerPrefs.GetString("language") == "UnitedKingdom")
                {
                    result = db.SingleSelectWhere("exhibit", "*", "exhibitID", "=", "'" + exhibit + "'");
                }


                if (result.Count > 0)
                {
                    quizSqlAnswer = "";
                    foreach (string[] s in result)
                    {
                        for (int x = 0; x < s.Length; x++)
                        {
                            //description += "\n" + s[x];
                        }
                        quizSqlAnswer = s[6];
                    }
                }



                db.CloseDB();
            }



            Debug.Log("SQL Result is " + quizSqlAnswer);
            if (quizSqlAnswer == Answer3.GetComponentInChildren <Text>().text)
            {
                Debug.Log("Compared with SQL. Answer 3 Correct");
                PlayerPrefs.SetString(exhibit + "Quiz", "Correct");
                ResultImage.texture = (Texture)CorrectSign;
                ResultImageHolder.SetActive(true);
            }
            else
            {
                Debug.Log("Compared with SQL. Answer 4 Incorrect");
                PlayerPrefs.SetString(exhibit + "Quiz", "Incorrect");
                ResultImage.texture = (Texture)IncorrectSign;
                ResultImageHolder.SetActive(true);
            }

            StartCoroutine(MyMethod());
        }


        if (Answer4.isOn == true)
        {
            Debug.Log("Answer 4 was chosen");
            Debug.Log(exhibit);


            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                Debug.Log("Entered Windows");
                string        conn = "URI=file:" + Application.dataPath + "/StreamingAssets/museumDatabase.db";                   //Path to database.
                IDbConnection dbconn;
                dbconn = (IDbConnection) new SqliteConnection(conn);
                dbconn.Open();                          //Open connection to the database.
                IDbCommand dbcmd = dbconn.CreateCommand();


                sqlQuery = "SELECT * FROM exhibit WHERE exhibitID = " + "'" + exhibit + "'";



                dbcmd.CommandText = sqlQuery;
                IDataReader reader = dbcmd.ExecuteReader();
                while (reader.Read())
                {
                    quizSqlAnswer = reader.GetString(6);
                }


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

            if (Application.platform == RuntimePlatform.Android)
            {
                dbAccess db = GetComponent <dbAccess>();


                db.OpenDB("museumDatabase.db");

                //ArrayList result = db.SingleSelectWhere("exhibit", "*", "exhibitID", "=", "'ExhibitB'");


                if (PlayerPrefs.GetString("language") == "UnitedKingdom")
                {
                    result = db.SingleSelectWhere("exhibit", "*", "exhibitID", "=", "'" + exhibit + "'");
                }


                if (result.Count > 0)
                {
                    quizSqlAnswer = "";
                    foreach (string[] s in result)
                    {
                        for (int x = 0; x < s.Length; x++)
                        {
                            //description += "\n" + s[x];
                        }
                        quizSqlAnswer = s[6];
                    }
                }



                db.CloseDB();
            }



            Debug.Log("SQL Result is " + quizSqlAnswer);
            if (quizSqlAnswer == Answer4.GetComponentInChildren <Text>().text)
            {
                Debug.Log("Compared with SQL. Answer 4 Correct");
                PlayerPrefs.SetString(exhibit + "Quiz", "Correct");
                ResultImage.texture = (Texture)CorrectSign;
                ResultImageHolder.SetActive(true);
            }
            else
            {
                Debug.Log("Compared with SQL. Answer 4 Incorrect");
                PlayerPrefs.SetString(exhibit + "Quiz", "Incorrect");
                ResultImage.texture = (Texture)IncorrectSign;
                ResultImageHolder.SetActive(true);
            }

            StartCoroutine(MyMethod());
        }
    }
Example #23
0
    void OnGUI()
    {
        //  Creating transparent backgrounds for GUI buttons
        // Make new Color(0, 0, 0, 1) to see where the gui boxes are (no longer transparent)
        //GUI.backgroundColor = new Color(0, 0, 0, 0);

        GUI.backgroundColor = Color.gray;
        tabInt   = GUI.Toolbar(new Rect(15, 5, 150 * 2, 50), tabInt, tabTexs);
        windowID = tabInt;
        switch (tabInt)
        {
        case 0:
            GUI.Button(new Rect(15 - 1, 5, 150, 50), tabSelectedTexs[0]);
            windowRect = GUI.Window(windowID, windowRect, DoMyWindow, "");
            break;

        case 1:
            GUI.Button(new Rect(15 + 150 + 1, 5, 150, 50), tabSelectedTexs[1]);
            windowRect = GUI.Window(windowID, windowRect, DoMyWindow, "");
            break;

        default:
            break;
        }

        // Outside buttons
        if (windowID == 1)
        {
            if (statsSwitch == 0)
            {
                // To view details of a session
                inputString = GUI.TextField(new Rect(Screen.width - 280, 10, 100, 30), inputString);
                if (GUI.Button(new Rect(Screen.width - 170, 10, 150, 30), "View Session Details"))
                {
                    if (LoginScreen.currentID > 0)
                    {
                        string patientTable = tablePrefix + LoginScreen.currentID;
                        int    inputInt;
                        // Is this even a number?
                        if (int.TryParse(inputString, out inputInt))
                        {
                            // Is this in the session list?
                            int        input   = inputInt;
                            List <int> ID_list = new List <int>();
                            ID_list = db.GetIDValues(patientTable, "SessionID");
                            if (ID_list.Contains(input))
                            {
                                selectedSession = input;
                                statsSwitch     = 1;
                            }
                        }
                    }
                }
            }
            else if (statsSwitch == 1)
            {
                // Button to go back to stats
                if (GUI.Button(new Rect(Screen.width - 170, 10, 150, 30), "Return to Sessions"))
                {
                    statsSwitch = 0;
                }
            }
        }

        // Large box container
        GUILayout.BeginArea(new Rect(15, 50, Screen.width - 25, Screen.height - 120));
        GUILayout.Label(box);
        GUILayout.EndArea();

        // Back button to game menu
        if (GUI.Button(new Rect(60, Screen.height - 60, 150, 50), back))
        {
            if (LoginScreen.currentID > 0)
            {
                db.CloseDB();
            }
            Application.LoadLevel("TherapistScreen");
        }
    }
Example #24
0
    void OnGUI()
    {
        //  Creating transparent backgrounds for GUI buttons
        // Make new Color(0, 0, 0, 1) to see where the gui boxes are (no longer transparent)

        GUI.backgroundColor = Color.blue;

        // add window
        if (window_ID == 1)                             // show all patients
        {
            mainRect = GUI.Window(window_ID, new Rect(150, 60, Screen.width / 2 - 100, Screen.height * 2 / 3), DoMyWindow, "");
        }
        else if (window_ID == 2)                // show add patient form and get user input
        {
            newPatientRect = GUI.Window(window_ID, new Rect(150, 60, Screen.width / 2 - 100, Screen.height * 2 / 3), DoMyWindow, "");
        }
        else if (window_ID == 3)
        {
            deletePatientRect = GUI.Window(window_ID, new Rect(150, 60, Screen.width / 2 - 100, Screen.height * 2 / 3), DoMyWindow, "");
        }

        GUI.backgroundColor = new Color(0, 0, 0, 0);

        if (selectedID == -1)
        {
            GUI.Box(new Rect(Screen.width / 2 + 100, 100, 300, 50), noPatient);
        }
        else
        {
            GUI.Box(new Rect(Screen.width / 2 + 100, 100, 300, 50), selectedPatient);
            displayID = selectedID.ToString();
            GUI.Box(new Rect(Screen.width / 2 + 405, 100, 50, 50), displayID, idStyle);
        }

        // add "Add new patient" button

        /*if(GUI.Button(new Rect(Screen.width/2 + 150, 300, 120, 25), "Add new patient")) {
         *      // popup a window prompting for new patient information
         *      window_ID = 2;
         *      newPatientRect = GUI.Window(window_ID, new Rect(20, 60, Screen.width - 40, Screen.height - 130), DoMyWindow, "");
         * }*/

        if (GUI.Button(new Rect(Screen.width / 2 + 150, 400, 150, 50), delete))
        {
            // delete patient information from patientID, patientLastName, patientFirstName
            window_ID         = 3;
            deletePatientRect = GUI.Window(window_ID, new Rect(20, 60, Screen.width - 40, Screen.height - 130), DoMyWindow, "");
        }

        if (GUI.Button(new Rect(60, Screen.height - 60, 150, 50), back))
        {
            LoginScreen.db.CloseDB();
            Application.LoadLevel("TitleScreen");
        }

        if (GUI.Button(new Rect(220, Screen.height - 60, 150, 50), statistics))
        {
            if (selectedID > -1)
            {
                // Stop the window from continuing to use the db to avoid conflict
                window_ID = 0;
                stopRect  = GUI.Window(window_ID, new Rect(20, 60, Screen.width - 40, Screen.height - 130), DoMyWindow, "");

                // selected player
                currentID = selectedID;

                db.CloseDB();
                // open window to view statitics of selected patient
                Application.LoadLevel("Statistics");
            }
        }
    }
Example #25
0
    public void BuildDBSchema()
    {
        Debug.Log("Start constructing DB");

        db = GetComponent <dbAccess>();
        db.OpenDB("VBBS.db");

        // Create Table for Match
        string[] match = new string[] {
            "ID INTEGER PRIMARY KEY AUTOINCREMENT",
            "date TEXT",
            "time TEXT",
            "location TEXT",
            "name TEXT",
            "team TEXT",
            "enemy TEXT",
            "matchStyle INTEGER",
            "ruleStyle INTEGER",
        };

        db.CreateTableByQuery("matches", match);

        // Create Table for Round
        string[] round = new string[] {
            "ID INTEGER PRIMARY KEY AUTOINCREMENT",
            "team_score INTEGER",
            "enemy_score INTEGER",
            "match_ID INTEGER",
            "FOREIGN KEY(match_ID) REFERENCES matches(ID)"
        };

        db.CreateTableByQuery("rounds", round);

        // Create Table for Each Ball

        string[] ball = new string[] {
            "ID INTEGER PRIMARY KEY AUTOINCREMENT",
            "time NUMERIC",
            "start_X NUMERIC",
            "start_Y NUMERIC",
            "end_X NUMERIC",
            "end_Y NUMERIC",
            "attacker INTEGER",
            "team_player INTEGER",
            "enemy_player INTEGER",
            "skill INTEGER",
            "good INTEGER",
            "score INTEGER",
            "score_reason INTEGER",
            "team_change INTEGER",
            "team_switch INTEGER",
            "team_position INTEGER",
            "team_score INTEGER",
            "enemy_score INTEGER",
            "enemy_change INTEGER",
            "enemy_switch INTEGER",
            "enemy_position INTEGER",
            "round_ID INTEGER",
            "FOREIGN KEY(round_ID) REFERENCES rounds(ID)"
        };

        db.CreateTableByQuery("balls", ball);

        Debug.Log("Constructing Done");

        db.CloseDB();
    }
Example #26
0
    public void DBAndroid()
    {
        //Handheld.Vibrate();
        dbAccess db = GetComponent <dbAccess>();


        db.OpenDB("museumDatabase.db");

        //ArrayList result = db.SingleSelectWhere("exhibit", "*", "exhibitID", "=", "'ExhibitB'");

        if (PlayerPrefs.GetString("language") == "Italy")
        {
            result = db.SingleSelectWhere("exhibit_italy", "*", "exhibitID", "=", "'" + mTrackableBehaviour.TrackableName + "'");
        }
        if (PlayerPrefs.GetString("language") == "UnitedKingdom")
        {
            result = db.SingleSelectWhere("exhibit", "*", "exhibitID", "=", "'" + mTrackableBehaviour.TrackableName + "'");
        }
        if (PlayerPrefs.GetString("language") == "France")
        {
            result = db.SingleSelectWhere("exhibit_france", "*", "exhibitID", "=", "'" + mTrackableBehaviour.TrackableName + "'");
        }

        if (result.Count > 0)
        {
            description = "";
            foreach (string[] s in result)
            {
                for (int x = 0; x < s.Length; x++)
                {
                    //description += "\n" + s[x];
                }
                artist      = s[1];
                year        = s[2];
                name        = s[3];
                description = s[4];
                url         = s[5];
            }
        }



        db.CloseDB();



        Debug.Log("Desc - " + description);
        ExhibitID.text = mTrackableBehaviour.TrackableName;
        //ExhibitData.text = description;


        if (PlayerPrefs.GetString("language") == "Italy")
        {
            ExhibitData.text = "Nome della Mostra: " + name + "\nArtista: " + artist + "\nAnno: " + year + "\n\n" + description + "\n\nArticoli simili\n\n";
        }
        if (PlayerPrefs.GetString("language") == "UnitedKingdom")
        {
            ExhibitData.text = "Exhibit Name: " + name + "\nExhibit Artist: " + artist + "\nYear: " + year + "\n\n" + description + "\n\nSimilar Items\n\n";
        }
        if (PlayerPrefs.GetString("language") == "France")
        {
            ExhibitData.text = "Nom du Exposition: " + name + "\nArtiste: " + artist + "\nAn: " + year + "\n\n" + description + "\n\nDes Articles Similaires\n\n";
        }



        dbAccess dsSimilar = GetComponent <dbAccess>();

        dsSimilar.OpenDB("museumDatabase.db");

        //resultSimilarItems = db.SingleSelectWhere("exhibit", "*", "exhibitID", "=", "'ExhibitB'");
        resultSimilarItems = dsSimilar.SingleSelectWhere("exhibit", "*", "exhibitArtist", "=", "'" + artist + "' AND exhibitID != '" + mTrackableBehaviour.TrackableName + "'");

        if (resultSimilarItems.Count > 0)
        {
            foreach (string[] similar in resultSimilarItems)
            {
                similarItemsID    = similar[0];
                similarItemsName  = similar[3];
                ExhibitData.text += similarItemsID + " - " + similarItemsName + "\n";
            }
        }



        dsSimilar.CloseDB();

        SpeakButton.onClick.AddListener(delegate { startReading(ExhibitData.text); });                            // - On Click, read the text within the input field
        StopSpeakButton.onClick.AddListener(delegate { stopReading(); });                                         // - On Click, Stop read the text within the input field
        ShowMoreInfo.onClick.AddListener(delegate { OpenURL(url); });
    }
Example #27
0
    public void newStats(float timePlayed, string bbsActivity, int bbsGrade)
    {
        numPlays++;
        if(numPlays <= 100)
        {
            db = new dbAccess();
            db.OpenDB(dbName);

            // Get Play Duration
            string playColumn = "Play" + numPlays.ToString();
            TimeSpan duration = TimeSpan.FromSeconds((int)timePlayed);

            // Store values into DB
            string playString = duration.ToString() + "|" + bbsActivity + "|" + bbsGrade.ToString();
            db.UpdateSpecific(patientTable, playColumn, playString, "SessionID", sessionNum);

            // Update session stats
            sessionTime += timePlayed;

            db.CloseDB();
        }
    }
Example #28
0
    public void StartNewGame()
    {
        //makesure all input fieds are not empty
        bool endstatus = true;

        for (int i = 0; i < numplayers; i++)
        {
            int number = i + 1;
            playerusername[i] = GameObject.Find("InputFieldPlayer" + number + "name").GetComponent <InputField>().text;
            if (playerusername [i] != "")
            {
                playerusernameactive[numplayersactive]        = playerusername[i];
                defvalueavatar.avataractive[numplayersactive] = number;
                numplayersactive += 1;
            }

            if (number == numplayers)
            {
                endstatus = true;
            }
            else
            {
                endstatus = false;
            }
        }
        //Debug.Log (avataractive[0]);
        //endstatus = false;
        if (endstatus)
        {
            //create a session
            string   datetimenow = System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
            string[] valuedata   = { "'" + datetimenow + "'", "'Active'" };
            //int insertresult =
            db.InsertInto("tbl_Sessions (Session_Name, Status)", valuedata);
            //Debug.Log(insertresult);

            //select the new created sessions ID.
            ArrayList result     = db.SelectLastRecord("id", "tbl_Sessions");
            string    session_id = ((string[])result[0])[0];
            //Debug.Log ("Session created ok" + session_id);

            for (int i = 0; i < numplayersactive; i++)
            {
                //insert the login and the user and also create the player
                string[] valuedata2 = { "'" + playerusernameactive [i] + "'", "'" + playerusernameactive [i] + "'" };
                //int insertresult2 =
                db.InsertInto("tbl_Login (username, password)", valuedata2);
                //Debug.Log(insertresult2);

                //select the new login ID.
                ArrayList result2  = db.SelectLastRecord("id", "tbl_Login");
                string    login_id = ((string[])result2[0])[0];
                //Debug.Log ("Login created ok" + login_id);

                //insert the user
                string[] valuedata3 = { "'" + playerusernameactive [i] + "'", "'" + login_id + "'" };
                //int insertresult3 =
                db.InsertInto("tbl_Users (name, tbl_Login_id)", valuedata3);
                //Debug.Log(insertresult3);

                //select the new User ID.
                ArrayList result3 = db.SelectLastRecord("id", "tbl_Users");
                string    user_id = ((string[])result3[0])[0];
                //Debug.Log ("user_id created ok" + user_id);

                string statusdice;
                if (i == 0)
                {
                    statusdice = "Active";
                }
                else
                {
                    statusdice = "Off";
                }

                //insert the players
                int number = defvalueavatar.avataractive[i];
                //Debug.Log(number);
                string[] valuedata4 = { "'" + number + "'", "'10'", "'1'", "'none'", "'" + statusdice + "'", "'" + user_id + "'", "'" + session_id + "'" };
                //int insertresult4 =
                db.InsertInto("tbl_Players (avatar_number, numMoney, numLevel, numReward, status_dice_roll, tbl_Users_id, tbl_Sessions_id)", valuedata4);
                //Debug.Log ("status for ok " + insertresult4);
            }


            db.CloseDB();

            //GameObject.Find ("EventSystem").SetActive (false);
            SceneManager.LoadScene("Main", LoadSceneMode.Additive);
        }
    }