// -------------------- Verificar a sala --------------------- public void Metodo_Selecionar_Sala() { Banco_Conexao conexao = new Banco_Conexao(); Objeto_Player player = new Objeto_Player(); InputField txt_codigo = GameObject.Find("txt_codigo").GetComponent <InputField>(); string codigo = txt_codigo.text; try{ conexao.conectarBanco(); conexao.Sql = "SELECT * FROM TB_SALA WHERE SALA_CODIGO='" + codigo + "';"; comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); dados = comando.ExecuteReader(); if (dados.HasRows) { while (dados.Read()) { player.CodSala = System.Convert.ToInt64(dados["SALA_ID"]); player.NomeSala = dados["SALA_NOME"].ToString(); } dados.Close(); comando.Dispose(); pnl_codigo.SetActive(false); pnl_cadastro_info.SetActive(true); Text sala = GameObject.Find("txt_sala_info").GetComponent <Text>(); sala.text = player.NomeSala; } else { dados.Close(); comando.Dispose(); StartCoroutine(Corrotina_Status_Cadastro("txt_status_codigo")); } conexao.fecharBanco(); } catch (MySqlException e) { dados.Close(); comando.Dispose(); conexao.fecharBanco(); print(e); //reconexao.realizarReconexao(); } }
public void Metodo_Adicionar_Pontos_Licao3_Atv1() { Banco_Conexao conexao = new Banco_Conexao(); Objeto_Player player = new Objeto_Player(); try { //PEGA NIVEL ATUAL DA ATIVIDADE conexao.conectarBanco(); conexao.Sql = "SELECT NIVEL_ATIVIDADE FROM TB_NIVEL_ATIVIDADE WHERE COD_ESTUDANTE=" + player.Cpf + " AND COD_ATIVIDADE=3"; comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); dados = comando.ExecuteReader(); int n = 0; if (dados.HasRows) { while (dados.Read()) { n = (int)dados["NIVEL_ATIVIDADE"]; print(n); } } dados.Close(); comando.Dispose(); //ALMENTA UM NIVEL conexao.Sql = "UPDATE TB_NIVEL_ATIVIDADE SET NIVEL_ATIVIDADE=" + (n + 1) + " WHERE COD_ESTUDANTE=" + player.Cpf + " AND COD_ATIVIDADE=3"; comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); comando.ExecuteNonQuery(); conexao.fecharBanco(); } catch { } }
void Start() { //INICIALIZA AS CLASSES 'CONEXAO' E 'PLAYER' Banco_Conexao conexao = new Banco_Conexao(); Objeto_Player player = new Objeto_Player(); posicoes_eventos.Add(new Vector3(-3f, 0f, 0)); posicoes_eventos.Add(new Vector3(53f, -56f, 0)); posicoes_eventos.Add(new Vector3(-3f, -112f, 0)); posicoes_eventos.Add(new Vector3(-59f, -56f, 0)); try { conexao.conectarBanco(); //COMANDO SQL NIVEL 2 conexao.Sql = "SELECT NIVEL_ATIVIDADE FROM TB_NIVEL_ATIVIDADE WHERE COD_ESTUDANTE=" + player.Cpf + " AND COD_ATIVIDADE=3"; comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); dados = comando.ExecuteReader(); if (dados.HasRows) { while (dados.Read()) { int n = (int)dados["NIVEL_ATIVIDADE"]; if (n <= 10) { nivel = 1; nDicas = 4; tempo = 300; } else if (n <= 20) { nivel = 2; nDicas = 3; tempo = 250; } else { nivel = 3; nDicas = 2; tempo = 200; } } } dados.Close(); comando.Dispose(); tempo_correndo = true; //CARREGANDO TODOS OS PREFABS DE EVENTOS for (int i = 0; i < Resources.LoadAll <GameObject>("L3_A1/Eventos/").Length; i++) { eventos.Add(Resources.Load <GameObject>("L3_A1/Eventos/evento_" + (i + 1))); } //GERANDO TODOS OS EVENTOS NAS POSICOES POSSIVEIS int rNEvento, rNPosicao; int nPosicoes = posicoes_eventos.ToArray().Length; for (int i = 0; i < nPosicoes; i++) { rNEvento = Random.Range(0, eventos.ToArray().Length); rNPosicao = Random.Range(0, posicoes_eventos.ToArray().Length); Instantiate(eventos[rNEvento], posicoes_eventos[rNPosicao], Quaternion.identity); mapa_eventos.Add(posicoes_eventos[rNPosicao], eventos[rNEvento]); eventos.RemoveAt(rNEvento); posicoes_eventos.RemoveAt(rNPosicao); } //PEGANDO TODAS AS MOEDAS spots_moedas = GetChildren(spots_moedas_object); //GERANDO MOEDAS int rNMoeda; for (int i = 0; i < nDicas; i++) { rNMoeda = Random.Range(0, spots_moedas.ToArray().Length); spots_moedas[rNMoeda].SetActive(true); spots_moedas.RemoveAt(rNMoeda); } int rNHotel = Random.Range(0, 4); switch (rNHotel) { case 0: dicas.Add("The Hotel is close to a " + mapa_eventos[new Vector3(-3f, 0f, 0)].GetComponent <Classe_Evento_Licao3_Atv1>().nome); dicas.Add("The Hotel is close to a " + mapa_eventos[new Vector3(53f, -56f, 0)].GetComponent <Classe_Evento_Licao3_Atv1>().nome); dicas.Add("The Hotel is on the right side of the neighborhood"); dicas.Add("The Hotel is on top of the neighborhood"); hotel_1.GetComponent <Classe_Hotel_Licao3_Atv1>().hotel_certo = true; break; case 1: dicas.Add("The Hotel is close to a " + mapa_eventos[new Vector3(-3f, 0f, 0)].GetComponent <Classe_Evento_Licao3_Atv1>().nome); dicas.Add("The Hotel is close to a " + mapa_eventos[new Vector3(-59f, -56f, 0)].GetComponent <Classe_Evento_Licao3_Atv1>().nome); dicas.Add("The Hotel is on the left side of the neighborhood"); dicas.Add("The Hotel is on top of the neighborhood"); hotel_2.GetComponent <Classe_Hotel_Licao3_Atv1>().hotel_certo = true; break; case 2: dicas.Add("The Hotel is close to a " + mapa_eventos[new Vector3(-59f, -56f, 0)].GetComponent <Classe_Evento_Licao3_Atv1>().nome); dicas.Add("The Hotel is close to a " + mapa_eventos[new Vector3(-3f, -112f, 0)].GetComponent <Classe_Evento_Licao3_Atv1>().nome); dicas.Add("The Hotel is on the left side of the neighborhood"); dicas.Add("The Hotel is at the bottom of the neighborhood"); hotel_3.GetComponent <Classe_Hotel_Licao3_Atv1>().hotel_certo = true; break; case 3: dicas.Add("The Hotel is close to a " + mapa_eventos[new Vector3(53f, -56f, 0)].GetComponent <Classe_Evento_Licao3_Atv1>().nome); dicas.Add("The Hotel is close to a " + mapa_eventos[new Vector3(-3f, -112f, 0)].GetComponent <Classe_Evento_Licao3_Atv1>().nome); dicas.Add("The Hotel is on the right side of the neighborhood"); dicas.Add("The Hotel is at the bottom of the neighborhood"); hotel_4.GetComponent <Classe_Hotel_Licao3_Atv1>().hotel_certo = true; break; } } catch (MySqlException e) { print(e); } }
public void Metodo_Logar() { InputField txt_login, txt_senha; txt_login = GameObject.Find("txt_login").GetComponent <InputField>(); txt_senha = GameObject.Find("txt_senha").GetComponent <InputField>(); Banco_Conexao conexao = new Banco_Conexao(); Objeto_Player player = new Objeto_Player(); MySqlCommand comando; MySqlDataReader dados; try{ conexao.conectarBanco(); /* --------------------------------- ESTUDANTE --------------------------------- */ conexao.Sql = "SELECT * FROM TB_USER_ESTUDANTE WHERE USER_ESTUDANTE_LOGIN='******' AND USER_ESTUDANTE_SENHA=md5('" + txt_senha.text + "');"; comando = new MySqlCommand("set net_write_timeout=99999; set net_read_timeout=99999", conexao.ConexaoBanco); comando.ExecuteNonQuery(); comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); dados = comando.ExecuteReader(); if (dados.HasRows) { while (dados.Read()) { player.Cpf = System.Convert.ToInt64(dados["USER_ESTUDANTE_CPF"]); player.Nome = System.Convert.ToString(dados["USER_ESTUDANTE_NOME"]); player.Email = System.Convert.ToString(dados["USER_ESTUDANTE_EMAIL"]); player.Nivel = System.Convert.ToInt32(dados["USER_ESTUDANTE_NIVEL"]); player.Ptotais = System.Convert.ToInt32(dados["USER_ESTUDANTE_PTOTAIS"]); player.Psemestre = System.Convert.ToInt32(dados["USER_ESTUDANTE_PSEMESTRE"]); player.Patuais = System.Convert.ToInt32(dados["USER_ESTUDANTE_PATUAIS"]); player.Pele = System.Convert.ToString(dados["USER_ESTUDANTE_PELE"]); player.Roupa = System.Convert.ToString(dados["USER_ESTUDANTE_ROUPA"]); player.Cabelo = System.Convert.ToString(dados["USER_ESTUDANTE_CABELO"]); player.Acessorio = System.Convert.ToString(dados["USER_ESTUDANTE_ACESSORIO"]); player.TipoLogin = "******"; pnl_loading.SetActive(true); UnityEngine.SceneManagement.SceneManager.LoadScene("telaPrincipal"); } } else { dados.Close(); comando.Dispose(); /* --------------------------------- PROFESSOR --------------------------------- */ conexao.Sql = "SELECT * FROM TB_USER_PROFESSOR WHERE USER_PROFESSOR_LOGIN='******' AND USER_PROFESSOR_SENHA=md5('" + txt_senha.text + "');"; comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); dados = comando.ExecuteReader(); if (dados.HasRows) { while (dados.Read()) { player.Cpf = System.Convert.ToInt64(dados["USER_PROFESSOR_CPF"]); player.Nome = System.Convert.ToString(dados["USER_PROFESSOR_NOME"]); player.Email = System.Convert.ToString(dados["USER_PROFESSOR_EMAIL"]); player.Nivel = 0; player.Ptotais = 0; player.Psemestre = 0; player.Patuais = 0; player.Pele = null; player.Roupa = null; player.Cabelo = null; player.Acessorio = null; player.TipoLogin = "******"; } } else { dados.Close(); comando.Dispose(); /* --------------------------------- MONITOR --------------------------------- */ conexao.Sql = "SELECT * FROM TB_USER_MONITOR WHERE USER_MONITOR_LOGIN='******' AND USER_MONITOR_SENHA=md5('" + txt_senha.text + "');"; comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); dados = comando.ExecuteReader(); if (dados.HasRows) { while (dados.Read()) { player.Cpf = System.Convert.ToInt64(dados["USER_MONITOR_CPF"]); player.Nome = System.Convert.ToString(dados["USER_MONITOR_NOME"]); player.Email = System.Convert.ToString(dados["USER_MONITOR_EMAIL"]); player.Nivel = 0; player.Ptotais = 0; player.Psemestre = 0; player.Patuais = 0; player.Pele = null; player.Roupa = null; player.Cabelo = null; player.Acessorio = null; player.TipoLogin = "******"; } } else { dados.Close(); comando.Dispose(); /* --------------------------------- ADM --------------------------------- */ conexao.Sql = "SELECT * FROM TB_USER_ADM WHERE USER_ADM_LOGIN='******' AND USER_ADM_SENHA=md5('" + txt_senha.text + "');"; comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); dados = comando.ExecuteReader(); if (dados.HasRows) { while (dados.Read()) { player.Cpf = System.Convert.ToInt64(dados["USER_ADM_CPF"]); player.Nome = System.Convert.ToString(dados["USER_ADM_NOME"]); player.Email = System.Convert.ToString(dados["USER_ADM_EMAIL"]); player.Nivel = 0; player.Ptotais = 0; player.Psemestre = 0; player.Patuais = 0; player.Pele = null; player.Roupa = null; player.Cabelo = null; player.Acessorio = null; player.TipoLogin = "******"; } } else { dados.Close(); comando.Dispose(); StartCoroutine(Corrotina_Status_Login()); player.TipoLogin = "******"; } } } } conexao.fecharBanco(); }catch (MySqlException e) { pnl_erro.SetActive(true); txt_erro.text = e.ToString(); Debug.Log(e.ToString()); //reconexao.realizarReconexao(); } }
void Start() { //INICIALIZA AS CLASSES 'CONEXAO' E 'PLAYER' Banco_Conexao conexao = new Banco_Conexao(); Objeto_Player player = new Objeto_Player(); //DEFINE TODAS AS POSIÇÕES POSSIVEIS E SUA CONSECUTIVA POSIÇÃO posicoes_possiveis[0, 0] = "CIMA"; posicoes_possiveis[0, 1] = new Vector3(-25, 3, 0); posicoes_possiveis[1, 0] = "CIMA"; posicoes_possiveis[1, 1] = new Vector3(-31, 3, 0); posicoes_possiveis[2, 0] = "CIMA"; posicoes_possiveis[2, 1] = new Vector3(-34, 3, 0); posicoes_possiveis[3, 0] = "BAIXO"; posicoes_possiveis[3, 1] = new Vector3(-35, 1, 0); posicoes_possiveis[4, 0] = "BAIXO"; posicoes_possiveis[4, 1] = new Vector3(-31, 1, 0); posicoes_possiveis[5, 0] = "BAIXO"; posicoes_possiveis[5, 1] = new Vector3(-26, 1, 0); //INDICA TODAS AS POSIÇÕES NA LISTAGEM 1 PARA SEREM TRABALHADAS posicoes1.Add(new Vector3(-25, 3, 0)); posicoes1.Add(new Vector3(-31, 3, 0)); posicoes1.Add(new Vector3(-34, 3, 0)); //INDICA TODAS AS POSIÇÕES NA LISTAGEM 2 PARA SEREM TRABALHADAS posicoes2.Add(new Vector3(-35, 1, 0)); posicoes2.Add(new Vector3(-31, 1, 0)); posicoes2.Add(new Vector3(-26, 1, 0)); //ADICIONA TODAS AS LISTAGEM DE POSIÇÕES PARA A LISTA FINAL posicoesNPC.Add(posicoes1); posicoesNPC.Add(posicoes2); //PEGA TODOS OS SPRITES Sprite[] resources = Resources.LoadAll <Sprite>("Sprites"); //COLOCANDO TODOS OS SPRITES EM SEUS DEVIDOS ARRAYS for (int i = 0; i < resources.Length; i++) { string[] sprite = resources[i].ToString().Split('_'); sprite[sprite.Length - 1] = sprite[sprite.Length - 1].Replace(" (UnityEngine.Sprite)", ""); string caminho = ""; switch (sprite[0]) { //PEGANDO BASES case "B": caminho = "Sprites/" + sprite[0] + "_" + sprite[1]; switch (sprite[1]) { case "M": if (sprite[2] == "1") { cima_m = Resources.LoadAll <Sprite>(caminho)[System.Convert.ToInt32(sprite[2])]; } if (sprite[2] == "10") { baixo_m = Resources.LoadAll <Sprite>(caminho)[System.Convert.ToInt32(sprite[2])]; } break; case "F": if (sprite[2] == "1") { cima_f = Resources.LoadAll <Sprite>(caminho)[System.Convert.ToInt32(sprite[2])]; } if (sprite[2] == "10") { baixo_f = Resources.LoadAll <Sprite>(caminho)[System.Convert.ToInt32(sprite[2])]; } break; } break; //PEGANDO CABELOS case "C": caminho = "Sprites/" + sprite[0] + "_" + sprite[1] + "_" + sprite[2]; switch (sprite[1]) { case "M": if (sprite[3] == "1") { cima_c_m.Add(Resources.LoadAll <Sprite>(caminho)[System.Convert.ToInt32(sprite[3])]); } if (sprite[3] == "10") { baixo_c_m.Add(Resources.LoadAll <Sprite>(caminho)[System.Convert.ToInt32(sprite[3])]); } break; case "F": if (sprite[3] == "1") { cima_c_f.Add(Resources.LoadAll <Sprite>(caminho)[System.Convert.ToInt32(sprite[3])]); } if (sprite[3] == "10") { baixo_c_f.Add(Resources.LoadAll <Sprite>(caminho)[System.Convert.ToInt32(sprite[3])]); } break; } break; //PEGANDO ROUPAS case "R": if (sprite[2] == "Escritorio") { caminho = "Sprites/" + sprite[0] + "_" + sprite[1] + "_" + sprite[2] + "_" + sprite[3]; switch (sprite[1]) { case "M": if (sprite[4] == "1") { cima_r_m.Add(Resources.LoadAll <Sprite>(caminho)[System.Convert.ToInt32(sprite[4])]); } if (sprite[4] == "10") { baixo_r_m.Add(Resources.LoadAll <Sprite>(caminho)[System.Convert.ToInt32(sprite[4])]); } break; case "F": if (sprite[4] == "1") { cima_r_f.Add(Resources.LoadAll <Sprite>(caminho)[System.Convert.ToInt32(sprite[4])]); } if (sprite[4] == "10") { baixo_r_f.Add(Resources.LoadAll <Sprite>(caminho)[System.Convert.ToInt32(sprite[4])]); } break; } } break; } } //CONTATO COM O BANCO DE DADOS try { conexao.conectarBanco(); //COMANDO SQL NIVEL 2 conexao.Sql = "SELECT NIVEL_ATIVIDADE FROM TB_NIVEL_ATIVIDADE WHERE COD_ESTUDANTE=" + player.Cpf + " AND COD_ATIVIDADE=1"; comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); dados = comando.ExecuteReader(); if (dados.HasRows) { while (dados.Read()) { int n = (int)dados["NIVEL_ATIVIDADE"]; if (n <= 10) { nivel = 1; } else if (n <= 20) { nivel = 2; } else { nivel = 3; } } } dados.Close(); comando.Dispose(); // PEGAR NOMES MASCULINOS E FEMININOS conexao.Sql = "SELECT CONTEUDO_TEXTO, CONTEUDO_TAG1 FROM TB_CONTEUDOS WHERE CONTEUDO_TIPO = 'Nome' AND (CONTEUDO_TAG1 = 'Masculino' OR CONTEUDO_TAG1 = 'Feminino');"; comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); dados = comando.ExecuteReader(); if (dados.HasRows) { while (dados.Read()) { if (dados["CONTEUDO_TAG1"].ToString() == "Masculino") { nomes_masculinos.Add(dados["CONTEUDO_TEXTO"].ToString()); } else if (dados["CONTEUDO_TAG1"].ToString() == "Feminino") { nomes_femininos.Add(dados["CONTEUDO_TEXTO"].ToString()); } } } //ADICIONANDO NOMES NOS DROPDOWNS dpw_nomes_1.AddOptions(nomes_masculinos); dpw_nomes_1.AddOptions(nomes_femininos); dpw_nomes_2.AddOptions(nomes_masculinos); dpw_nomes_2.AddOptions(nomes_femininos); dpw_nomes_3.AddOptions(nomes_masculinos); dpw_nomes_3.AddOptions(nomes_femininos); dpw_nomes_4.AddOptions(nomes_masculinos); dpw_nomes_4.AddOptions(nomes_femininos); dpw_nomes_5.AddOptions(nomes_masculinos); dpw_nomes_5.AddOptions(nomes_femininos); dpw_nomes_6.AddOptions(nomes_masculinos); dpw_nomes_6.AddOptions(nomes_femininos); dados.Close(); comando.Dispose(); // PEGAR SOBRENOMES conexao.Sql = "SELECT CONTEUDO_TEXTO FROM TB_CONTEUDOS WHERE CONTEUDO_TIPO = 'Sobrenome';"; comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); dados = comando.ExecuteReader(); if (dados.HasRows) { while (dados.Read()) { sobrenomes.Add(dados["CONTEUDO_TEXTO"].ToString()); } } dados.Close(); comando.Dispose(); // PEGAR NASCIONALIDADES conexao.Sql = "SELECT CONTEUDO_TEXTO FROM TB_CONTEUDOS WHERE CONTEUDO_TIPO = 'Nacionalidade';"; comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); dados = comando.ExecuteReader(); if (dados.HasRows) { while (dados.Read()) { nascionalidades.Add(dados["CONTEUDO_TEXTO"].ToString()); } } //ADICIONANDO NASCIONALIDADES AOS DROPDOWNS dpw_nascionalidades_1.AddOptions(nascionalidades); dpw_nascionalidades_2.AddOptions(nascionalidades); dpw_nascionalidades_3.AddOptions(nascionalidades); dpw_nascionalidades_4.AddOptions(nascionalidades); dpw_nascionalidades_5.AddOptions(nascionalidades); dpw_nascionalidades_6.AddOptions(nascionalidades); dados.Close(); comando.Dispose(); conexao.fecharBanco(); }catch (MySqlException e) { print(e); } int nNpcs; switch (nivel) { case 1: nNpcs = 2; break; case 2: nNpcs = 4; break; case 3: nNpcs = 6; break; default: nNpcs = 2; break; } int rPosicao1; int rPosicao2; // GERA NPCS for (int i = 0; i < nNpcs; i++) { rPosicao1 = Random.Range(0, posicoesNPC.Count); if (posicoesNPC[rPosicao1].Count == 0) { posicoesNPC.RemoveAt(rPosicao1); rPosicao1 = Random.Range(0, posicoesNPC.Count); } rPosicao2 = Random.Range(0, posicoesNPC[rPosicao1].Count); GameObject npc = Instantiate(NPC, posicoesNPC[rPosicao1][rPosicao2], Quaternion.identity); Classe_NPC_Licao1_Atv1 c = npc.GetComponent <Classe_NPC_Licao1_Atv1>(); c.id = i + 1; npcs.Add(npc); posicoesNPC[rPosicao1].RemoveAt(rPosicao2); } }
void Start() { //INICIALIZA AS CLASSES 'CONEXAO' E 'PLAYER' Banco_Conexao conexao = new Banco_Conexao(); Objeto_Player player = new Objeto_Player(); try { conexao.conectarBanco(); //COMANDO SQL NIVEL 2 conexao.Sql = "SELECT NIVEL_ATIVIDADE FROM TB_NIVEL_ATIVIDADE WHERE COD_ESTUDANTE=" + player.Cpf + " AND COD_ATIVIDADE=4"; comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); dados = comando.ExecuteReader(); if (dados.HasRows) { while (dados.Read()) { int n = (int)dados["NIVEL_ATIVIDADE"]; if (n <= 10) { nivel = 1; qtdAtividades = 3; tempo = 180; } else if (n <= 20) { nivel = 2; qtdAtividades = 6; tempo = 140; } else { nivel = 3; qtdAtividades = 9; tempo = 120; } } } dados.Close(); comando.Dispose(); tempo_correndo = true; todos_eventos = GetChildren(gameobject_eventos); float y_task = 152f; int nREvento; for (int i = 0; i < qtdAtividades; i++) { nREvento = Random.Range(0, todos_eventos.ToArray().Length); todos_eventos[nREvento].SetActive(true); todos_eventos[nREvento].GetComponent <Classe_Evento_Licao4_Atv1>().e_pra_fazer = true; GameObject task = Instantiate(pnl_task_L4A1, new Vector3(canvas.transform.position.x, canvas.transform.position.y + y_task, 0), Quaternion.identity, scroll_object.transform); y_task = y_task - (task.GetComponent <RectTransform>().rect.height + 10); Text txt_task = task.transform.Find("txt_task").GetComponent <Text>(); txt_task.text = todos_eventos[nREvento].GetComponent <Classe_Evento_Licao4_Atv1>().evento_task; eventos_questao.Add(todos_eventos[nREvento].name, todos_eventos[nREvento]); acertos_erros.Add(todos_eventos[nREvento].name, false); tasks.Add(task); todos_eventos.RemoveAt(nREvento); } } catch (MySqlException e) { print(e); } }
void Start() { //INICIALIZA AS CLASSES 'CONEXAO' E 'PLAYER' Banco_Conexao conexao = new Banco_Conexao(); Objeto_Player player = new Objeto_Player(); //CONTATO COM O BANCO DE DADOS try { conexao.conectarBanco(); comidas_entrada_traducao.Add("Choose"); comidas_almoco_traducao.Add("Choose"); bebidas_entrada_traducao.Add("Choose"); bebidas_almoco_traducao.Add("Choose"); //COMANDO SQL NIVEL 2 conexao.Sql = "SELECT NIVEL_ATIVIDADE FROM TB_NIVEL_ATIVIDADE WHERE COD_ESTUDANTE=" + player.Cpf + " AND COD_ATIVIDADE=5"; comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); dados = comando.ExecuteReader(); if (dados.HasRows) { while (dados.Read()) { int n = (int)dados["NIVEL_ATIVIDADE"]; if (n <= 10) { qtdAMenos = 4; } else if (n <= 20) { qtdAMenos = 2; } else { qtdAMenos = 0; } } } dados.Close(); comando.Dispose(); // PEGAR CONTEUDO LICAO 5 ATIVIDADE 1 conexao.Sql = "SELECT CONTEUDO_TEXTO, CONTEUDO_TIPO, CONTEUDO_TAG2, CONTEUDO_TAG3 FROM TB_CONTEUDOS WHERE CONTEUDO_TAG1 = 'Licao5_Atv1';"; comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); dados = comando.ExecuteReader(); if (dados.HasRows) { while (dados.Read()) { switch (dados["CONTEUDO_TIPO"].ToString()) { case "Comida": switch (dados["CONTEUDO_TAG3"].ToString()) { case "Almoco": comidas_almoco.Add(dados["CONTEUDO_TEXTO"].ToString()); comidas_almoco_traducao.Add(dados["CONTEUDO_TAG2"].ToString()); break; case "Entrada": comidas_entrada.Add(dados["CONTEUDO_TEXTO"].ToString()); comidas_entrada_traducao.Add(dados["CONTEUDO_TAG2"].ToString()); break; } break; case "Bebida": switch (dados["CONTEUDO_TAG3"].ToString()) { case "Almoco": bebidas_almoco.Add(dados["CONTEUDO_TEXTO"].ToString()); bebidas_almoco_traducao.Add(dados["CONTEUDO_TAG2"].ToString()); break; case "Entrada": bebidas_entrada.Add(dados["CONTEUDO_TEXTO"].ToString()); bebidas_entrada_traducao.Add(dados["CONTEUDO_TAG2"].ToString()); break; } break; } } } dados.Close(); comando.Dispose(); txt_dialogo.text = "Olá " + player.Nome + ", obrigado por almoçar comigo, eu sou novo aqui e eu não sei falar em inglês, você poderia fazer o pedido por mim?"; conexao.fecharBanco(); } catch (MySqlException e) { print(e); } }
// -------------------- Verificar o codigo --------------------- // -------------------- Validar Informações --------------------- public void Metodo_Validar_Info() { Banco_Conexao conexao = new Banco_Conexao(); Objeto_Player player = new Objeto_Player(); InputField txt_nome = GameObject.Find("txt_nome").GetComponent <InputField>(); InputField txt_email = GameObject.Find("txt_email").GetComponent <InputField>(); InputField txt_cpf = GameObject.Find("txt_cpf").GetComponent <InputField>(); Text txt_status_info = GameObject.Find("txt_status_info").GetComponent <Text>(); if ((txt_nome.text == "") || (txt_email.text == "") || (txt_cpf.text == "")) { txt_status_info.text = "Um dos campos está em branco!"; StartCoroutine(Corrotina_Status_Cadastro("txt_status_info")); } else { try{ conexao.conectarBanco(); conexao.Sql = "SELECT USER_ESTUDANTE_CPF FROM TB_USER_ESTUDANTE WHERE USER_ESTUDANTE_EMAIL='" + txt_email.text + "';"; comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); dados = comando.ExecuteReader(); if (dados.HasRows) { dados.Close(); comando.Dispose(); txt_status_info.text = "Email ou cpf já cadastrados! Contate um Administrador."; StartCoroutine(Corrotina_Status_Cadastro("txt_status_info")); } else { dados.Close(); comando.Dispose(); conexao.Sql = "SELECT USER_ESTUDANTE_CPF FROM TB_USER_ESTUDANTE WHERE USER_ESTUDANTE_CPF='" + txt_cpf.text + "';"; comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); dados = comando.ExecuteReader(); if (dados.HasRows) { dados.Close(); comando.Dispose(); StartCoroutine(Corrotina_Status_Cadastro("txt_status_info")); } else { player.Nome = txt_nome.text; player.Email = txt_email.text; player.Cpf = System.Convert.ToInt64(txt_cpf.text); dados.Close(); comando.Dispose(); pnl_cadastro_info.SetActive(false); pnl_cadastro_player.SetActive(true); //Text sala = GameObject.Find("txt_sala_player").GetComponent<Text>(); //sala.text = player.NomeSala; } } conexao.fecharBanco(); } catch (MySqlException e) { dados.Close(); comando.Dispose(); conexao.fecharBanco(); print(e); //reconexao.realizarReconexao(); } } }
// -------------------- Validar Informações --------------------- // -------------------- Validar Player --------------------- public void Metodo_Validar_Player() { Banco_Conexao conexao = new Banco_Conexao(); Objeto_Player player = new Objeto_Player(); InputField txt_login = GameObject.Find("txt_login").GetComponent <InputField>(); InputField txt_senha = GameObject.Find("txt_senha").GetComponent <InputField>(); Text txt_status_login = GameObject.Find("txt_status_login").GetComponent <Text>(); Text txt_status_senha = GameObject.Find("txt_status_senha").GetComponent <Text>(); Toggle tgl_masculino = GameObject.Find("tgl_masculino").GetComponent <Toggle>(); Toggle tgl_feminino = GameObject.Find("tgl_feminino").GetComponent <Toggle>(); if (txt_login.text == "") { txt_status_login.text = "Não pode estar em branco!"; StartCoroutine(Corrotina_Status_Cadastro("txt_status_login")); } else if (txt_senha.text == "") { txt_status_senha.text = "Não pode estar em branco!"; StartCoroutine(Corrotina_Status_Cadastro("txt_status_senha")); } else { try{ conexao.conectarBanco(); conexao.Sql = "SELECT USER_ESTUDANTE_CPF FROM TB_USER_ESTUDANTE WHERE USER_ESTUDANTE_LOGIN='******';"; comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); dados = comando.ExecuteReader(); if (dados.HasRows) { comando.Dispose(); dados.Close(); txt_status_login.text = "Login não disponível! Tente outro."; StartCoroutine(Corrotina_Status_Cadastro("txt_status_login")); } else { comando.Dispose(); dados.Close(); if (tgl_masculino.isOn) { player.Pele = "B_M"; player.Roupa = "R_M_Escritorio_1"; player.Cabelo = "C_M_1"; } else if (tgl_feminino.isOn) { player.Pele = "B_F"; player.Roupa = "R_F_Escritorio_1"; player.Cabelo = "C_F_7"; } else { return; } comando.Dispose(); dados.Close(); pnl_loading.SetActive(true); player.Acessorio = "NULL"; player.Nivel = 1; player.Patuais = 0; player.Psemestre = 0; player.Ptotais = 0; conexao.Sql = "INSERT INTO TB_USER_ESTUDANTE (USER_ESTUDANTE_CPF, USER_ESTUDANTE_NOME, USER_ESTUDANTE_LOGIN, " + "USER_ESTUDANTE_SENHA, USER_ESTUDANTE_EMAIL, USER_ESTUDANTE_NIVEL, USER_ESTUDANTE_PTOTAIS, USER_ESTUDANTE_PSEMESTRE, " + "USER_ESTUDANTE_PATUAIS, USER_ESTUDANTE_PELE, USER_ESTUDANTE_ROUPA, USER_ESTUDANTE_CABELO, USER_ESTUDANTE_ACESSORIO) VALUES (" + player.Cpf + ", " + "'" + player.Nome + "', " + "'" + txt_login.text + "', " + "md5('" + txt_senha.text + "'), " + "'" + player.Email + "', " + player.Nivel + ", " + player.Ptotais + ", " + player.Psemestre + ", " + player.Patuais + ", " + "'" + player.Pele + "', " + "'" + player.Roupa + "', " + "'" + player.Cabelo + "', " + "'" + player.Acessorio + "');"; comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); comando.ExecuteNonQuery(); comando.Dispose(); List <int> cod_atividades = new List <int>(); conexao.Sql = "SELECT ATIVIDADE_ID FROM TB_ATIVIDADES;"; comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); dados = comando.ExecuteReader(); if (dados.HasRows) { while (dados.Read()) { cod_atividades.Add(System.Convert.ToInt32(dados["ATIVIDADE_ID"])); } } comando.Dispose(); dados.Close(); for (int i = 0; i < cod_atividades.ToArray().Length; i++) { conexao.Sql = "INSERT INTO TB_NIVEL_ATIVIDADE(COD_ESTUDANTE, COD_ATIVIDADE, NIVEL_ATIVIDADE) VALUES " + "(" + player.Cpf + ", " + cod_atividades[i] + ", 1);"; comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); comando.ExecuteNonQuery(); comando.Dispose(); } comando.Dispose(); conexao.fecharBanco(); UnityEngine.SceneManagement.SceneManager.LoadScene("telaPrincipal"); } }catch (MySqlException e) { dados.Close(); comando.Dispose(); conexao.fecharBanco(); print(e); //reconexao.realizarReconexao(); } } }
void Start() { Banco_Conexao connection = new Banco_Conexao(); Objeto_Player player = new Objeto_Player(); try { connection.conectarBanco(); connection.Sql = "SELECT NIVEL_ATIVIDADE FROM TB_NIVEL_ATIVIDADE WHERE COD_ESTUDANTE=" + player.Cpf + " AND COD_ATIVIDADE=7"; command = new MySqlCommand(connection.Sql, connection.ConexaoBanco); data = command.ExecuteReader(); if (data.HasRows) { while (data.Read()) { int n = (int)data["NIVEL_ATIVIDADE"]; if (n <= 10) { level = 1; } else if (n <= 20) { level = 2; } else { level = 3; } } } data.Close(); command.Dispose(); connection.Sql = "SELECT CONTEUDO_TEXTO, CONTEUDO_TAG1 FROM TB_CONTEUDOS WHERE CONTEUDO_TIPO = 'Lugar' AND CONTEUDO_TAG1 = 'Lição 7 Atividade 1';"; command = new MySqlCommand(connection.Sql, connection.ConexaoBanco); data = command.ExecuteReader(); if (data.HasRows) { while (data.Read()) { places.Add(data["CONTEUDO_TEXTO"].ToString()); } } data.Close(); command.Dispose(); connection.Sql = "SELECT CONTEUDO_TEXTO, CONTEUDO_TAG1 FROM TB_CONTEUDOS WHERE CONTEUDO_TIPO = 'Direção' AND CONTEUDO_TAG1 = 'Lição 7 Atividade 1';"; command = new MySqlCommand(connection.Sql, connection.ConexaoBanco); data = command.ExecuteReader(); if (data.HasRows) { while (data.Read()) { answers.Add(data["CONTEUDO_TEXTO"].ToString()); } } data.Close(); command.Dispose(); connection.fecharBanco(); } catch (MySqlException e) { Debug.LogError(e); } switch (level) { case 1: answersTimes = 2; break; case 2: answersTimes = 4; break; case 3: answersTimes = 6; break; default: answersTimes = 2; break; } RandomizeActivitie(); }
void Start() { //INICIALIZA AS CLASSES 'CONEXAO' E 'PLAYER' Banco_Conexao conexao = new Banco_Conexao(); Objeto_Player player = new Objeto_Player(); //CONTATO COM O BANCO DE DADOS try { conexao.conectarBanco(); //COMANDO SQL NIVEL 2 conexao.Sql = "SELECT NIVEL_ATIVIDADE FROM TB_NIVEL_ATIVIDADE WHERE COD_ESTUDANTE=" + player.Cpf + " AND COD_ATIVIDADE=6"; comando = new MySqlCommand(conexao.Sql, conexao.ConexaoBanco); dados = comando.ExecuteReader(); int rNFotoNome; if (dados.HasRows) { while (dados.Read()) { int n = (int)dados["NIVEL_ATIVIDADE"]; if (n <= 10) { nivel = 1; qtdFotos = 2; } else if (n <= 20) { nivel = 2; qtdFotos = 4; } else { nivel = 3; qtdFotos = 8; } } } fotos.AddRange(Resources.LoadAll <Sprite>("L6_A1/Imagens/")); for (int i = 0; i < fotos.ToArray().Length; i++) { nomes.Add(fotos[i].name); nomes_a_popular.Add(fotos[i].name); } switch (nivel) { case 1: rNFotoNome = Random.Range(0, nomes_a_popular.ToArray().Length); txt_foto_1.text = nomes_a_popular[rNFotoNome]; nomes_a_popular.RemoveAt(rNFotoNome); rNFotoNome = Random.Range(0, nomes_a_popular.ToArray().Length); txt_foto_2.text = nomes_a_popular[rNFotoNome]; nomes_a_popular.RemoveAt(rNFotoNome); break; case 2: rNFotoNome = Random.Range(0, nomes_a_popular.ToArray().Length); txt_foto_1.text = nomes_a_popular[rNFotoNome]; nomes_a_popular.RemoveAt(rNFotoNome); rNFotoNome = Random.Range(0, nomes_a_popular.ToArray().Length); txt_foto_2.text = nomes_a_popular[rNFotoNome]; nomes_a_popular.RemoveAt(rNFotoNome); rNFotoNome = Random.Range(0, nomes_a_popular.ToArray().Length); txt_foto_3.text = nomes_a_popular[rNFotoNome]; nomes_a_popular.RemoveAt(rNFotoNome); rNFotoNome = Random.Range(0, nomes_a_popular.ToArray().Length); txt_foto_4.text = nomes_a_popular[rNFotoNome]; nomes_a_popular.RemoveAt(rNFotoNome); break; case 3: rNFotoNome = Random.Range(0, nomes_a_popular.ToArray().Length); txt_foto_1.text = nomes_a_popular[rNFotoNome]; nomes_a_popular.RemoveAt(rNFotoNome); rNFotoNome = Random.Range(0, nomes_a_popular.ToArray().Length); txt_foto_2.text = nomes_a_popular[rNFotoNome]; nomes_a_popular.RemoveAt(rNFotoNome); rNFotoNome = Random.Range(0, nomes_a_popular.ToArray().Length); txt_foto_3.text = nomes_a_popular[rNFotoNome]; nomes_a_popular.RemoveAt(rNFotoNome); rNFotoNome = Random.Range(0, nomes_a_popular.ToArray().Length); txt_foto_4.text = nomes_a_popular[rNFotoNome]; nomes_a_popular.RemoveAt(rNFotoNome); rNFotoNome = Random.Range(0, nomes_a_popular.ToArray().Length); txt_foto_5.text = nomes_a_popular[rNFotoNome]; nomes_a_popular.RemoveAt(rNFotoNome); rNFotoNome = Random.Range(0, nomes_a_popular.ToArray().Length); txt_foto_6.text = nomes_a_popular[rNFotoNome]; nomes_a_popular.RemoveAt(rNFotoNome); rNFotoNome = Random.Range(0, nomes_a_popular.ToArray().Length); txt_foto_7.text = nomes_a_popular[rNFotoNome]; nomes_a_popular.RemoveAt(rNFotoNome); rNFotoNome = Random.Range(0, nomes_a_popular.ToArray().Length); txt_foto_8.text = nomes_a_popular[rNFotoNome]; nomes_a_popular.RemoveAt(rNFotoNome); break; } dados.Close(); comando.Dispose(); } catch (MySqlException e) { print(e); } }