void Start() { // Gather a list of weapons and their type names pulled from the weapontype table List <Weapon> weapons = dbManager.Query <Weapon>( "SELECT " + "W.WeaponID, " + "W.WeaponName, " + "W.Damage, " + "W.Cost, " + "W.Weight, " + "W.WeaponTypeID, " + "T.Description AS WeaponTypeDescription " + "FROM " + "Weapon W " + "JOIN WeaponType T " + "ON W.WeaponTypeID = T.WeaponTypeID " + "ORDER BY " + "W.WeaponID " ); // output the list of weapons outputText.text = "Weapons\n\n"; foreach (Weapon weapon in weapons) { outputText.text += "Name: '" + weapon.WeaponName + "' " + "Damage:" + weapon.Damage.ToString() + " " + "Cost:" + weapon.Cost.ToString() + " " + "Weight:" + weapon.Weight.ToString() + " " + "Type:" + weapon.WeaponTypeDescription + "\n"; } }
//Display All Records From User_Table public void Display_Data_UnlockedCharacterTable() { //Display User Data string sql2 = "SELECT * FROM User_Table"; List <User_Table> usr = dbManager.Query <User_Table> (sql2); int rowCounter = 0; foreach (User_Table row in usr) { rowCounter++; print("Record No : " + rowCounter + " >> Character No : " + row.UNLOCKED_CHAR_ID + " >> Character Name : " + row.UNLOCKED_CHAR_NAME); } }
void Start() { outputText.text = ""; // get the final path in the working directory by combining the persistentDataPath with the new file name var attachDatabaseFilePath = Path.Combine(Application.persistentDataPath, attachDatabaseNewFileName); // extract the attach database file from the Unity project into the working directory if (!ExtractDatabase(attachDatabaseFilePath)) { // failed, exit return; } // attach to the scifi database dbManager.Execute("ATTACH DATABASE '" + attachDatabaseFilePath + "' AS SciFi"); // query the players from the newly attached database and output them to the screen outputText.text += "Players:\n"; var players = dbManager.Query <PlayerStats>("SELECT * FROM PlayerStats"); foreach (var player in players) { outputText.text += player.PlayerName + "\n"; } outputText.text += "\n\n"; // query the weapons from the original datbase and output them to the screen outputText.text += "Weapons:\n"; var weapons = dbManager.Query <Weapon>("SELECT * FROM Weapon"); foreach (var weapon in weapons) { outputText.text += weapon.WeaponName + "\n"; } }
void Start() { // alternate way of populating an entire table without using a SQL statement. This uses Linq. // You could also use "SELECT * FROM Location" with a Query function without Linq. List <Location> startingLocationList = new List <Location> (from loc in dbManager.Table <Location> () select loc); // set up a sql query that we will reuse, // binding the parameter denoted by ? with the location id string sql = "SELECT " + "CASE " + "WHEN L.LocationID = M.LocationID1 THEN ML2.LocationName " + "WHEN L.LocationID = M.LocationID2 THEN ML1.LocationName " + "END AS LocationName " + "FROM " + "Location L " + "JOIN LocationMapping M " + "ON L.LocationID = M.LocationID1 " + "OR L.LocationID = M.LocationID2 " + "LEFT JOIN Location ML1 " + "ON M.LocationID1 = ML1.LocationID " + "LEFT JOIN Location ML2 " + "ON M.LocationID2 = ML2.LocationID " + "WHERE " + "L.LocationID = ?"; // loop through each starting location and gather the list of adjacent location based on our mapping table // using the premade query above. foreach (Location startingLocation in startingLocationList) { startingLocation.AdjacentLocations = dbManager.Query <Location>(sql, startingLocation.LocationID); } // output our list of starting locations along with their corresponding adjacent locations outputText.text = "Map adjacent locations:\n\n"; foreach (Location startingLocationRecord in startingLocationList) { outputText.text += "<color=#1abc9c>" + startingLocationRecord.LocationName + "</color> is next to: <color=#34495e>"; foreach (Location adjacentLocation in startingLocationRecord.AdjacentLocations) { outputText.text += adjacentLocation.LocationName + ", "; } // trim off last comma outputText.text = outputText.text.Substring(0, outputText.text.Length - 2); outputText.text += "</color>\n"; } }
void Start() { // Gather a list of weapons and their type names pulled from the weapontype table List <Weapon> weaponList = dbManager.Query <Weapon>( "SELECT " + "W.WeaponID, " + "W.WeaponName, " + "W.Damage, " + "W.Cost, " + "W.Weight, " + "W.WeaponTypeID, " + "T.Description AS WeaponTypeDescription " + "FROM " + "Weapon W " + "JOIN WeaponType T " + "ON W.WeaponTypeID = T.WeaponTypeID " + "ORDER BY " + "W.WeaponID " ); // output the list of weapons outputText.text = "Weapons\n\n"; foreach (Weapon weaponRecord in weaponList) { outputText.text += "<color=#1abc9c>Name</color>: '" + weaponRecord.WeaponName + "' " + "<color=#1abc9c>Damage</color>:" + weaponRecord.Damage.ToString() + " " + "<color=#1abc9c>Cost</color>:" + weaponRecord.Cost.ToString() + " " + "<color=#1abc9c>Weight</color>:" + weaponRecord.Weight.ToString() + " " + "<color=#1abc9c>Type</color>:" + weaponRecord.WeaponTypeDescription + "\n"; } // get the first weapon record that has a WeaponID > 4 outputText.text += "\nFirst weapon record where the WeaponID > 4: "; bool recordExists; Weapon firstWeaponRecord = dbManager.QueryFirstRecord <Weapon>(out recordExists, "SELECT WeaponName FROM Weapon WHERE WeaponID > 4"); if (recordExists) { outputText.text += firstWeaponRecord.WeaponName + "\n"; } else { outputText.text += "No record found\n"; } }
void Start() { // Gather a list of weapons and their type names pulled from the weapontype table List <Stuff> weapons = dbManager.Query <Stuff>( "SELECT " + "W.displayText, " + "W.imageLocation " + "FROM " + "memoryBank W " ); // output the list of weapons outputText.text = "Memories...\n\n"; foreach (Stuff weapon in weapons) { outputText.text += "Display Name: " + weapon.WeaponName.ToString() + "\n" + "Image Location: " + weapon.Damage.ToString() + "\n\n"; } }
void Start() { dbManager.Execute("DROP TABLE IF EXISTS posts"); dbManager.Execute("CREATE VIRTUAL TABLE posts" + " USING FTS5 (" + "title" + ",body" + ")" ); dbManager.Execute("INSERT INTO posts " + "(" + "title" + ",body" + ")" + " VALUES (" + "'Learn SQlite FTS5'" + ",'This tutorial teaches you how to perform full-text search in SQLite using FTS5'" + ")" + ",(" + "'Advanced SQlite Full-text Search'" + ",'Show you some advanced techniques in SQLite full-text searching'" + ")" + ",(" + "'SQLite Tutorial'" + ",'Help you learn SQLite quickly and effectively'" + ")" ); var matchResults = dbManager.Query <Post>("SELECT * FROM posts WHERE posts MATCH 'learn NOT text'"); outputText.text = "Posts matching 'learn NOT text'\n\n"; foreach (var result in matchResults) { outputText.text += "<color=#1abc9c>Title</color>: '" + result.title + "' " + "<color=#1abc9c>Body</color>: '" + result.body + "'\n"; } }
public void HideSelectMonsterPopup() { string sql = "SELECT " + "MQ.ID, " + "MQ.Image, " + "MQ.PosX, " + "MQ.PosY, " + "MQ.Atk, " + "MQ.Def, " + "MQ.Hp, " + "E.Apply, " + "E.Value, " + "E.Turn, " + "ET.Type " + "FROM MonsterEquip MQ " + "JOIN Effects E " + "ON MQ.EffectID = E.EffectID " + "JOIN EffectType ET " + "ON E.EffectTypeID = ET.EffectTypeID "; mqList = dbManager.Query <MonsterEquipRaw>(sql); foreach (string key in hashtable.Keys) { visualMonsterNameList.Add((string)hashtable[key]); Debug.Log((string)hashtable[key]); } Shuffle(visualMonsterNameList); //for (int i = 0; i < visualMonsterEquipped.Length; i++) //{ // visualMonsterEquipped[i].sprite = Resources.Load("Sprites/" + visualMonsterNameList[i], typeof(Sprite)) as Sprite; // for (int j = 0; j < jsonMonsters["monsters"].Count; j++) // { // if (jsonMonsters["monsters"][j]["image"].ToString() == visualMonsterNameList[i]) // { // MonsterEquip mq = visualMonsterEquipped[i].gameObject.AddComponent<MonsterEquip>(); // mq.ID = jsonMonsters["monsters"][j]["id"].ToString(); // mq.Image = jsonMonsters["monsters"][j]["image"].ToString(); // mq.PosX = float.Parse(jsonMonsters["monsters"][j]["posx"].ToString()); // mq.PosY = float.Parse(jsonMonsters["monsters"][j]["posy"].ToString()); // mq.AddValue("atk", jsonMonsters["monsters"][j]["bonus"][0]["atk"].ToString()); // mq.AddValue("def", jsonMonsters["monsters"][j]["bonus"][0]["def"].ToString()); // mq.AddValue("hp", jsonMonsters["monsters"][j]["bonus"][0]["hp"].ToString()); // mq.EffectProperty.Turn = int.Parse(jsonMonsters["monsters"][j]["effect"][0]["turn"].ToString()); // mq.EffectProperty.Apply = jsonMonsters["monsters"][j]["effect"][0]["apply"].ToString(); // mq.EffectProperty.Value = int.Parse(jsonMonsters["monsters"][j]["effect"][0]["value"].ToString()); // mq.EffectProperty.Type = jsonMonsters["monsters"][j]["effect"][0]["type"].ToString(); // } // } // Debug.Log(visualMonsterNameList[i]); //} for (int i = 0; i < visualMonsterEquipped.Length; i++) { visualMonsterEquipped[i].sprite = Resources.Load("Sprites/" + visualMonsterNameList[i], typeof(Sprite)) as Sprite; for (int j = 0; j < mqList.Count; j++) { if (mqList[j].Image == visualMonsterNameList[i]) { MonsterEquip mq = visualMonsterEquipped[i].gameObject.AddComponent <MonsterEquip>(); mq.ID = mqList[j].ID.ToString(); mq.Image = mqList[j].Image; mq.PosX = float.Parse(mqList[j].PosX.ToString()); mq.PosY = float.Parse(mqList[j].PosY.ToString()); mq.AddValue("atk", mqList[j].Atk.ToString()); mq.AddValue("def", mqList[j].Def.ToString()); mq.AddValue("hp", mqList[j].Hp.ToString()); mq.EffectProperty.Turn = mqList[j].Turn; mq.EffectProperty.Apply = mqList[j].Apply; mq.EffectProperty.Value = mqList[j].Value; mq.EffectProperty.Type = mqList[j].Type; } } Debug.Log(visualMonsterNameList[i]); } selectMonsterPopupGO.SetActive(false); onCD = false; }
public List <DrawDotData> GetDrawDots(int stageID) { return(dbManager.Query <DrawDotData>($"SELECT * FROM DrawDotData WHERE stage_id={stageID}")); }