Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Data.SQLite;
- using System.Data;
- namespace Oregon_Trail.Classes
- {
- public static class db
- {
- public static readonly SQLiteConnection dbCon = new SQLiteConnection("Data Source=oregontrail.sqlite; version=3");
- public static DataSet OTDS = new DataSet("OTDS");
- public static async void LoadData()
- {
- SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter();
- await Task.Factory.StartNew(() =>
- {
- bool isStarted;
- string sql = "SELECT * FROM gamestate";
- string table = "loadstuff";
- dataAdapter = new SQLiteDataAdapter(sql, dbCon);
- dataAdapter.Fill(OTDS, table);
- for (int i = 0; i < OTDS.Tables[3].Rows.Count; i++)
- {
- string gamename = OTDS.Tables[3].Rows[i]["gamenum"].ToString();
- switch (gamename)
- {
- case "game1":
- {
- int isstarted = int.Parse(OTDS.Tables[3].Rows[i]["isStarted"].ToString());
- if (isstarted == 0)
- {
- isStarted = false;
- Game.EnabledGames[0] = isStarted;
- }
- else if (isstarted == 1)
- {
- isStarted = true;
- Game.EnabledGames[0] = isStarted;
- }
- break;
- }
- case "game2":
- {
- int isstarted = int.Parse(OTDS.Tables[3].Rows[i]["isStarted"].ToString());
- if (isstarted == 0)
- {
- isStarted = false;
- Game.EnabledGames[1] = isStarted;
- }
- else if (isstarted == 1)
- {
- isStarted = true;
- Game.EnabledGames[1] = isStarted;
- }
- break;
- }
- case "game3":
- {
- int isstarted = int.Parse(OTDS.Tables[3].Rows[i]["isStarted"].ToString());
- if (isstarted == 0)
- {
- isStarted = false;
- Game.EnabledGames[2] = isStarted;
- }
- else if (isstarted == 1)
- {
- isStarted = true;
- Game.EnabledGames[2] = isStarted;
- }
- break;
- }
- }
- }
- });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement