示例#1
0
    /**
     * @brief Sets Program List
     * Opens up a connection to the database and queries "SELECT * FROM GAMEINSTANCE WHERE ProgramID = " + m_currentProgram.
     * Reads through each of the database columns and assigns the values to the corresponding current instance of the program
     * then sets it to the current game.
     *
     * @param
     * @return void
     * @pre
     * @post
     */
    private void setProgramList()
    {
        GameDataHelper.GameInstance game;

        OdbcCommand cmd = new OdbcCommand();

        cmd.Connection  = con;
        cmd.CommandText = "SELECT * FROM GAMEINSTANCE WHERE ProgramID = " + m_currentProgram;
        OdbcDataReader read = cmd.ExecuteReader();

        while (read.Read())
        {
            game = new GameDataHelper.GameInstance();
            game.m_gameInstanceID = read.GetInt32(0);
            game.m_gameID         = read.GetInt32(2);
            game.m_difficulty     = read.GetInt32(3);
            game.m_duration       = read.GetInt32(4);

            if (read.GetString(5) == "True")
            {
                game.m_completed = true;
            }
            else
            {
                game.m_completed = false;
            }
            m_programGames.Add(game);
        }

        setCurrentGame();
    }
示例#2
0
 /**
  * @brief Sets Current Game
  * Loops through the program games and checks if the program game has been completed. If true,
  * continues to check the rest of the games in the program games else sets the current game to
  * that of the game that has not been completed and breaks to keep game set at that incomplete
  * game.
  *
  * @param
  * @return void
  * @pre
  * @post
  */
 public void setCurrentGame()
 {
     for (int i = 0; i < m_programGames.Count; i++)
     {
         if (!m_programGames.ElementAt(i).m_completed)
         {
             m_currentGame = m_programGames.ElementAt(i);
             GameDataHelper.setCurrentGame(m_programGames.ElementAt(i));
             break;
         }
     }
 }
示例#3
0
    /**
     * @brief Adds Patient Data to Database
     * Opens a connection to the database adds the parameters given into the patient data then updates the
     * game instance of the patient setting the completed value to 1 (true).
     *
     * @param GameDataHelper.GameInstance game
     * @param int score
     * @param int timePlayed
     * @string videourl
     * @return void
     * @pre
     * @post
     */
    public void addPatientData(GameDataHelper.GameInstance game, int score, int timePlayed, string videourl)
    {
        OdbcCommand cmd = new OdbcCommand();

        cmd.Connection  = con;
        cmd.CommandText = "INSERT INTO PATIENTDATA(GameID, UserID, Score, TimePlayed, VideoLocation) VALUES(" + game.m_gameID + ", '" + m_userID + "', " + score + ", " + timePlayed + ", '" + videourl + "')";
        cmd.ExecuteNonQuery();

        OdbcCommand cmd2 = new OdbcCommand();

        cmd2.Connection  = con;
        cmd2.CommandText = "UPDATE GAMEINSTANCE SET Completed = 1 WHERE GameInstanceID = " + game.m_gameInstanceID;
        cmd2.ExecuteNonQuery();
    }
示例#4
0
    AudioSource audioSource;          // Audio Source object

    /**
     * @brief Overloaded Start Function
     * Initialises the Game Logic class. Sets the game instance, begins the Kinect recording,
     * sets the game difficulty and initialises audio features.
     *
     * @param
     * @return void
     * @pre
     * @post
     */
    void Start()
    {
        game = GameDataHelper.getCurrentGame();
        GameDataHelper.record();
        switch (game.m_difficulty)
        {
        case 1:
            setEasy();
            break;

        case 2:
            setMedium();
            break;

        case 3:
            setHard();
            break;
        }
        audioSource = GetComponent <AudioSource>();
    }
示例#5
0
    /**
     * @brief Sets Current Game Instance
     *
     * @param int gid
     * @param int difficulty
     * @param int time
     * @return GameDataHelper.GameInstance gi
     * @pre
     * @post
     */
    public GameDataHelper.GameInstance addGameInstance(int gid, int difficulty, int time)
    {
        int         ginstid;
        int         count = 0;
        OdbcCommand cmd   = new OdbcCommand();

        cmd.Connection  = con;
        cmd.CommandText = "INSERT INTO GAMEINSTANCE(GameID, Difficulty, Duration) VALUES(" + gid + ", '" + difficulty + "', " + time + ")";
        cmd.ExecuteNonQuery();

        cmd.CommandText = "SELECT COUNT(*) FROM GAMEINSTANCE";
        OdbcDataReader read = cmd.ExecuteReader();

        read.Read();
        int total = read.GetInt32(0);

        read.Close();

        cmd.CommandText = "SELECT GameInstanceID FROM GAMEINSTANCE";
        read            = cmd.ExecuteReader();

        while (count < total - 1)
        {
            read.Read();
            count++;
        }

        read.Read();
        ginstid = read.GetInt32(0);

        GameDataHelper.GameInstance gi = new GameDataHelper.GameInstance();
        gi.m_gameInstanceID = ginstid;
        gi.m_gameID         = gid;
        gi.m_difficulty     = difficulty;
        gi.m_duration       = time;

        GameDataHelper.setCurrentGame(gi);

        return(gi);
    }