private void listaComprasModelos() { for (int i = 0; i < 5; i++) { if (jogador.tabuleiro.verificaSeLinhaPreenchidaNaoCompleta(i))//confere se a linha tá prenchida mas não completa { int qtd = (i + 1) - jogador.tabuleiro.modelo[i].quantidade; while (qtd >= 1) { Compra compra = new Compra(); compra.azulejo = jogador.tabuleiro.modelo[i].id; compra.modelo = i + 1; compra.qtd = qtd; listaCompras.Add(compra); qtd--; } Invoke((MethodInvoker) delegate { textBox1.Text += compra.qtd.ToString() + Azulejo.LembraCor(compra.azulejo, false) + " modelo " + (i + 1).ToString() + "\r\n"; }); } } }//Busca Linhas de Modelo incompletas
}//Recarrega azulejos (REMOVER) private void azulejo_Click(object sender, EventArgs e) { compra = new Compra(); //Instacia o objeto compra PictureBox pcb = (PictureBox)sender; //Recebe a picturebox que mandou o evento //Preence o objeto compra compra.tipo = pcb.AccessibleName.Substring(0, 1); compra.fabrica = Convert.ToInt32(pcb.AccessibleName.Substring(1, 1)); compra.azulejo = Convert.ToInt32(pcb.AccessibleName.Substring(2, 1)); compra.qtd = Convert.ToInt32(pcb.AccessibleName.Substring(3, 1)); string cor = Azulejo.LembraCor(compra.azulejo, compra.qtd > 1); //Pega a cor na função da classe azulejo, essa comparação diz se é plural ou não string azu = "azulejo"; //Pego o plural ou o singular de Azulejos if (compra.qtd > 1) { azu += "s"; } string dx;//Vê se a compra é da fábrica ou do centro if (compra.tipo == "F") { dx = "da fábrica " + compra.fabrica; } else { dx = "do centro"; } lblCompra.Text = "Compra: " + compra.qtd + " " + azu + " " + cor + " " + dx;//Escreve a corrinho de compras na tela }//Clique em um azulejo das fábricas e centro: adiciona o azulejo no carrinho
public void preencherFabricas(string txt) { this.fabricas = new List <Fabrica>(); txt = txt.Replace("\r", ""); //corta o caracter /r do retorno string[] fabs = txt.Split('\n'); //Separa as linhas do retorno fabs = fabs.Take(fabs.Count() - 1).ToArray(); //Remove o elemento fantasma int p = 0; for (int i = 1; i <= this.qtdFabricas; i++) //Controla as fábricas { Fabrica fabrica = new Fabrica(); fabrica.azulejos = new List <Azulejo>(); fabrica.id = i; while (p != fabs.Length && i == Convert.ToInt32(fabs[p].Substring(0, 1))) //Controla o azulejo { Azulejo azul = new Azulejo(); azul.id = Convert.ToInt32(fabs[p].Substring(2, 1)); azul.quantidade = Convert.ToInt32(fabs[p].Substring(fabs[p].Length - 1, 1)); //Lê o último caractere e pega a quantidade azul.DefinirCor(); //Define a imagem do Azulejo p++; fabrica.azulejos.Add(azul); } //Definir o x y das fábricas aqui this.fabricas.Add(fabrica); } }
public void preencherCentro(string txt) { this.centro = new Centro(); txt = txt.Replace("\r", ""); //corta o caracter /r do retorno string[] cent = txt.Split('\n'); //Separa as linhas do retorno this.centro.azulejos = new List <Azulejo>(); cent = cent.Take(cent.Count() - 1).ToArray();//Remove o elemento fantasma string[] checa1 = cent[0].Split(','); if (Convert.ToBoolean(Convert.ToInt16(checa1[3]))) { Azulejo a = new Azulejo(); a.id = 0; a.quantidade = 1; //this.centro.marca1 = Convert.ToBoolean(Convert.ToInt16(itens[3])); a.DefinirCor(); this.centro.azulejos.Add(a); } for (int i = 0; i < 5; i++) { string[] itens = cent[i].Split(','); Azulejo a = new Azulejo(); a.id = Convert.ToInt32(itens[0]); a.quantidade = Convert.ToInt32(itens[2]); //this.centro.marca1 = Convert.ToBoolean(Convert.ToInt16(itens[3])); a.DefinirCor(); this.centro.azulejos.Add(a); } }
public void preencherTabuleiro(int id, string senha) { this.tabuleiro = new Tabuleiro(); this.tabuleiro.modelo = new Azulejo[5]; this.tabuleiro.chao = new List <Azulejo>(); this.tabuleiro.parede = new bool[5, 5]; string txt = Jogo.LerTabuleiro(id, senha, this.id); Console.WriteLine("li tabuleiro"); txt = txt.Replace("\r", ""); //corta o caracter /r do retorno string[] txtTabuleiro = txt.Split('\n'); //Separa as linhas do retorno int l = 1; //Começa em 1 pra pular o texto modelo while (txtTabuleiro[l].Substring(0, 1) != "p") { string[] linha = txtTabuleiro[l].Split(','); Azulejo a = new Azulejo(); a.id = Convert.ToInt32(linha[1]); a.DefinirCor(); a.quantidade = Convert.ToInt32(linha[2]); this.tabuleiro.modelo[Convert.ToInt32(linha[0]) - 1] = a; l++; } l++; //Pula o texto parede while (txtTabuleiro[l].Substring(0, 1) != "c") { string[] linha = txtTabuleiro[l].Split(','); this.tabuleiro.parede[Convert.ToInt32(linha[0]) - 1, Convert.ToInt32(linha[1]) - 1] = true; l++; } l++; //Pula o texto chão while (!txtTabuleiro[l].Equals("")) { string[] linha = txtTabuleiro[l].Split(','); Azulejo a = new Azulejo(); a.id = Convert.ToInt32(linha[1]); a.DefinirCor(); this.tabuleiro.chao.Add(a); l++; } }
public bool podeColocar(int azulejo, int modelo) { for (int i = 0; i < 5; i++) { if (this.parede[modelo, i]) { if (azulejo == Azulejo.VerCorNaParede(modelo, i)) { return(false); } } } return(true); }
}//Diz quantos pontos a linha vai fazer private bool completaCor(int l, int c) { int cor = Azulejo.VerCorNaParede(l, c); int qtd = 0; //int linhaModelo = 0; for (int i = 0; i < 5; i++) { if (jogador.tabuleiro.parede[i, checaPos(i, cor - 1)]) { qtd++; } } if (qtd == 4) { return(true); } return(false); }
}//Busca Linhas de Modelo incompletas private void listaComprasModelosVazios() { listaCompraColuna = new List <Compra>(); for (int l = 0; l < 5; l++) { Compra MelhorCorLinha = new Compra(); if (jogador.tabuleiro.verificaSeLinhaVazia(l)) { int maisPontos = 0; for (int c = 0; c < 5; c++) { if (!jogador.tabuleiro.parede[l, c]) { int p = checarPontosAzul(l, c); if (p >= 10) { MelhorCorLinha.azulejo = Azulejo.VerCorNaParede(l, c); MelhorCorLinha.modelo = l + 1; MelhorCorLinha.qtd = l + 1; int qtdColuna = MelhorCorLinha.qtd; while (qtdColuna + 3 >= 1) { Compra com = new Compra(); com.azulejo = MelhorCorLinha.azulejo; com.modelo = MelhorCorLinha.modelo; com.qtd = qtdColuna; listaCompraColuna.Add(com); qtdColuna--; } } if (p >= maisPontos) { maisPontos = p; MelhorCorLinha.azulejo = Azulejo.VerCorNaParede(l, c); MelhorCorLinha.modelo = l + 1; MelhorCorLinha.qtd = l + 1; } } } int qtd = MelhorCorLinha.qtd; while (qtd >= 1) { Compra c = new Compra(); c.azulejo = MelhorCorLinha.azulejo; c.modelo = MelhorCorLinha.modelo; c.qtd = qtd; listaCompras.Add(c); qtd--; } Invoke((MethodInvoker) delegate { textBox1.Text += Azulejo.LembraCor(MelhorCorLinha.azulejo, false) + " modelo " + (l + 1).ToString() + "\r\n"; }); } } }//Busca a melhor cor pra cada linha de modelo vazia