/// <summary> /// 主キーを指定して該当するデータを取得する /// </summary> /// <param name="id">主キー</param> /// <returns>データ、ただし存在しない場合はnull</returns> public List <T> SelectFromPrimaryKey <U>(Dictionary <string, string> whereQuery) { StringBuilder query = new StringBuilder(); query.Append("SELECT * FROM "); query.Append(TableName); QueryUtility.CreateWhereQuery(ref query, whereQuery); Debug.Log(query); query.Append(";"); DataTable dt = mDb.ExecuteQuery(query.ToString()); if (dt.Rows.Count == 0) { return(null); } else { var list = new List <T>(); foreach (var row in dt.Rows) { list.Add(PutData(row)); } return(list); } }
// DBにアクセスしてスコアをの高い順から取得する private void SelectOrderScore() { int count = 0; // scoreを見て降順でソートしている string selectQuery = "select * from user order by score desc"; DataTable dataTable = sqlDB.ExecuteQuery(selectQuery); foreach (DataRow dr in dataTable.Rows) { if (count > 4) { break; } nameStr = (string)dr["user_name"]; scoreInt = (int)dr["score"]; frameInt = (int)dr["frame"]; ChangeRankingState(count); //Debug.Log( // "name:" + (string)dr["user_name"] + // "score:" + (int)dr["score"] + // "frame:" + (int)dr["frame"] // ); count++; } }
public void DumpDB(string fileName) { SqliteDatabase db = GetDatabase(fileName); if (db == null) { Debug.LogError("db not found for file name: " + fileName); return; } string qry = "SELECT name FROM sqlite_master WHERE type='table'"; DataTable tableList = db.ExecuteQuery(qry); foreach (DataRow row in tableList.Rows) { foreach (KeyValuePair <string, object> item in row) { Debug.LogWarningFormat("Table Name: {0}", item.Value); string tableQry = "SELECT * FROM '" + item.Value.ToString() + "'"; DataTable tableData = db.ExecuteQuery(tableQry); foreach (DataRow tableRow in tableData.Rows) { foreach (KeyValuePair <string, object> elem in tableRow) { Debug.LogFormat("{0}: {1}", elem.Key, elem.Value); } } } } }
public static void new_test() { res1 = ""; Correct[0] = -1; SqliteDatabase sqlDB = new SqliteDatabase("question"); //コラム数を取得 string query = "select count (*) as ct from FE"; DataTable dT = sqlDB.ExecuteQuery(query); foreach (DataRow dr in dT.Rows) { ct = dr["ct"].ToString(); } //ランダムに1問抽出 int random = Random.Range((int)1, int.Parse(ct) + 1); string rq = "select * from FE where ID = " + random.ToString(); dT = sqlDB.ExecuteQuery(rq); foreach (DataRow dr in dT.Rows) { test = "問題: " + (string)dr["Question"]; a = "ア: " + (string)dr["Choice_a"]; i = "イ: " + (string)dr["Choice_i"]; u = "ウ: " + (string)dr["Choice_u"]; e = "エ: " + (string)dr["Choice_e"]; answer = (string)dr["Answer"]; } }
/// <summary> /// 主キーを指定して該当するデータを取得する /// </summary> /// <param name="id">主キー[shopid,machineid,machineNumber]</param> /// <returns>データ、ただし存在しない場合はnull</returns> public T SelectFromPrimaryKey(params int[] id) { StringBuilder query = new StringBuilder(); query.Append("SELECT * FROM "); query.Append(TableName); query.Append(" WHERE "); for (int i = 0; i < PrimaryKeyName.Length; i++) { query.Append(PrimaryKeyName[i]); query.Append("="); query.Append(id[i].ToString()); if (i < PrimaryKeyName.Length - 1) // 最終条件には接続詞をつけない { query.Append(" AND "); } } query.Append(";"); DataTable dt = mDb.ExecuteQuery(query.ToString()); if (dt.Rows.Count == 0) { return(null); } else { return(PutData(dt[0])); } }
public int getLocationIDbyName(string loName) { string query = @"select ID from tblLocations where Name = '" + loName + "';"; return(int.Parse(db.ExecuteQuery(query).Rows[0]["ID"].ToString())); }
public Story[] GetAll() { var sql = "select * from story"; var dataTable = sqlDB.ExecuteQuery(sql); return(dataTable.Rows.Select((r) => new Story((int)r["id"], (string)r["title"], JsonUtility.FromJson <Sentences>((string)r["sentences"]))).ToArray()); }
/// <summary> /// SELECT文:キャラクターの一覧を取得する /// </summary> /// <returns>dataTable : 取得したDB</returns> public DataTable SelectSQL(int row) { // ノード内に表示するテキストを検索する string query = $"select * from characters limit 1 offset {row}"; DataTable dataTable = sqlDB.ExecuteQuery(query); return(dataTable); }
public int CoutNumReview(int _stationid) { string query = @"select tblStations.ID, tblStations.name, tblReviews.Rating from tblStations, tblReviews where tblStations.ID = tblReviews.StationID and tblStations.ID = " + _stationid + " ;"; return(db.ExecuteQuery(query).Rows.Count); }
public void afresh() { string query = "insert chara(player, num) values({Player_num}, {Chara_num})"; sqlDB.ExecuteNonQuery(query); query = "select id from chara where player = {Player_num} and num = {Chara_num}"; DataTable dataTable = sqlDB.ExecuteQuery(query); Data_id = (int)dataTable[0]["id"]; Debug.Log(Data_id); }
/// <summary> /// Returns all data from the database (Chembox.db) /// </summary> /// <returns>The database.</returns> public DataTable GetDatabase() { DataTable result = sqlDB.ExecuteQuery("SELECT * FROM Molecules"); if (result.Rows.Count < 1) { Debug.LogError("Database returned empty DataTable."); } if (result == null) { Debug.LogError("Database returned null."); } return(result); }
public bool IsWordValid(string word, string dbFileName) { SqliteDatabase db = GetDatabase(dbFileName); if (db == null) { Debug.LogError("Cannot load database?"); return(false); } word = word.ToLower(); string firstLetter = word.Substring(0, 1); string letterCount = word.Length.ToString(); if (word.Length < 10) { letterCount = "0" + letterCount; } string table = firstLetter + letterCount; DataTable qry = db.ExecuteQuery("SELECT * FROM '" + table + "' WHERE word='" + word + "'"); foreach (DataRow row in qry.Rows) { foreach (KeyValuePair <string, object> kvp in row) { if (kvp.Value.ToString() == word) { return(true); } } } return(false); }
public static DataTable RequestLoad(DB_ID id) { for (int i = 0; i < databseList.Count; i++) { DatabaseLoadData data = databseList[i]; if (data.id != id) { continue; } if (data.isLoaded) { continue; } SqliteDatabase sqlDB = new SqliteDatabase(data.dbName + ".db"); string selectQuery = "SELECT * FROM " + data.tableName; data.dataTable = sqlDB.ExecuteQuery(selectQuery); data.isLoaded = true; return(data.dataTable); } return(null); }
/// <summary> /// Numbering the target column /// 対象列を採番(数値) /// </summary> /// <param name="column"></param> /// <returns></returns> public string GetAssignNumber(string column) { DataTable dataTable = new DataTable(); string countColumn = "Count"; string countSql = "select max(cast({0} as interger)) as " + countColumn + " from {1}"; this.ExecutetSql.Append(string.Format(countSql, column, this.GetDataAccessAttribute <DataAccessAttribute>(this.BaseType).TableName)); SqliteDatabase sqliteDataBase = new SqliteDatabase(CONNECT_TABLE); dataTable = sqliteDataBase.ExecuteQuery(this.ExecutetSql.ToString()); PropertyInfo propertyInfo = this.BaseType.GetProperty(column); if (propertyInfo == null) { Debug.Log("not found assign column"); return(string.Empty); } DataPropertyAttribute attribute = this.GetDataPropertyAttribute <DataPropertyAttribute>(propertyInfo); if (dataTable.Rows.Count.Equals(0)) { return(this.GetAssignNumberFormat(attribute.MaxLength, "1")); } else { int no = int.Parse(dataTable.Rows[0][countColumn].ToString()) + 1; return(this.GetAssignNumberFormat(attribute.MaxLength, no.ToString())); } }
IEnumerator ChangeInfo() { Text infotext = GameObject.Find("InfoText").GetComponent <Text>(); SqliteDatabase sqlite = new SqliteDatabase("shinkeisei.db"); string query = "SELECT * FROM url_info WHERE type = 2"; var response = sqlite.ExecuteQuery(query); string url = response.Rows[0]["url"].ToString(); WWW www = new WWW(url); yield return(www); var text = MakeText(www.text); //text = "2019年11月1日 10時45分【新京成線 一部列車運休】理由はうんにゃらかんにゃら"; ChangeTextSize(text); if (TextManager.lang == TextManager.LANGUAGE.JAPANESE) { infotext.text = text; } else { infotext.text = ""; } changeInfo(text); }
/// <summary> /// Unique data presence check /// ユニークデータ存在チェック /// </summary> /// <param name="component"></param> /// <returns>存在:true、非存在:false</returns> public bool ChkPrimaryData(object component) { try { DataTable dataTable = new DataTable(); string countColumn = "Count"; string countSql = "select count(*) as {0} from {1}"; this.ExecutetSql.AppendLine(string.Format(countSql, countColumn, this.GetDataAccessAttribute <DataAccessAttribute>(component.GetType()).TableName)); this.GetPrimaryKeyValue(component); this.CreatePrimaryWhere(component.GetType()); SqliteDatabase sqliteDataBase = new SqliteDatabase(CONNECT_TABLE); dataTable = sqliteDataBase.ExecuteQuery(this.ExecutetSql.ToString()); int count = int.Parse(dataTable.Rows[0][countColumn].ToString()); return(!count.Equals(0)); } catch (SqliteException ex) { Debug.Log(ex.Message + " " + this.ExecutetSql.ToString()); } return(false); }
/// <summary> /// Get the data without duplication from the target column /// 対象列から重複せずにデータを取得 /// </summary> /// <param name="column"></param> /// <param name="type"></param> /// <returns></returns> public string[] GetGroupDataArray(string column, Type type) { try { DataTable dataTable = new DataTable(); string groupSql = "select {0} from {1} group by {2}"; this.ExecutetSql.AppendLine(string.Format(groupSql, column, this.GetDataAccessAttribute <DataAccessAttribute>(type).TableName, column)); SqliteDatabase sqliteDataBase = new SqliteDatabase(CONNECT_TABLE); dataTable = sqliteDataBase.ExecuteQuery(this.ExecutetSql.ToString()); if (dataTable.Rows.Count.Equals(0)) { return(new string[] { }); } string[] dataArray = new string[dataTable.Rows.Count]; for (int i = 0; i < dataTable.Rows.Count; i++) { dataArray[i] = dataTable.Rows[i][column].ToString(); } return(dataArray); } catch (SqliteException ex) { Debug.Log(ex.Message + " " + this.ExecutetSql.ToString()); } return(new string[] { }); }
/// <summary> /// Issue select statements.Get the first data /// セレクトSQL文発行 /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public T GetDataFirst <T>() { try { DataTable dataTable = new DataTable(); this.CreateSelectSql(); SqliteDatabase sqliteDataBase = new SqliteDatabase(CONNECT_TABLE); Debug.Log(ExecutetSql.ToString()); dataTable = sqliteDataBase.ExecuteQuery(this.ExecutetSql.ToString()); if (dataTable.Rows.Count.Equals(0)) { return(default(T)); } T data = (T)Activator.CreateInstance(typeof(T), new object[] { }); DataBinding <T> .DataRowToObject(dataTable.Rows[0], data); return(data); } catch (SqliteException ex) { Debug.LogError(ex.Message + " " + this.ExecutetSql.ToString()); } finally { this.Init(this.BaseType); } return(default(T)); }
// Start is called before the first frame update void Start() { try { var fileName = "schoolprojectdb.db"; var db = new SqliteDatabase(fileName); var query = db.ExecuteQuery("SELECT * FROM user"); foreach (var row in query.Rows) { var id = row["u_id"]; var name = row["u_name"]; var mail = row["mail"]; var password = row["password"]; var text = $"ID:{id}, \r\nName:{name}, \r\nMail:{mail}, \r\nPassword:{password}\r\n"; Charactors.Add(text); } } catch (Exception ex) { Charactors.Add(ex.Message); } }
// Use this for initialization void Start() { SqliteDatabase sqlDB = new SqliteDatabase("ejdict.sqlite3"); string test = "apple"; string query = "select mean from items where word ='" + test + "'"; DataTable dataTable = sqlDB.ExecuteQuery(query); foreach (DataRow dr in dataTable.Rows) { string str = (string)dr["mean"]; // attack = (int)dr["attack"]; Debug.Log("name:" + str); } /* * SqliteDatabase sqlDB = new SqliteDatabase("GameMaster.db"); * string query = "select name,attack from Weapon where id=2"; * DataTable dataTable = sqlDB.ExecuteQuery(query); * * string name = ""; * int attack = 0; * foreach (DataRow dr in dataTable.Rows) * { * name = (string)dr["name"]; * attack = (int)dr["attack"]; * Debug.Log("name:" + name + " attack:" + attack); * } */ }
// Start is called before the first frame update void Start() { try { var fileName = "sample.db"; var db = new SqliteDatabase(fileName); var query = db.ExecuteQuery("SELECT * FROM charactors"); foreach (var row in query.Rows) { var id = row["id"]; var name = row["name"]; var data1 = row["data1"]; var data2 = row["data2"]; var text = $"ID:{id}, Name:{name}, DATA1:{data1}, DATA2:{data2}"; Charactors.Add(text); } } catch (Exception ex) { Charactors.Add(ex.Message); } }
// Use this for initialization void Start() { //変数初期化 for (int i = 0; i < 4; i++) { resflg[i] = 0; } ansflg = 0; Correct[0] = -1; Correct[1] = -1; Correct[2] = -1; Correct[3] = -1; res1 = ""; res2 = ""; res3 = ""; res4 = ""; if (PlayerPrefs.HasKey("playerCount")) { playerCount = PlayerPrefs.GetInt("playerCount"); //プレイヤー人数取得 } // Select SqliteDatabase sqlDB = new SqliteDatabase("question"); string selectQuery = "select * from FE"; DataTable dataTable = sqlDB.ExecuteQuery(selectQuery); Debug.Log("テスト"); string question = ""; foreach (DataRow dr in dataTable.Rows) { Debug.Log("ID:" + dr["ID"].ToString()); question = (string)dr["Question"]; Debug.Log("Question:" + question); Debug.Log("選択肢ア:" + (string)dr["Choice_a"]); Debug.Log("選択肢イ:" + (string)dr["Choice_i"]); Debug.Log("選択肢ウ:" + (string)dr["Choice_u"]); Debug.Log("選択肢エ:" + (string)dr["Choice_e"]); Debug.Log("正解:" + (string)dr["Answer"]); } }
// Use this for initialization void Start() { WriteText(); SqliteDatabase sqlite = new SqliteDatabase("shinkeisei.db"); string query = "SELECT * FROM user_info;"; var response = sqlite.ExecuteQuery(query); Static.FavoStation = response.Rows[0]["station"].ToString(); if (Static.FavoStation != "") { Static.StationNo = Static.FavoStation; } else { Static.StationNo = "01"; } scrollrect = GameObject.Find("Scroll").GetComponent <ScrollRect>(); scrollrect.horizontalNormalizedPosition = 0; count = 0; length = 1; StartCoroutine(ChangeInfo()); Dropdown langdrop = GameObject.Find("LangDrop").GetComponent <Dropdown>(); langdrop.value = (int)response.Rows[0]["language"]; StartCoroutine(CheckDialog()); }
public void DisplayRanking() { SqliteDatabase sqlDB = new SqliteDatabase("rank.db"); string query = "select * from " + table + " order by rank asc"; DataTable dataTable = sqlDB.ExecuteQuery(query); foreach (DataRow dr in dataTable.Rows) { int rank = (int)dr["rank"]; int score = (int)dr["score"]; int battery = (int)dr["battery"]; int time = (int)dr["time"]; Debug.Log("rank=" + rank + ", score=" + score + ", battery=" + battery + ", time=" + time); if (rank == thisRank && score == breakNum && battery == reminginBattery && time == reminingTime) { Debug.Log("^^^^this is your record^^^^"); rankingText.text += "<color=#00ff00>" + string.Format("{0,-3}", rank) + "\t\t\t\t" + string.Format("{0,-3}", score) + "\t\t\t\t" + string.Format("{0,-3}", battery) + "\t\t\t\t" + string.Format("{0,-3}", time) + "</color>\n"; } else { string.Format("{0,3}", rank); rankingText.text += string.Format("{0,-3}", rank) + "\t\t\t\t" + string.Format("{0,-3}", score) + "\t\t\t\t" + string.Format("{0,-3}", battery) + "\t\t\t\t" + string.Format("{0,-3}", time) + "\n"; } } }
protected override void RequestTile(int tileX, int tileY, int roundedZoom, Tile tile) { if (db == null) { throw new NullReferenceException("db"); } DataTable dt = db.ExecuteQuery("SELECT tile_data FROM tiles WHERE zoom_level=" + roundedZoom + " AND tile_column=" + tileX + " AND tile_row=" + tileY); if (dt.Rows.Count == 0) { #if DEBUG_LOG Debug.LogWarning("WARNING: no rows in MBTiles db for tile: " + tileX + "," + tileY + "," + roundedZoom); #endif return; } Texture2D tex = new Texture2D((int)Map.TileResolution, (int)Map.TileResolution); if (tex.LoadImage((byte[])dt.Rows[0]["tile_data"])) { tile.SetTexture(tex); } else { #if DEBUG_LOG Debug.LogError("ERROR: MBTilesLayer.RequestTile: couldn't load image for: " + tileX + "," + tileY + "," + roundedZoom); #endif } }
// シーン開始後に呼び出される void Start() { Debug.Log("「キャラクター詳細画面」に遷移した"); this.name = CharacterList.CharacterName; Debug.Log("name" + this.name); // DBからデータを取得する SqliteDatabase sqlDB = new SqliteDatabase("namebattler.db"); string query = string.Format("select * from characters where name ='{0}'", this.name); DataTable dataTable = sqlDB.ExecuteQuery(query); //変数の準備 var name = ""; int job = 0; int hp = 0; int mp = 0; int str = 0; int def = 0; int agi = 0; int luck = 0; string create_at = null; // DBのデータを変数に格納 foreach (DataRow dr in dataTable.Rows) { name = (string)dr["name"]; job = (int)dr["job"]; hp = (int)dr["hp"]; mp = (int)dr["mp"]; str = (int)dr["str"]; def = (int)dr["def"]; agi = (int)dr["agi"]; luck = (int)dr["luck"]; create_at = (string)dr["create_at"]; } // 名前の表示用 textName.text = name; //職業の表示用 if (job == 0) { textJob.text = "戦士"; } else if (job == 1) { textJob.text = "魔法使い"; } else if (job == 2) { textJob.text = "僧侶"; } else { textJob.text = "勇者"; } textStatus.text = string.Format("\n{0}\n{1}\n{2}\n{3}\n{4}\n{5}", hp, mp, str, def, agi, luck); }
public DataTable GetDataTable(string tableName) { SqliteDatabase sqlDB = new SqliteDatabase("1.db"); string query = string.Format("select * from " + tableName); DataTable dataTable = sqlDB.ExecuteQuery(query); return(dataTable); }
// DBの時刻を現在時刻に更新 public void Update_time() { DateTime putTime = DateTime.Now; string query = "update time_check_12 set time_12_year = " + putTime.Year + ", time_12_month = " + putTime.Month + ", time_12_day = " + putTime.Day + ", time_12_hour = " + putTime.Hour + ", time_12_minut = " + putTime.Minute + ", time_12_sec = " + putTime.Second + " where time_12_day = " + date[2]; sqlDB.ExecuteQuery(query); }
void ResetRank(int r) { int rr = r; SqliteDatabase sqlDB = new SqliteDatabase("rank.db"); string query = "update " + table + " set rank=rank+1 where rank>=" + r; sqlDB.ExecuteQuery(query); }
/// <summary> /// 文字列初期化 /// </summary> /// <param name="lang">使用言語</param> public static void Init() { SqliteDatabase sqlite = new SqliteDatabase("shinkeisei.db"); string query = "SELECT language FROM user_info;"; var response = sqlite.ExecuteQuery(query); if ((int)response.Rows[0]["language"] == 1) { lang = LANGUAGE.ENGLISH; } else if ((int)response.Rows[0]["language"] == 2) { lang = LANGUAGE.CHINESE; } else if ((int)response.Rows[0]["language"] == 3) { lang = LANGUAGE.KOREAN; } else { lang = LANGUAGE.JAPANESE; } // リソースファイルパス決定 string filePath; if (lang == LANGUAGE.JAPANESE) { filePath = "Text/japanese"; } else if (lang == LANGUAGE.ENGLISH) { filePath = "Text/english"; } else if (lang == LANGUAGE.CHINESE) { filePath = "Text/chinese"; } else if (lang == LANGUAGE.KOREAN) { filePath = "Text/korean"; } else { throw new Exception("TextManager Init failed."); } // ディクショナリー初期化 sDictionary.Clear(); TextAsset csv = Resources.Load <TextAsset>(filePath); StringReader reader = new StringReader(csv.text); while (reader.Peek() > -1) { string[] values = reader.ReadLine().Split('\t'); sDictionary.Add(values[0], values[1].Replace("\\n", "\n")); } }
// Use this for initialization void Start() { Resources.UnloadUnusedAssets(); StartCoroutine(viewStart()); //使用中のキャラ取得 SqliteDatabase sqlDB = new SqliteDatabase("UserStatus.db"); string selectQuery = "select * from Character where select_flg = 1"; DataTable characterTable = sqlDB.ExecuteQuery(selectQuery); if (characterTable.Rows.Count >= 1) { charaNumber = (int) characterTable.Rows[0]["id"]; GameObject selectCharaPrefab = Resources.Load <GameObject> ("Prefab/Chara/Character" + charaNumber); chara = GameObject.Instantiate(selectCharaPrefab) as GameObject; chara.transform.localPosition = new Vector3(-2.24f, 11.56f, -1.0f); chara.name = "Character"; //スキル設定 skillNumber = (int) characterTable.Rows[0]["skill_number"]; skillName = (string) characterTable.Rows[0]["skill_name"]; skillType = (int) characterTable.Rows[0]["skill_type"]; skillLevel = (int) characterTable.Rows[0]["get_count"]; addSkillCount(); //キャラを落ちないように設定 chara.GetComponent<Rigidbody2D>().isKinematic = true; sr = chara.GetComponent<SpriteRenderer>(); charaDefaultPositionX = chara.transform.localPosition.x; StartCoroutine(gameStart()); } boosterEffect = (GameObject)Resources.Load("Effect/Booster"); //CameraScriptを取得 cameraScript = (CameraScript) cameraObject.GetComponent<CameraScript>(); }
IEnumerator gameCleared() { SqliteDatabase sqlDB = new SqliteDatabase("UserStatus.db"); string selectQuery = "select * from Stage where stage_number = " + stageNumber + " and difficulty = " + difficultyType; DataTable stageTable = sqlDB.ExecuteQuery(selectQuery); bool highScoreFlg = false; if (stageTable.Rows.Count == 0) { highScoreFlg = true; } else { int beforeScore = (int)stageTable.Rows[0]["score"]; if (beforeScore < point) { highScoreFlg = true; } } //panelの表示 GameObject panelPrefab = (GameObject)Instantiate(panelObject); panelPrefab.GetComponent<Image>().color = new Color(255f, 255f, 255f, 0); panelPrefab.transform.SetParent (canvasObject.transform, false); yield return new WaitForSeconds(0.2f); //ダイアログの表示 GameObject dialogPrefab = (GameObject)Instantiate(endDialogObject); float scaleX = dialogPrefab.transform.localScale.x; float scaleY = dialogPrefab.transform.localScale.y; float scaleZ = dialogPrefab.transform.localScale.z; dialogPrefab.transform.localScale = new Vector3((scaleX / 3), (scaleY / 3), (scaleZ / 3)); dialogPrefab.transform.SetParent (canvasObject.transform, false); iTween.ScaleTo(dialogPrefab, iTween.Hash("x", 1, "y", 1, "z", 1, "time", 0.3f)); yield return new WaitForSeconds(0.2f); //タイトルの表示 GameObject endTitlePrefab = (GameObject)Instantiate(endTitleObject); scaleX = endTitlePrefab.transform.localScale.x; scaleY = endTitlePrefab.transform.localScale.y; scaleZ = endTitlePrefab.transform.localScale.z; endTitlePrefab.transform.localScale = new Vector3((scaleX / 3), (scaleY / 3), (scaleZ / 3)); endTitlePrefab.transform.SetParent (canvasObject.transform, false); iTween.ScaleTo(endTitlePrefab, iTween.Hash("x", scaleX, "y", scaleY, "z", scaleZ, "time", 0.3f)); yield return new WaitForSeconds(0.2f); //スコアの表示 GameObject scorePrefab = (GameObject)Instantiate(endScoreObject); scaleX = scorePrefab.transform.localScale.x; scaleY = scorePrefab.transform.localScale.y; scaleZ = scorePrefab.transform.localScale.z; scorePrefab.transform.localScale = new Vector3((scaleX / 3), (scaleY / 3), (scaleZ / 3)); scorePrefab.transform.SetParent (canvasObject.transform, false); //スコアのテキストを変更 GameObject scoreText = scorePrefab.transform.FindChild("ScoreText").gameObject; scoreText.GetComponent<Text>().text = point.ToString(); iTween.ScaleTo(scorePrefab, iTween.Hash("x", 1, "y", 1, "z", 1, "time", 0.3f)); yield return new WaitForSeconds(0.2f); //ハイスコアの表示 if (highScoreFlg) { GameObject highScorePrefab = (GameObject)Instantiate(endHighScoreObject); scaleX = highScorePrefab.transform.localScale.x; scaleY = highScorePrefab.transform.localScale.y; scaleZ = highScorePrefab.transform.localScale.z; highScorePrefab.transform.localScale = new Vector3((scaleX / 3), (scaleY / 3), (scaleZ / 3)); highScorePrefab.transform.SetParent (canvasObject.transform, false); iTween.ScaleTo(highScorePrefab, iTween.Hash("x", scaleX, "y", scaleY, "z", scaleZ, "time", 0.3f)); yield return new WaitForSeconds(0.2f); } //コインの表示 GameObject coinPrefab = (GameObject)Instantiate(endCoinObject); scaleX = coinPrefab.transform.localScale.x; scaleY = coinPrefab.transform.localScale.y; scaleZ = coinPrefab.transform.localScale.z; coinPrefab.transform.localScale = new Vector3((scaleX / 3), (scaleY / 3), (scaleZ / 3)); coinPrefab.transform.SetParent (canvasObject.transform, false); iTween.ScaleTo(coinPrefab, iTween.Hash("x", 1, "y", 1, "z", 1, "time", 0.3f)); yield return new WaitForSeconds(0.2f); //コインテキストの表示 Text coinTextPrefab = (Text)Instantiate(endCoinText); coinTextPrefab.transform.SetParent (canvasObject.transform, false); //コインの計算 int coin = (point / 1000); coinTextPrefab.text = coin.ToString(); yield return new WaitForSeconds(0.2f); //ボタンの表示 GameObject endButtonPrefab = (GameObject)Instantiate(endMenuButton); scaleX = endButtonPrefab.transform.localScale.x; scaleY = endButtonPrefab.transform.localScale.y; scaleZ = endButtonPrefab.transform.localScale.z; endButtonPrefab.transform.localScale = new Vector3((scaleX / 3), (scaleY / 3), (scaleZ / 3)); endButtonPrefab.transform.SetParent (canvasObject.transform, false); iTween.ScaleTo(endButtonPrefab, iTween.Hash("x", 1, "y", 1, "z", 1, "time", 0.3f)); yield return new WaitForSeconds(0.2f); endButtonPrefab = (GameObject)Instantiate(endRetryButton); scaleX = endButtonPrefab.transform.localScale.x; scaleY = endButtonPrefab.transform.localScale.y; scaleZ = endButtonPrefab.transform.localScale.z; endButtonPrefab.transform.localScale = new Vector3((scaleX / 3), (scaleY / 3), (scaleZ / 3)); endButtonPrefab.transform.SetParent (canvasObject.transform, false); iTween.ScaleTo(endButtonPrefab, iTween.Hash("x", 1, "y", 1, "z", 1, "time", 0.3f)); yield return new WaitForSeconds(0.2f); string query; //インサート if (stageTable.Rows.Count == 0) { query = "insert into Stage(stage_number, difficulty, star, remaining_time, remaining_hp, score, created, updated) values(" + stageNumber + "," + difficultyType + ",0,0,0," + point + ",datetime(),datetime())"; sqlDB.ExecuteNonQuery(query); //アップデート } else { int stageID = (int)stageTable.Rows[0]["id"]; if (highScoreFlg) { query = "update Stage set star=0, remaining_time=0, remaining_hp=0, score=" + point + ",updated=dateTime() where id=" + stageID; sqlDB.ExecuteNonQuery(query); } } //お金アップデート query = "update UserStatus set money = (money + " + coin + ") where id = 1"; sqlDB.ExecuteNonQuery(query); /* int clearTime = cd; //GameObjectを生成、生成したオブジェクトを変数に代入 GameObject panelPrefab = (GameObject)Instantiate(panelObject); panelPrefab.GetComponent<Image>().color = new Color(255f, 255f, 255f, 0); //Canvasの子要素として登録する panelPrefab.transform.SetParent (canvasObject.transform, false); yield return new WaitForSeconds(0.2f); //ダイアログの表示 GameObject clearDialogPrefab = (GameObject)Instantiate(clearDialogObject); float scaleX = clearDialogPrefab.transform.localScale.x; float scaleY = clearDialogPrefab.transform.localScale.y; float scaleZ = clearDialogPrefab.transform.localScale.z; clearDialogPrefab.transform.localScale = new Vector3((scaleX / 3), (scaleY / 3), (scaleZ / 3)); //Canvasの子要素として登録する clearDialogPrefab.transform.SetParent (canvasObject.transform, false); iTween.ScaleTo(clearDialogPrefab, iTween.Hash("x", 1, "y", 1, "z", 1, "time", 0.3f)); yield return new WaitForSeconds(0.2f); //Complete GameObject completePrefab = (GameObject)Instantiate(completeObject); scaleX = completePrefab.transform.localScale.x; scaleY = completePrefab.transform.localScale.y; scaleZ = completePrefab.transform.localScale.z; completePrefab.transform.localScale = new Vector3((scaleX / 3), (scaleY / 3), (scaleZ / 3)); //Canvasの子要素として登録する completePrefab.transform.SetParent (canvasObject.transform, false); if (completePrefab.GetComponent<Text>() == null) { iTween.ScaleTo(completePrefab, iTween.Hash("x", 1, "y", 1, "z", 1, "time", 0.3f)); } else { iTween.ScaleTo(completePrefab, iTween.Hash("x", 0.3f, "y", 0.3f, "z", 0.3f, "time", 0.3f)); } yield return new WaitForSeconds(0.2f); //star //星の数を計算する float decPer = (clearTime * 0.5f) / (limitTime * 1.0f); float decHpPer = (hp * 0.5f) / 2 * decPer; float totalPer = decPer + decHpPer; Debug.Log("DEC PER:" + decPer); Debug.Log("DEC HP PER:" + decHpPer); Debug.Log("TOTAL PER:" + totalPer); //星の数 int starCount = 1; if (totalPer >= 0.49f) { starCount = 3; } else if (totalPer >= 0.35f) { starCount = 2; } int score = (int) Math.Ceiling(totalPer * 10000); int coin = (int) Math.Ceiling(totalPer * 10); Debug.Log("COIN:" + coin); //セーブ SqliteDatabase sqlDB = new SqliteDatabase("UserStatus.db"); string selectQuery = "select * from Stage where stage_number = " + stageNumber + " and difficulty = " + difficultyType; DataTable stageTable = sqlDB.ExecuteQuery(selectQuery); string query; //インサート if (stageTable.Rows.Count == 0) { query = "insert into Stage(stage_number, difficulty, star, remaining_time, remaining_hp, score, created, updated) values(" + stageNumber + "," + difficultyType + "," + starCount + "," + clearTime + "," + hp + "," + score + ",datetime(),datetime())"; sqlDB.ExecuteNonQuery(query); //アップデート } else { int beforeScore = (int)stageTable.Rows[0]["score"]; int stageID = (int)stageTable.Rows[0]["id"]; if (beforeScore < score) { query = "update Stage set star=" + starCount + ", remaining_time=" + hp +", remaining_hp=" + hp + ", score=" + score + ",updated=dateTime() where id=" + stageID; sqlDB.ExecuteNonQuery(query); } } //お金アップデート query = "update UserStatus set money = (money + " + coin + ") where id = 1"; sqlDB.ExecuteNonQuery(query); //結果ダイアログ GameObject resultPrefab = (GameObject)Instantiate(resultDialogObject); scaleX = resultPrefab.transform.localScale.x; scaleY = resultPrefab.transform.localScale.y; scaleZ = resultPrefab.transform.localScale.z; resultPrefab.transform.localScale = new Vector3((scaleX / 3), (scaleY / 3), (scaleZ / 3)); //Canvasの子要素として登録する resultPrefab.transform.SetParent (canvasObject.transform, false); GameObject decTimeChild1 = resultPrefab.transform.FindChild("time_number_1").gameObject; GameObject decTimeChild2 = resultPrefab.transform.FindChild("time_number_2").gameObject; GameObject decTimeChild3 = resultPrefab.transform.FindChild("time_number_3").gameObject; String stTime = clearTime.ToString(); String number1 = "0"; String number2 = "0"; String number3 = "0"; if (stTime.Length >= 3) { number1 = stTime.Substring(0, 1); number2 = stTime.Substring(1, 1); number3 = stTime.Substring(2, 1); } else if (stTime.Length >= 2) { number2 = stTime.Substring(0, 1); number3 = stTime.Substring(1, 1); } else { number3 = stTime.Substring(0, 1); } decTimeChild1.GetComponent<Image>().sprite = Resources.Load <Sprite> ("Prefab/Number/" + "number4_red_" + number1); decTimeChild2.GetComponent<Image>().sprite = Resources.Load <Sprite> ("Prefab/Number/" + "number4_red_" + number2); decTimeChild3.GetComponent<Image>().sprite = Resources.Load <Sprite> ("Prefab/Number/" + "number4_red_" + number3); //hp設定 GameObject decHpChild = resultPrefab.transform.FindChild("hp_number_1").gameObject; String stHp = hp.ToString(); decHpChild.GetComponent<Image>().sprite = Resources.Load <Sprite> ("Prefab/Number/" + "number4_red_" + stHp); //coin設定 GameObject coinChild1 = resultPrefab.transform.FindChild("coin_number_1").gameObject; GameObject coinChild2 = resultPrefab.transform.FindChild("coin_number_2").gameObject; String stCoin = coin.ToString(); String coin1= "0"; String coin2= "0"; if (stCoin.Length >= 2) { coin2 = stCoin.Substring(0, 1); coin1 = stCoin.Substring(1, 1); } else { coin1 = stCoin.Substring(0, 1); } coinChild1.GetComponent<Image>().sprite = Resources.Load <Sprite> ("Prefab/Number/" + "number4_red_" + coin1); coinChild2.GetComponent<Image>().sprite = Resources.Load <Sprite> ("Prefab/Number/" + "number4_red_" + coin2); iTween.ScaleTo(resultPrefab, iTween.Hash("x", 1, "y", 1, "z", 1, "time", 0.3f)); yield return new WaitForSeconds(0.2f); GameObject starPrefab; for (int i = 0; i < starObject.Length; i++) { starPrefab = (GameObject)Instantiate(starObject[i]); scaleX = starPrefab.transform.localScale.x; scaleY = starPrefab.transform.localScale.y; scaleZ = starPrefab.transform.localScale.z; starPrefab.transform.localScale = new Vector3((scaleX / 3), (scaleY / 3), (scaleZ / 3)); if (i == 1 && totalPer <= 0.35f) { starPrefab.GetComponent<Image>().sprite = Resources.Load <Sprite> ("Prefab/item_star_lost"); } else if (i == 2 && totalPer <= 0.49f) { starPrefab.GetComponent<Image>().sprite = Resources.Load <Sprite> ("Prefab/item_star_lost"); } //Canvasの子要素として登録する starPrefab.transform.SetParent (canvasObject.transform, false); // 4秒かけて、y軸を3倍に拡大 iTween.ScaleTo(starPrefab, iTween.Hash("x", 1, "y", 1, "z", 1, "time", 0.3f)); yield return new WaitForSeconds(0.2f); } //button GameObject endButtonPrefab; for (int i = 0; i < endButtonObject.Length; i++) { endButtonPrefab = (GameObject)Instantiate(endButtonObject[i]); scaleX = endButtonPrefab.transform.localScale.x; scaleY = endButtonPrefab.transform.localScale.y; scaleZ = endButtonPrefab.transform.localScale.z; endButtonPrefab.transform.localScale = new Vector3((scaleX / 3), (scaleY / 3), (scaleZ / 3)); //Canvasの子要素として登録する endButtonPrefab.transform.SetParent (canvasObject.transform, false); // 4秒かけて、y軸を3倍に拡大 iTween.ScaleTo(endButtonPrefab, iTween.Hash("x", 1, "y", 1, "z", 1, "time", 0.3f)); yield return new WaitForSeconds(0.2f); } */ yield return new WaitForSeconds(0.2f); }
/// <summary> /// Opens the MBTiles database file located at Filepath. /// </summary> private void Open () { if (db != null) db.Close (); db = new SqliteDatabase (); db.Open (filepath); DataTable dt = db.ExecuteQuery ("SELECT * FROM metadata"); #if DEBUG_LOG string dbg = String.Empty; foreach (DataRow dbgRow in dt.Rows) { foreach (string col in dt.Columns) { dbg += "\t" + dbgRow[col]; } dbg += "\n"; } Debug.Log("DEBUG: MBTilesLayer.Update: metadata:\n" + dbg); #endif metadataRowNameLookedFor = "version"; DataRow row = dt.Rows.Find (metadataMatchPredicate); if (row == null) { db.Close (); throw new SqliteException ("missing 'version' in metadata"); } version = row ["value"] as string; switch (version) { case "1.0.0": metadataRowNameLookedFor = "bounds"; row = dt.Rows.Find (metadataMatchPredicate); if (row != null) { string[] tokens = (row ["value"] as string).Split (new Char[] { ',' }); bounds = new Rect (Single.Parse (tokens [0]), Single.Parse (tokens [1]), Single.Parse (tokens [2]), Single.Parse (tokens [3])); } metadataRowNameLookedFor = "center"; row = dt.Rows.Find (metadataMatchPredicate); if (row != null) { string[] tokens = (row ["value"] as string).Split (new Char[] { ',' }); center = new Vector3 (Single.Parse (tokens [0]), Single.Parse (tokens [1]), Single.Parse (tokens [2])); } metadataRowNameLookedFor = "minzoom"; row = dt.Rows.Find (metadataMatchPredicate); if (row != null) { minZoom = Single.Parse (row ["value"] as string); } metadataRowNameLookedFor = "maxzoom"; row = dt.Rows.Find (metadataMatchPredicate); if (row != null) { maxZoom = Single.Parse (row ["value"] as string); } metadataRowNameLookedFor = "name"; row = dt.Rows.Find (metadataMatchPredicate); if (row != null) { _name = row ["value"] as string; } metadataRowNameLookedFor = "description"; row = dt.Rows.Find (metadataMatchPredicate); if (row != null) { description = row ["value"] as string; } metadataRowNameLookedFor = "attribution"; row = dt.Rows.Find (metadataMatchPredicate); if (row != null) { attribution = row ["value"] as string; } metadataRowNameLookedFor = "template"; row = dt.Rows.Find (metadataMatchPredicate); if (row != null) { template = row ["value"] as string; } break; default: throw new SqliteException ("unsupported SQLite version: " + version); } isReadyToBeQueried = true; }
private void charaInit() { SqliteDatabase sqlDB = new SqliteDatabase("UserStatus.db"); //キャラクター系設定 string selectQuery = "select * from Character where get_flg = 1"; DataTable characterTable = sqlDB.ExecuteQuery(selectQuery); //現在選択中のキャラ for (int i = 0; i < characterTable.Rows.Count; i++) { if ((int)characterTable.Rows[i]["select_flg"] == 1) { charaNumber = (int) characterTable.Rows[i]["id"]; //スキル設定 skillNumber = (int) characterTable.Rows[i]["skill_number"]; skillName = (string) characterTable.Rows[i]["skill_name"]; skillType = (int) characterTable.Rows[i]["skill_type"]; skillLevel = (int) characterTable.Rows[i]["get_count"]; addSkillCount(); break; } } //キャラ画像設定 charaHeadImage.GetComponent<Image>().sprite = Resources.Load <Sprite> ("Image/Character/Chara" + charaNumber + "/head"); }
// Use this for initialization void Start() { StartCoroutine(viewStart()); //使用中のキャラ取得 SqliteDatabase sqlDB = new SqliteDatabase("UserStatus.db"); string selectQuery = "select * from Character where select_flg = 1"; DataTable characterTable = sqlDB.ExecuteQuery(selectQuery); if (characterTable.Rows.Count >= 1) { charaNumber = (int) characterTable.Rows[0]["id"]; charaHeadImage.GetComponent<Image>().sprite = Resources.Load <Sprite> ("Image/Character/Chara" + charaNumber + "/head"); GameObject selectCharaPrefab = Resources.Load <GameObject> ("Prefab/Chara/Character" + charaNumber); chara = GameObject.Instantiate(selectCharaPrefab) as GameObject; chara.transform.localPosition = new Vector3(-1.24f, 11.56f, -1.0f); chara.name = "Character"; //スキル設定 skillNumber = (int) characterTable.Rows[0]["skill_number"]; skillName = (string) characterTable.Rows[0]["skill_name"]; skillType = (int) characterTable.Rows[0]["skill_type"]; skillLevel = (int) characterTable.Rows[0]["get_count"]; addSkillCount(); //キャラを落ちないように設定 chara.GetComponent<Rigidbody2D>().isKinematic = true; // プレハブを取得 floorPrefab = (GameObject)Resources.Load("Prefab/FloorCube"); bombPrefab = (GameObject)Resources.Load("Prefab/Bomb"); jumpBombPrefab = (GameObject)Resources.Load("Prefab/JumpBomb"); moveFloorPrefab = (GameObject)Resources.Load("Prefab/FloorMove"); rockPrefab = (GameObject)Resources.Load("Prefab/FloorRock"); wallPrefab = (GameObject)Resources.Load("Prefab/FloorWall"); goalStarPrefab = (GameObject)Resources.Load("Prefab/GoalStar"); sr = chara.GetComponent<SpriteRenderer>(); charaDefaultPositionX = chara.transform.localPosition.x; StartCoroutine(gameInit()); } }