// Use this for initialization to connect database void Start() { //Load required scenes for the games SceneManager.UnloadScene("New"); setassetscene(); //get values of active session and number of active players activesessionid = GameObject.Find("EventSystem").GetComponent <StartGame>().active_session_id; avataractive = GameObject.Find("EventSystem").GetComponent <StartGame>().avataractive; //db = GetComponent<dbAccess>(); db = GameObject.Find("database").GetComponent <dbAccess>(); db.OpenDB("mydb.sdb"); ArrayList result = db.SelectLastRecord("id", "tbl_Sessions"); session_id = ((string[])result[0])[0]; //Set active_session_id on EventSystem to be used laterduring the game GameObject.Find("EventSystem").GetComponent <StartGame>().active_session_id = session_id; //this function is to insert history into table hismsg = "Game Starts"; db.InsertHistory(hismsg, session_id); HistPrint("-"); HistPrint("-"); HistPrint(hismsg); totplayeractive = db.BasicQuery("SELECT COUNT(id) FROM tbl_players WHERE tbl_Sessions_id=" + session_id); totplayeractive.Read(); totnumplayeractive = totplayeractive.GetInt32(0); playernumber = db.BasicQuery("SELECT id FROM tbl_players WHERE tbl_Sessions_id=" + session_id); playernum = new ArrayList(); while (playernumber.Read()) { for (var i = 0; i < playernumber.FieldCount; i++) { playernum.Add(playernumber.GetValue(i)); // This reads the entries in a row } } avatarnumber = db.BasicQuery("SELECT avatar_number FROM tbl_players WHERE tbl_Sessions_id=" + session_id); avatarnum = new ArrayList(); while (avatarnumber.Read()) { for (var k = 0; k < avatarnumber.FieldCount; k++) { avatarnum.Add(avatarnumber.GetValue(k)); // This reads the entries in a row } } disableandenabletab(); disableandenabletab2(); PlayerOnClick(1); GameObject.Find("BtnPlayer" + nextactive).GetComponent <Image>().color = Color.blue; PlayerNameActive = GameObject.Find("numPlayerName").GetComponent <Text>().text; }
public void InfoCardOnClick() { db = GameObject.Find("database").GetComponent <dbAccess>(); msg = GameObject.Find("EngineMain").GetComponent <MainEngine>(); session_id = GameObject.Find("EventSystem").GetComponent <StartGame>().active_session_id; infonumber = db.BasicQuery("SELECT COUNT(id) FROM tbl_Info_Card;"); infonumber.Read(); maxNumbers = infonumber.GetInt32(0); maxNumbers = checkmaxnumber(maxNumbers, 12); int selectednumber = EventSystem.current.currentSelectedGameObject.GetComponent <value>().no_card; string selectedbutton = EventSystem.current.currentSelectedGameObject.name; GameObject.Find("CardBackgroundi").GetComponent <RectTransform>().localPosition = new Vector3(posopencard(selectedbutton), -80, 0); ArrayList result = db.SingleSelectWhere("tbl_Info_Card", "*", "id", "=", selectednumber.ToString()); desc = ((string[])result[0])[1]; reward = "$2"; correctanswer = ((string[])result[0])[2]; GameObject.Find("Content").GetComponent <Text> ().text = desc; GameObject.Find("Reward").GetComponent <Text> ().text = reward; showcard(); }
// 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(); }
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); }
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(); }
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(); }
// Use this for initialization void Start() { Debug.Log("starting SQLiteLoad app"); // Retrieve next word from database description = "something went wrong with the database"; db = new dbAccess(); if (db != null) { db.OpenDB("word.db"); System.Data.IDataReader reader = db.BasicQuery("SELECT * FROM words"); //System.Collections.Generic.List<string> reader = db.getWords(); if (reader != null) { description = ""; string water = "\u6C34"; //string disaster = "\u707D"; Word d = db.getWord(water); if (d != null) { description = "it works!"; } else { description = water; } /* * while(reader.Read()){ * description += reader.GetString(0) + " "; * description += reader.GetString(1) + " "; * description += reader.GetInt32(2) + " "; * string t = (string)reader.GetValue(3); * if(t == null) description +="NULL "; * else description += t + " "; * //description += reader.GetValue(3) + " "; * description += reader.GetValue(4) + " "; * description += reader.GetValue(5) + " "; * description += reader.GetValue(6) + " "; * description += reader.GetValue(7) + " "; * description += reader.GetValue(8) + " "; * /*for(int i=0; i<reader.FieldCount;i++){ * description += reader.GetString(i) + "\t"; * }//*/ // description += "\n"; //} } } else { toggle = true; } DontDestroyOnLoad(gameObject); }
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); }
public void DeleteMatch() { dbAccess db = GetComponent <dbAccess>(); db.OpenDB("VBBS.db"); IDataReader reader = db.BasicQuery("DELETE from matches WHERE ID = " + match_id); db.CloseDB(); }
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(); }
public int GetRoundIDFromMatch(int ID) { dbAccess db = GetComponent <dbAccess>(); db.OpenDB("VBBS.db"); IDataReader reader = db.BasicQuery("Select ID from rounds WHERE match_id = " + ID); reader.Read(); return(reader.GetInt32(0)); }
// Use this for initialization public void LoadInfoScene() { hideinfocard(); db = GameObject.Find("database").GetComponent <dbAccess>(); infonumber = db.BasicQuery("SELECT COUNT(id) FROM tbl_Info_Card;"); infonumber.Read(); maxNumbers = infonumber.GetInt32(0); //Debug.Log (maxNumbers); uniqueNumber = new List <int>(); finishedList = new List <int>(); AssignedValue(); }
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); }
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); }
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(); }
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); }