/// <summary> /// Methode qui permet de donner au concierge sa zone d'interaction /// </summary> /// <param name="x2"></param> /// <param name="y2"></param> /// <param name="c"></param> /// <returns></returns> private bool[,] PeuplerBitmapInteractionConcierge(int x2, int y2, Concierge c) { bool[,] bmInteractionC = new bool[43, 25]; for (int i = 0; i < bmInteractionC.GetLength(0); i++) { for (int j = 0; j < bmInteractionC.GetLength(1); j++) { bmInteractionC[i, j] = false; } } if (c.x != 0 && c.y != 0) { bmInteractionC[x2 - 1, y2 - 1] = true; } if (c.x != 0) { bmInteractionC[x2 - 1, y2] = true; } if (c.y != 0) { bmInteractionC[x2, y2 - 1] = true; } if (c.x != 0 && c.y != 24) { bmInteractionC[x2 - 1, y2 + 1] = true; } if (c.x != 42 && c.y != 24) { bmInteractionC[x2 + 1, y2 + 1] = true; } if (c.x != 42) { bmInteractionC[x2 + 1, y2] = true; } if (c.y != 24) { bmInteractionC[x2, y2 + 1] = true; } if (c.x != 42 && c.y != 0) { bmInteractionC[x2 + 1, y2 - 1] = true; } return(bmInteractionC); }
private void DessinerConcierge(Graphics gr, Concierge c) { gr.DrawImage(c.currentDir, c.x * 32, c.y * 32, 32, 32); }
/// <summary> /// Methode qui permet au concierge de ce deplacer /// </summary> /// <param name="c"></param> public void DeplacementConcierge(Concierge c) { Random r = new Random(); int deplacement = r.Next(1, 5); int x2 = c.x; int y2 = c.y; Point pHero = new Point(); Point pConcierge = new Point(); pHero.X = h.x; pHero.Y = h.y; pConcierge.X = c.x; pConcierge.Y = c.y; List <Image> l = new List <Image>(); l = c.listeC; if (deplacement == 1) { y2--; pConcierge.Y = y2; if (y2 >= 0) { if (noMouvCoordAI[x2, y2] && noMouvJanitor[x2, y2] && noMouvAi[x2, y2] && noMouvTrash[x2, y2] && pConcierge != pHero) { c.y--; if (c.upAI == 0) { c.currentDir = l.ElementAt(9); Refresh(); c.upAI++; } else if (c.upAI == 1) { c.currentDir = l.ElementAt(8); Refresh(); c.upAI--; } } } } else if (deplacement == 2) { x2--; pConcierge.X = x2; if (x2 >= 0) { if (noMouvCoordAI[x2, y2] && noMouvJanitor[x2, y2] && noMouvAi[x2, y2] && noMouvTrash[x2, y2] && pConcierge != pHero) { c.x--; if (c.leftAI == 0) { c.currentDir = l.ElementAt(7); Refresh(); c.leftAI++; } else if (c.leftAI == 1) { c.currentDir = l.ElementAt(6); Refresh(); c.leftAI++; } else if (c.leftAI == 2) { c.currentDir = l.ElementAt(5); Refresh(); c.leftAI = 0; } } } } else if (deplacement == 3) { y2++; pConcierge.Y = y2; if (y2 <= 24) { if (noMouvCoordAI[x2, y2] && noMouvJanitor[x2, y2] && noMouvAi[x2, y2] && noMouvTrash[x2, y2] && pConcierge != pHero) { c.y++; if (c.downAI == 0) { c.currentDir = l.ElementAt(1); Refresh(); c.downAI++; } else if (c.downAI == 1) { c.currentDir = l.ElementAt(0); Refresh(); c.downAI--; } } } } else if (deplacement == 4) { x2++; pConcierge.X = x2; if (x2 <= 42) { if (noMouvCoordAI[x2, y2] && noMouvJanitor[x2, y2] && noMouvAi[x2, y2] && noMouvTrash[x2, y2] && pConcierge != pHero) { c.x++; if (c.rightAI == 0) { c.currentDir = l.ElementAt(4); Refresh(); c.rightAI++; } else if (c.rightAI == 1) { c.currentDir = l.ElementAt(3); Refresh(); c.rightAI++; } else if (c.rightAI == 2) { c.currentDir = l.ElementAt(2); Refresh(); c.rightAI = 0; } } } } for (int i = 0; i < c.bmInteractionC.GetLength(0); i++) { for (int j = 0; j < c.bmInteractionC.GetLength(1); j++) { c.bmInteractionC[i, j] = false; } } c.bmInteractionC = PeuplerBitmapInteractionConcierge(c.x, c.y, c); for (int i = 0; i < c.bmInteractionC.GetLength(0); i++) { for (int j = 0; j < c.bmInteractionC.GetLength(1); j++) { if (c.bmInteractionC[i, j]) { foreach (Point p in listeTrash) { if (p.X == i && p.Y == j) { listeTrash.Remove(p); break; } } } } } }
/// <summary> /// Methode qui ajoute un concierge a la listeConcierge /// </summary> public void AjouterConcierge(int x, int y) { Concierge c = new Concierge(x, y); listeConcierge.Add(c); }
/// <summary> /// Ajouter un concierge /// </summary> /// <param name="x"></param> /// <param name="y"></param> public void AjoutConcierge(int x, int y) { Concierge temp = new Concierge(x, y, tabAjout, listeVisiteur, listeDechet, listeConcierge, hero); listeConcierge.Add(temp); }