-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Atualização no Banco de Dados - Funcional mas Não Completa
Já existe a opção de salvar a tela, porém não funciona ao desligar e ligar o jogo.
- Loading branch information
1 parent
f1a02ec
commit 246d0d6
Showing
61 changed files
with
728 additions
and
160 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
using System.Data; | ||
using Mono.Data.Sqlite; | ||
using System.IO; | ||
|
||
public class botaoSalvar : MonoBehaviour{ | ||
// Start is called before the first frame update | ||
void Start(){ | ||
|
||
} | ||
|
||
// Update is called once per frame | ||
public void salvarJogo(int id_da_fase){ | ||
string connection = "URI=file:"+Application.persistentDataPath+"/BD_Proj_Memorias"; //Adicionando à variável "connection" o caminho para o nosso Banco de Dados "BD_Proj_Memorias" | ||
IDbConnection dbcon = new SqliteConnection(connection); //Comunicando com o nosso banco de dados cujo caminho está sendo passado como parâmetro pela variável "connection" | ||
dbcon.Open(); //Abrindo a conexão com o banco de dados | ||
|
||
IDbCommand cmnd = dbcon.CreateCommand(); | ||
cmnd.CommandText = "INSERT INTO ultimo_save (id, tela_salva) VALUES ("+SQLite.id_do_save+", "+id_da_fase+")"; | ||
cmnd.ExecuteNonQuery(); | ||
|
||
//Fechando a conexão | ||
IDbCommand cmnd_read = dbcon.CreateCommand(); | ||
IDataReader reader; | ||
|
||
string query = "SELECT * FROM ultimo_save"; | ||
cmnd_read.CommandText = query; | ||
reader = cmnd_read.ExecuteReader(); | ||
|
||
while(reader.Read()){ | ||
Debug.Log("id: " + reader[0].ToString()); | ||
Debug.Log("última tela salva: " + reader[1].ToString()); | ||
} | ||
SQLite.id_do_save = SQLite.id_do_save + 1; | ||
dbcon.Close(); | ||
|
||
} | ||
|
||
public void limparTabela(){ | ||
string connection = "URI=file:"+Application.persistentDataPath+"/BD_Proj_Memorias"; //Adicionando à variável "connection" o caminho para o nosso Banco de Dados "BD_Proj_Memorias" | ||
IDbConnection dbcon = new SqliteConnection(connection); //Comunicando com o nosso banco de dados cujo caminho está sendo passado como parâmetro pela variável "connection" | ||
dbcon.Open(); //Abrindo a conexão com o banco de dados | ||
|
||
IDbCommand cmnd = dbcon.CreateCommand(); | ||
cmnd.CommandText = "DELETE FROM ultimo_save"; | ||
cmnd.ExecuteNonQuery(); | ||
|
||
IDbCommand cmnd2 = dbcon.CreateCommand(); | ||
cmnd2.CommandText = "VACUUM"; | ||
cmnd2.ExecuteNonQuery(); | ||
|
||
IDbCommand cmnd_read = dbcon.CreateCommand(); | ||
IDataReader reader; | ||
|
||
string query = "SELECT * FROM ultimo_save"; | ||
cmnd_read.CommandText = query; | ||
reader = cmnd_read.ExecuteReader(); | ||
|
||
while(reader.Read()){ | ||
Debug.Log("id: " + reader[0].ToString()); | ||
Debug.Log("última tela salva: " + reader[1].ToString()); | ||
} | ||
|
||
dbcon.Close(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
Oops, something went wrong.