void RemoveEndCondition(ModeTransition _mt) { bossMode.modeTransitions.Remove(_mt); }
public void Update(KeyboardState touche, MouseState souris, bool francais) { #region Langue if (francais) { texte_menu[0] = "Sols"; texte_menu[1] = "Décors"; texte_menu[2] = "Objet"; texte_menu[3] = "PNJ"; texte_menu[4] = "Transition"; texte_menu[5] = "Musique"; texte_menu[6] = "Tout afficher"; nombre_de_transition = "Nombre de transitions: "; ajouter = "Ajouter"; supprimer = "Supprimer"; selectionner = "Selectionnez le rectangle de téléportation:"; modifier = "Modifier"; hauteurtransition = "Hauteur: "; largeurtransition = "Largeur: "; xtransition = "X: "; ytransition = "Y: "; selectionnercartedestination = "Selectionnez la carte de destination: "; xdestination = "X: "; ydestination = "Y: "; retour = "Retour"; suivant = "Suivant"; creer = "Créer"; selectionnersupr = "Selectionnez la transition à supprimer."; destination_carte = "Carte de destination: "; } else { texte_menu[0] = "Floors"; texte_menu[1] = "Walls"; texte_menu[2] = "Items"; texte_menu[3] = "NPC"; texte_menu[4] = "Transition"; texte_menu[5] = "Music"; texte_menu[6] = "All show"; nombre_de_transition = "Number of transitions: "; ajouter = "Add"; supprimer = "Remove"; selectionner = "Select the transportation rectangle: "; modifier = "Edit"; hauteurtransition = "Height: "; largeurtransition = "Width: "; xtransition = "X: "; ytransition = "Y: "; selectionnercartedestination = "Select the destination map: "; xdestination = "X: "; ydestination = "Y: "; retour = "Back"; suivant = "Next"; creer = "Create"; } #endregion Rectangle sourisrect = new Rectangle(souris.X, souris.Y, 2, 2); curseur.Update(); #region Scroll Carte Keys[] touches = touche.GetPressedKeys(); foreach (Keys key in touches) { if (niveau == 5 && modeTransition == ModeTransition.DestinationNew) { if (key == Keys.Up) { if (yy > 0) yy -= 4; } if (key == Keys.Down) { //0.625 if (yy < hauteur2 * 40 - 9 * hauteurFenetre / 15) yy += 4; } if (key == Keys.Left) { if (xx > 0) xx -= 4; } if (key == Keys.Right) { if (xx < largeur2 * 40 - 8 * largeurFenetre / 11) xx += 4; } } else { if (key == Keys.Up) { if (y > 0) y -= 4; } if (key == Keys.Down) { //0.625 if (y < hauteur * 40 - 9 * hauteurFenetre / 15) y += 4; } if (key == Keys.Left) { if (x > 0) x -= 4; } if (key == Keys.Right) { if (x < largeur * 40 - 8 * largeurFenetre / 11) x += 4; } } } #endregion #region Sol if (niveau == 1) { for (int i = 0; i < coordgrilletexture_sol.GetLength(0); i++) { for (int j = 0; j < coordgrilletexture_sol.GetLength(1); j++) { if (grilletexture_sol[i, j] != null && coordgrilletexture_sol[i, j].Intersects(sourisrect) && souris.LeftButton == ButtonState.Pressed) { element_actuel = char_texture_sol[i, j]; index_x = i; index_y = j; } } } if (souris.LeftButton == ButtonState.Pressed && souris.X < 8 * largeurFenetre / 11 && souris.Y < 9 * hauteurFenetre / 15) { for (int i = 0; i < sol.GetLength(0); i++) { for (int j = 0; j < sol.GetLength(1); j++) { if (new Rectangle(j * 40 - x, i * 40 - y, 40, 40).Intersects(sourisrect)) sol[i, j] = element_actuel; } } } } #endregion #region Decor if (niveau == 2) { if (souris.RightButton == ButtonState.Pressed) { cliquedroit = true; } if (souris.RightButton == ButtonState.Pressed && cliquedroit) { cliquedroit = false; for (int i = 0; i < sol.GetLength(0); i++) { for (int j = 0; j < sol.GetLength(1); j++) { if (new Rectangle(j * 40 - x, i * 40 - y, 40, 40).Intersects(sourisrect)) decor[i, j] = ' '; } } } for (int i = 0; i < coordgrilletexture_decor.GetLength(0); i++) { for (int j = 0; j < coordgrilletexture_decor.GetLength(1); j++) { if (grilletexture_decor[i, j] != null && coordgrilletexture_decor[i, j].Intersects(sourisrect) && souris.LeftButton == ButtonState.Pressed) { element_actuel = char_texture_decor[i, j]; index_x = i; index_y = j; } } } if (souris.LeftButton == ButtonState.Pressed && souris.X < 8 * largeurFenetre / 11 && souris.Y < 9 * hauteurFenetre / 15) { for (int i = 0; i < sol.GetLength(0); i++) { for (int j = 0; j < sol.GetLength(1); j++) { if (new Rectangle(j * 40 - x, i * 40 - y, 40, 40).Intersects(sourisrect)) decor[i, j] = element_actuel; } } } } #endregion #region Objet if (niveau == 3) { if (souris.RightButton == ButtonState.Pressed) { cliquedroit_objet = true; } if (souris.RightButton == ButtonState.Released && cliquedroit_objet) { cliquedroit_objet = false; for (int i = 0; i < sol.GetLength(0); i++) { for (int j = 0; j < sol.GetLength(1); j++) { if (new Rectangle(j * 40 - x, i * 40 - y, 40, 40).Intersects(sourisrect)) objet[i, j] = ' '; } } } for (int i = 0; i < coordgrilletexture_objet.GetLength(0); i++) { for (int j = 0; j < coordgrilletexture_objet.GetLength(1); j++) { if (grilletexture_objet[i, j] != null && coordgrilletexture_objet[i, j].Intersects(sourisrect) && souris.LeftButton == ButtonState.Pressed) { element_actuel = char_texture_objet[i, j]; index_x = i; index_y = j; } } } if (souris.LeftButton == ButtonState.Pressed && souris.X < 8 * largeurFenetre / 11 && souris.Y < 9 * hauteurFenetre / 15) { for (int i = 0; i < sol.GetLength(0); i++) { for (int j = 0; j < sol.GetLength(1); j++) { if (new Rectangle(j * 40 - x, i * 40 - y, 40, 40).Intersects(sourisrect)) objet[i, j] = element_actuel; } } } } #endregion #region GestionBoutton if (souris.LeftButton == ButtonState.Pressed && souris.X > 8 * largeurFenetre / 11 && souris.Y < 9 * hauteurFenetre / 15) { for (int i = 0; i < rect_bouton.Length; i++) { if (rect_bouton[i].Intersects(sourisrect)) { if (i < rect_bouton.Length - 1) { niveau = i + 1; if (niveau == 1) element_actuel = char_texture_sol[0, 0]; if (niveau == 2) element_actuel = char_texture_decor[0, 0]; if (niveau == 3) element_actuel = char_texture_objet[0, 0]; index_x = 0; index_y = 0; } else { inter_affiche = true; } } } } if (souris.LeftButton == ButtonState.Released && inter_affiche) { inter_affiche = false; afficher_tout = !(afficher_tout); } #endregion #region Transition if (niveau == 5) { #region MenuTransition if (modeTransition == ModeTransition.Main) { Rectangle boutton_t = new Rectangle(2 * largeurFenetre / 35, dec_y_transition * 12 / 10, 7 * largeurFenetre / 35, 60); int k = 0; while (k < 3) { if(new Rectangle(boutton_t.X + k * (boutton_t.Width + 10), boutton_t.Y, boutton_t.Width, boutton_t.Height).Intersects(sourisrect) && souris.LeftButton == ButtonState.Pressed) { changementmode = true; index = k; } k++; } if (souris.LeftButton == ButtonState.Released && changementmode) { if (index == 0) { modeTransition = ModeTransition.Ajouter; } else if (index == 1) { modeTransition = ModeTransition.Modifier; } else if (index == 2) { modeTransition = ModeTransition.Supprimer; } else { } changementmode = false; index = 0; } } #endregion #region AjouterTransition if (modeTransition == ModeTransition.Ajouter) { Rectangle boutton_t = new Rectangle(2 * largeurFenetre / 35, dec_y_transition * 13 / 10, 7 * largeurFenetre / 35, 60); int k; k = 0; while (k < 2) { if (new Rectangle(boutton_t.X + k * (boutton_t.Width + 10), boutton_t.Y, boutton_t.Width, boutton_t.Height).Intersects(sourisrect) && souris.LeftButton == ButtonState.Pressed) { changementmode = true; index = k; } k++; } if (souris.LeftButton == ButtonState.Released && changementmode) { if (index == 0) { modeTransition = ModeTransition.Main; } else if (index == 1) { modeTransition = ModeTransition.DestinationNew; } else { } changementmode = false; index = 0; } if (etatprecedent == ButtonState.Released && souris.LeftButton == ButtonState.Pressed && souris.X < 8 * largeurFenetre / 11 && souris.Y < 9 * hauteurFenetre / 15) { for (int i = 0; i < sol.GetLength(0); i++) { for (int j = 0; j < sol.GetLength(1); j++) { if (new Rectangle(j * 40 - x, i * 40 - y, 40, 40).Intersects(sourisrect)) { debut = new Rectangle(j * 40, i * 40, 40, 40); } } } } if (etatprecedent == ButtonState.Pressed && souris.LeftButton == ButtonState.Released && souris.X < 8 * largeurFenetre / 11 && souris.Y < 9 * hauteurFenetre / 15) { for (int i = 0; i < sol.GetLength(0); i++) { for (int j = 0; j < sol.GetLength(1); j++) { if (new Rectangle(j * 40 - x, i * 40 - y, 40, 40).Intersects(sourisrect)) { fin = new Rectangle(j * 40, i * 40, 40, 40); } } } if (debut.X < fin.X) { if (debut.Y < fin.Y) { x_tel = debut.X; y_tel = debut.Y; largeur_tel = fin.X + 40 - debut.X; hauteur_tel = fin.Y + 40 - debut.Y; } else { x_tel = debut.X; y_tel = fin.Y; largeur_tel = fin.X + 40 - debut.X; hauteur_tel = debut.Y + 40 - fin.Y; } } else { if (debut.Y < fin.Y) { x_tel = fin.X; y_tel = debut.Y; largeur_tel = debut.X + 40 - fin.X; hauteur_tel = fin.Y + 40 - debut.Y; } else { x_tel = fin.X; y_tel = fin.Y; largeur_tel = debut.X + 40 - fin.X; hauteur_tel = debut.Y + 40 - fin.Y; } } } etatprecedent = souris.LeftButton; } #endregion #region AjouterTransitionDestination if (modeTransition == ModeTransition.DestinationNew) { Rectangle boutton_t = new Rectangle(2 * largeurFenetre / 35, dec_y_transition * 12 / 10, 7 * largeurFenetre / 35, 60); int k = 0; while (k < 2) { if (new Rectangle(boutton_t.X + k * (boutton_t.Width + 10), boutton_t.Y, boutton_t.Width, boutton_t.Height).Intersects(sourisrect) && souris.LeftButton == ButtonState.Pressed) { changementmode = true; index = k; } k++; } if (souris.LeftButton == ButtonState.Released && changementmode) { if (index == 0) { modeTransition = ModeTransition.Ajouter; } else if (index == 1) { modeTransition = ModeTransition.Main; gestionTeleportation.Add(x_tel, y_tel, x_dest, y_dest, destination.ToString(), numero_carte.ToString(), largeur_tel, hauteur_tel, 2); } else { } changementmode = false; index = 0; } ////////////////////////////////////////////////:: if (coord_fleche_g.Intersects(sourisrect) && souris.LeftButton == ButtonState.Pressed) { cliquefg = true; } if (souris.LeftButton == ButtonState.Released && cliquefg) { if (destination > 0) destination--; cliquefg = false; } if (coord_fleche_d.Intersects(sourisrect) && souris.LeftButton == ButtonState.Pressed) { cliquefd = true; } if (souris.LeftButton == ButtonState.Released && cliquefd) { if (destination < nb_cartes - 1) destination++; cliquefd = false; } /////////////////////////////////////////////// StreamReader sr2 = new StreamReader("DATA\\Carte\\" + destination + ".map"); StreamReader sr_decor2 = new StreamReader("DATA\\MUR\\" + destination + ".map"); string line2; int largeur_carte2, hauteur_carte2; largeur_carte2 = 0; hauteur_carte2 = 0; #region Creation Des Tableaux while (!sr2.EndOfStream) { line2 = sr2.ReadLine(); hauteur_carte2++; if (largeur_carte2 < line2.Length) largeur_carte2 = line2.Length; } sr2.BaseStream.Position = 0; hauteur2 = hauteur_carte2; largeur2 = largeur_carte2; sol2 = new char[hauteur_carte2, largeur_carte2]; decor2 = new char[hauteur_carte2, largeur_carte2]; #endregion #region Chargement Sol line2 = ""; int i = 0; while ((line2 = sr2.ReadLine()) != null) { for (int j = 0; j < sol2.GetLength(1); j++) { if (j < line2.Length) sol2[i, j] = line2[j]; else sol2[i, j] = ' '; } i++; } #endregion #region Chargement Decor line2 = ""; i = 0; while ((line2 = sr_decor2.ReadLine()) != null && i < hauteur_carte2) { for (int j = 0; j < decor2.GetLength(1); j++) { if (j < line2.Length) decor2[i, j] = line2[j]; else decor2[i, j] = ' '; } i++; } #endregion sr2.Close(); sr_decor2.Close(); /////////////////////////////////////////////// if (souris.LeftButton == ButtonState.Pressed && souris.X < 8 * largeurFenetre / 11 && souris.Y < 9 * hauteurFenetre / 15) { x_dest = souris.X + xx; y_dest = souris.Y + yy; } } #endregion #region Supprimer if (modeTransition == ModeTransition.Supprimer) { if (souris.LeftButton == ButtonState.Pressed && souris.X < 8 * largeurFenetre / 11 && souris.Y < 9 * hauteurFenetre / 15) { cliquetransition = true; } if (souris.LeftButton == ButtonState.Released && cliquetransition) { int i = 0; while (i < gestionTeleportation.liste_teleporteur.Count && !new Rectangle(gestionTeleportation.liste_teleporteur[i].Coordonnees.X - x, gestionTeleportation.liste_teleporteur[i].Coordonnees.Y - y, gestionTeleportation.liste_teleporteur[i].Coordonnees.Width, gestionTeleportation.liste_teleporteur[i].Coordonnees.Height).Intersects(sourisrect)) { i++; } if (i < gestionTeleportation.liste_teleporteur.Count) gestionTeleportation.liste_teleporteur.RemoveAt(i); cliquetransition = false; modeTransition = ModeTransition.Main; } } #endregion } #endregion }