private void TimerGreedySw_Tick(object sender, EventArgs e) { if (contadorGreedy >= tiempoGreedy) { for (int i = 0; i < 10; i++) { ConstruidaGreedy[i] = null; } TimerGreedySw.Stop(); } else { TiempoGreedy.Text = "Tiempo: " + (contadorGreedy + 1); if (movSCGreedy[contadorGreedy] == 'I') { numScareCGr[otroScarecrowGr].Location = new Point((600 - (60 * (movimientosScareCrowGr + 1))), 10); } else { numScareCGr[otroScarecrowGr].Location = new Point((600 - (60 * (movimientosScareCrowGr))), 20); } if (movSCGreedy[contadorGreedy] == 'A' && movSCGreedy[contadorGreedy + 1] == 'I') { otroScarecrowGr++; movimientosScareCrowGr = -1; } } movimientosScareCrowGr++; contadorGreedy++; }
public void RecibirCadena(String numScarecrow) { int x = 60, x0 = 10; ConstruidaGreedy = new PictureBox[10]; ConstruidaFb = new PictureBox[10]; this.tam_terreno = numScarecrow.Length; generarObjF = 10 - tam_terreno; if (generarObjF != 0) { for (int i = 0; i < generarObjF; i++) { numScarecrow = numScarecrow + "#"; } } this.tam_terreno = numScarecrow.Length; this.terreno = new char[tam_terreno]; this.terreno = numScarecrow.ToCharArray(); for (int i = 0; i < 10; i++) { ConstruidaGreedy[i] = new PictureBox(); ConstruidaFb[i] = new PictureBox(); if (i == 0) { ConstruidaGreedy[i].Location = new Point(x0, 40); ConstruidaFb[i].Location = new Point(x0, 40); } else { ConstruidaGreedy[i].Location = new Point(x0 + (x * i), 40); ConstruidaFb[i].Location = new Point(x0 + (x * i), 40); } if (terreno[i] == '.') { ConstruidaGreedy[i].Image = ProyectoDeAlgoritmos.Properties.Resources.Maiz; ConstruidaFb[i].Image = ProyectoDeAlgoritmos.Properties.Resources.Maiz; } else { ConstruidaGreedy[i].Image = ProyectoDeAlgoritmos.Properties.Resources.Tierra; ConstruidaFb[i].Image = ProyectoDeAlgoritmos.Properties.Resources.Tierra; } ConstruidaGreedy[i].SizeMode = PictureBoxSizeMode.Normal; ConstruidaFb[i].SizeMode = PictureBoxSizeMode.Normal; ConstruidaGreedy[i].Size = new System.Drawing.Size(40, 45); ConstruidaFb[i].Size = new System.Drawing.Size(40, 45); ConstruidaGreedy[i].Show(); ConstruidaFb[i].Show(); panel1.Controls.Add(ConstruidaGreedy[i]); panel2.Controls.Add(ConstruidaFb[i]); } ScarecrowFuerzaBruta(); ScarecrowGreedy(); Thread.Sleep(100); TimerGreedySw.Start(); TimerFbSw.Start(); }