/// <summary> /// Crée le tableau dans lequel les pieces vont être générées. /// </summary> /// <returns>tabRotation</returns> /// C'est le tableau vide dans lequel une piece va être générée. TypeBloc[,] CreationTableauRotation(TypeBloc PieceChoisis) { int taille; if (PieceChoisis == TypeBloc.Ligne) { taille = 4; } else if (PieceChoisis == TypeBloc.Carré) { taille = 2; } else { taille = 3; } TypeBloc[,] tabRotationVide = new TypeBloc[taille, taille]; int i; int j; for (i = 0; i < taille; i++) { for (j = 0; j < taille; j++) { tabRotationVide[i, j] = TypeBloc.None; } } return(tabRotationVide); }
/// <summary> /// Fait par Jo /// </summary> void Tester_PartieEstTerminee() { // Bloc utilisé pour les tests blocCourant = TypeBloc.T; //5. Jeu d'essai général si la fin de la partie est true // Mise en place des données du test colonneCourante = 3; ligneCourante = 1; tableauDeJeu[2, 3] = TypeBloc.Gelé; DeplacerBloc(TouchesJoueur.DéplacerBas); // Exécution de la méthode à tester Debug.Assert(PartieEstTerminee() == true, "Erreur lorsque la fin de la partie est true"); // Clean-up colonneCourante = 3; ligneCourante = 1; tableauDeJeu[2, 3] = TypeBloc.None; //6. Jeu d'essai général si la fin de la partie est false // Mise en place des données du test colonneCourante = 3; ligneCourante = 1; tableauDeJeu[3, 3] = TypeBloc.Gelé; DeplacerBloc(TouchesJoueur.DéplacerBas); // Exécution de la méthode à tester Debug.Assert(PartieEstTerminee() == false, "Erreur lorsque la fin de la partie est false"); // Clean-up colonneCourante = 3; ligneCourante = 1; tableauDeJeu[3, 3] = TypeBloc.None; }
/// <summary> /// Fait par Kevin /// </summary> /// <param name="blocActif"></param> //L.Kevin R. void AfficherBlocActif(TypeBloc blocActif) { if (blocActif == TypeBloc.Carré) { ChangerImageAffichage(Properties.Resources.Carré); } if (blocActif == TypeBloc.Ligne) { ChangerImageAffichage(Properties.Resources.Ligne); } if (blocActif == TypeBloc.J) { ChangerImageAffichage(Properties.Resources.J); } if (blocActif == TypeBloc.L) { ChangerImageAffichage(Properties.Resources.L); } if (blocActif == TypeBloc.S) { ChangerImageAffichage(Properties.Resources.S); } if (blocActif == TypeBloc.T) { ChangerImageAffichage(Properties.Resources.T); } if (blocActif == TypeBloc.Z) { ChangerImageAffichage(Properties.Resources.Z); } }
public async Task <IHttpActionResult> PutTypeBloc(int id, TypeBloc typeBloc) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != typeBloc.IdTypeBloc) { return(BadRequest()); } db.Entry(typeBloc).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TypeBlocExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
TypeBloc[,] PositionnerBlocSurGrille(TypeBloc pieceChoisis) { PictureBox pic = toutesImagesVisuelles[_yPosition, _xPosition]; TypeBloc[,] grilleJeu = InitialiserSurfaceDeJeu(); TypeBloc[,] grilleAvecBloc = ChoixPiece(pieceChoisis); _xPosition = _xPosition - grilleAvecBloc.GetLength(1) / 2 - 1; if (grilleAvecBloc.GetLength(1) == 2) { _xPosition++; } for (int iPos = 0; iPos < grilleAvecBloc.GetLength(0); iPos++) { for (int jPos = 0; jPos < grilleAvecBloc.GetLength(1); jPos++) { if (grilleAvecBloc[iPos, jPos] != TypeBloc.None) { grilleJeu[_yPosition + iPos, _xPosition + jPos] = pieceChoisis; pic = toutesImagesVisuelles[_yPosition + iPos, _xPosition + jPos]; pic.BackColor = Color.Green; } } } return(grilleJeu); }
Color GererCouleurBloc(TypeBloc bloc) { Color retour = Color.Black; if (bloc == TypeBloc.Carre) { retour = Color.Yellow; } if (bloc == TypeBloc.Ligne) { retour = Color.Turquoise; } if (bloc == TypeBloc.T) { retour = Color.Purple; } if (bloc == TypeBloc.L) { retour = Color.Orange; } if (bloc == TypeBloc.J) { retour = Color.Blue; } if (bloc == TypeBloc.S) { retour = Color.Green; } if (bloc == TypeBloc.Z) { retour = Color.Red; } return(retour); }
void MettreAJourPositionBlocDansTabLogique(TypeBloc bloc) { for (int i = 0; i < positionXRelative.Length; i++) { tabLogique[ligneCourante + positionYRelative[i], colonneCourante + positionXRelative[i]] = bloc; } }
private void Form1_Load(object sender, EventArgs e) { InitialiserSurfaceVisuelle(nbLignesJeu, nbColonnesJeu); grilleJeu = InitialiserSurfaceDeJeu(); pieceGenerer = GenererPieceAJouer(); TypeBloc[,] TabChoixPiece = ChoixPiece(pieceGenerer); PositionnerBlocSurGrille(pieceGenerer); }
/// <summary> /// Fait par Jo /// </summary> void Tester_BlocPeutBouger() { // Bloc utilisé pour les tests blocCourant = TypeBloc.T; //1. Jeu d'essai général pour la rotation placé au centre. // Mise en place des données du test colonneCourante = 5; ligneCourante = 5; // Exécution de la méthode à tester Debug.Assert(BlocPeutBouger(TouchesJoueur.RotationAntiHoraire) == true, "Erreur dans la rotation du bloc vers la gauche."); // Clean-up colonneCourante = 3; ligneCourante = 1; //2. Jeu d'essai particulié de la rotation sur un mur placé à gauche // Mise en place des données du test colonneCourante = 0; ligneCourante = 5; // Exécution de la méthode à tester Debug.Assert(BlocPeutBouger(TouchesJoueur.RotationAntiHoraire) == false, "Erreur dans la rotation du bloc vers la gauche sur le mur exterieur."); // Clean-up colonneCourante = 3; ligneCourante = 1; //3. Jeu d'essai particulié de la rotation sur un mur placé à droite // Mise en place des données du test colonneCourante = 10; ligneCourante = 5; // Exécution de la méthode à tester Debug.Assert(BlocPeutBouger(TouchesJoueur.RotationHoraire) == false, "Erreur dans la rotation du bloc vers la droite sur le mur exterieur."); // Clean-up colonneCourante = 3; ligneCourante = 1; //4. Jeu d'essai particulié de la rotation entouré de blocs // Mise en place des données du test colonneCourante = 4; ligneCourante = 4; tableauDeJeu[4, 4] = TypeBloc.Gelé; tableauDeJeu[4, 6] = TypeBloc.Gelé; tableauDeJeu[6, 5] = TypeBloc.Gelé; tableauDeJeu[6, 6] = TypeBloc.Gelé; tableauDeJeu[6, 4] = TypeBloc.Gelé; // Exécution de la méthode à tester for (int i = 0; i < 4; i++) { Debug.Assert(BlocPeutBouger(TouchesJoueur.RotationHoraire) == false, "Erreur dans la rotation du bloc vers la droite entouré de blocs."); } // Clean-up colonneCourante = 3; ligneCourante = 1; tableauDeJeu[4, 4] = TypeBloc.None; tableauDeJeu[4, 6] = TypeBloc.None; tableauDeJeu[6, 5] = TypeBloc.None; tableauDeJeu[6, 6] = TypeBloc.None; tableauDeJeu[6, 4] = TypeBloc.None; }
/// <summary> /// Place bloc dans le tableau /// </summary> /// <param name="BlocChoisis"></param> /// <returns></returns> TypeBloc[,] ChoixPiece(TypeBloc BlocChoisis) { TypeBloc[,] tabRotationVide = CreationTableauRotation(BlocChoisis); switch (BlocChoisis) { case TypeBloc.Carré: tabRotationVide[0, 0] = TypeBloc.Carré; tabRotationVide[0, 1] = TypeBloc.Carré; tabRotationVide[1, 0] = TypeBloc.Carré; tabRotationVide[1, 1] = TypeBloc.Carré; break; case TypeBloc.J: tabRotationVide[0, 1] = TypeBloc.J; tabRotationVide[1, 1] = TypeBloc.J; tabRotationVide[2, 1] = TypeBloc.J; tabRotationVide[0, 2] = TypeBloc.J; break; case TypeBloc.L: tabRotationVide[0, 1] = TypeBloc.L; tabRotationVide[1, 1] = TypeBloc.L; tabRotationVide[2, 1] = TypeBloc.L; tabRotationVide[2, 2] = TypeBloc.L; break; case TypeBloc.Ligne: tabRotationVide[0, 0] = TypeBloc.Ligne; tabRotationVide[1, 0] = TypeBloc.Ligne; tabRotationVide[2, 0] = TypeBloc.Ligne; tabRotationVide[3, 0] = TypeBloc.Ligne; break; case TypeBloc.S: tabRotationVide[0, 2] = TypeBloc.S; tabRotationVide[1, 1] = TypeBloc.S; tabRotationVide[1, 2] = TypeBloc.S; tabRotationVide[2, 1] = TypeBloc.S; break; case TypeBloc.T: tabRotationVide[0, 1] = TypeBloc.T; tabRotationVide[1, 1] = TypeBloc.T; tabRotationVide[1, 2] = TypeBloc.T; tabRotationVide[2, 1] = TypeBloc.T; break; case TypeBloc.Z: tabRotationVide[0, 0] = TypeBloc.Z; tabRotationVide[0, 1] = TypeBloc.Z; tabRotationVide[1, 1] = TypeBloc.Z; tabRotationVide[1, 2] = TypeBloc.Z; break; } return(tabRotationVide); }
/*-------------------Generation piece aléatoire-------------------------*/ /// <summary> /// Permet de choisir aléatoirement la piece qui va etre jouer. /// </summary> /// <returns>BlocChoisis</returns> /// C'est le la variable en TypeBloc qui a ete choisis. TypeBloc GenererPieceAJouer() { Random rnd = new Random(); //int pieceChoisis = rnd.Next(2, 7 + 1); int pieceChoisis = 3; TypeBloc blocChoisis = tabBlocPossible[pieceChoisis]; return(blocChoisis); }
public async Task <IHttpActionResult> GetTypeBloc(int id) { TypeBloc typeBloc = await db.TypeBloc.FindAsync(id); if (typeBloc == null) { return(NotFound()); } return(Ok(typeBloc)); }
public async Task <IHttpActionResult> PostTypeBloc(TypeBloc typeBloc) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.TypeBloc.Add(typeBloc); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = typeBloc.IdTypeBloc }, typeBloc)); }
public async Task <IHttpActionResult> DeleteTypeBloc(int id) { TypeBloc typeBloc = await db.TypeBloc.FindAsync(id); if (typeBloc == null) { return(NotFound()); } db.TypeBloc.Remove(typeBloc); await db.SaveChangesAsync(); return(Ok(typeBloc)); }
//Déplacement /// <summary> /// Fait descendre la piece à chaque tick (1000 millisecondes) /// </summary> void BougerPieceSurLaSurface() { bool peutDescendre = true; TypeBloc pieceChoisis = GenererPieceAJouer(); TypeBloc[,] grilleAvecBloc = ChoixPiece(pieceChoisis); PictureBox pic = toutesImagesVisuelles[_yPosition, _xPosition]; if (_yPosition < grilleJeu.GetLength(0)) { if (_yPosition == grilleJeu.GetLength(0) - 1) { //pic.BackColor = Color.White; grilleJeu[_yPosition, _xPosition] = TypeBloc.Gelé; _yPosition = 0; } else if (grilleJeu[_yPosition + 1, _xPosition] == TypeBloc.Gelé) { //pic.BackColor = Color.DarkGoldenrod; grilleJeu[_yPosition, _xPosition] = TypeBloc.Gelé; _yPosition = 0; } else { for (int iPos = 0; iPos < grilleAvecBloc.GetLength(0); iPos++) { for (int jPos = 0; jPos < grilleAvecBloc.GetLength(1); jPos++) { if (_yPosition > 19 && grilleJeu[_yPosition + iPos, _xPosition + jPos] != TypeBloc.None && _yPosition + iPos == nbLignesJeu - 1) { peutDescendre = false; _yPosition = 0; } } } if (peutDescendre == true) { _yPosition++; } DeplacementPiece(); } } }
/// <summary> /// /// </summary> //L.Kevin R. void InitialiserTour() { //position bloc colonneCourante = nbColonnesJeu / 2 - 1; ligneCourante = 1; //nouveau bloc blocCourant = ChoisirBlocAleatoire(); CreeNouveauBlocActif(blocCourant); //descente/seconde timerBlocDescente.Enabled = true; // Timer stopWatch.Start(); //affichage AfficherBlocActif(blocCourant); //score + retirer ligne score += AttribuerPoint(RetireerLignesCompletees()); lblScore.Text = score.ToString(); //fin partie GererPartieTerminee(); }
//ACusteau //Rôle : Trouver aléatoirement une nouvelle pièce à générer //Paramètre : Aucun //Retour : Le type de bloc à générer, choisi aléatoirement. TypeBloc TrouverNouvellePieceAGenerer() { TypeBloc blocActif = TypeBloc.None; int pieceActive = 0; Random rnd = new Random(); pieceActive = rnd.Next(2, 9); if (pieceActive == 2) { blocActif = TypeBloc.Carré; } if (pieceActive == 3) { blocActif = TypeBloc.Ligne; } if (pieceActive == 4) { blocActif = TypeBloc.T; } if (pieceActive == 5) { blocActif = TypeBloc.L; } if (pieceActive == 6) { blocActif = TypeBloc.J; } if (pieceActive == 7) { blocActif = TypeBloc.S; } if (pieceActive == 8) { blocActif = TypeBloc.Z; } return(blocActif); }
/// <summary> /// Fait par Jo /// </summary> /// <returns></returns> void CreeNouveauBlocActif(TypeBloc bloc) { // Carré if (bloc == TypeBloc.Carré) { //Positions Y blocActifY[0] = 0; blocActifY[1] = 0; blocActifY[2] = 1; blocActifY[3] = 1; //Positions X blocActifX[0] = 0; blocActifX[1] = 1; blocActifX[2] = 0; blocActifX[3] = 1; } // Ligne else if (bloc == TypeBloc.Ligne) { // Positions Y blocActifY[0] = -1; blocActifY[1] = 0; blocActifY[2] = 1; blocActifY[3] = 2; //Positions X blocActifX[0] = 0; blocActifX[1] = 0; blocActifX[2] = 0; blocActifX[3] = 0; } // T else if (bloc == TypeBloc.T) { // Positions Y blocActifY[0] = -1; blocActifY[1] = 0; blocActifY[2] = 0; blocActifY[3] = 0; //Positions X blocActifX[0] = 0; blocActifX[1] = -1; blocActifX[2] = 0; blocActifX[3] = 1; } // L else if (bloc == TypeBloc.L) { // Positions Y blocActifY[0] = -1; blocActifY[1] = 0; blocActifY[2] = 1; blocActifY[3] = 1; //Positions X blocActifX[0] = 0; blocActifX[1] = 0; blocActifX[2] = 0; blocActifX[3] = 1; } // J else if (bloc == TypeBloc.J) { // Positions Y blocActifY[0] = -1; blocActifY[1] = 0; blocActifY[2] = 1; blocActifY[3] = 1; //Positions X blocActifX[0] = 0; blocActifX[1] = 0; blocActifX[2] = 0; blocActifX[3] = -1; } // S else if (bloc == TypeBloc.S) { // Positions Y blocActifY[0] = 1; blocActifY[1] = 1; blocActifY[2] = 0; blocActifY[3] = 0; //Positions X blocActifX[0] = -1; blocActifX[1] = 0; blocActifX[2] = 0; blocActifX[3] = 1; } // Z else { // Positions Y blocActifY[0] = 0; blocActifY[1] = 0; blocActifY[2] = 1; blocActifY[3] = 1; //Positions X blocActifX[0] = -1; blocActifX[1] = 0; blocActifX[2] = 0; blocActifX[3] = 1; } }
void GererCreationBlocDansJeu(TypeBloc bloc) { if (bloc == TypeBloc.Carre) { positionYRelative[0] = 0; positionYRelative[1] = 1; positionYRelative[2] = 0; positionYRelative[3] = 1; positionXRelative[0] = 0; positionXRelative[1] = 0; positionXRelative[2] = 1; positionXRelative[3] = 1; } if (bloc == TypeBloc.Ligne) { positionYRelative[0] = 0; positionYRelative[1] = 0; positionYRelative[2] = 0; positionYRelative[3] = 0; positionXRelative[0] = 0; positionXRelative[1] = 1; positionXRelative[2] = 2; positionXRelative[3] = 3; } if (bloc == TypeBloc.T) { positionYRelative[0] = 0; positionYRelative[1] = 1; positionYRelative[2] = 1; positionYRelative[3] = 1; positionXRelative[0] = 1; positionXRelative[1] = 0; positionXRelative[2] = 1; positionXRelative[3] = 2; } if (bloc == TypeBloc.L) { positionYRelative[0] = 0; positionYRelative[1] = 1; positionYRelative[2] = 1; positionYRelative[3] = 1; positionXRelative[0] = 2; positionXRelative[1] = 0; positionXRelative[2] = 1; positionXRelative[3] = 2; } if (bloc == TypeBloc.J) { positionYRelative[0] = 0; positionYRelative[1] = 0; positionYRelative[2] = 0; positionYRelative[3] = 1; positionXRelative[0] = 0; positionXRelative[1] = 1; positionXRelative[2] = 2; positionXRelative[3] = 2; } if (bloc == TypeBloc.S) { positionYRelative[0] = 0; positionYRelative[1] = 0; positionYRelative[2] = 1; positionYRelative[3] = 1; positionXRelative[0] = 1; positionXRelative[1] = 2; positionXRelative[2] = 0; positionXRelative[3] = 1; } if (bloc == TypeBloc.Z) { positionYRelative[0] = 0; positionYRelative[1] = 0; positionYRelative[2] = 1; positionYRelative[3] = 1; positionXRelative[0] = 0; positionXRelative[1] = 1; positionXRelative[2] = 1; positionXRelative[3] = 2; } MettreAJourPositionBlocDansTabLogique(bloc); Color blocCouleur = GererCouleurBloc(bloc); AfficherBloc(blocCouleur); }
void GererTypeBlocs() { bloc = (TypeBloc)rnd.Next(2, 9); //TypeBloc.Carre; // }
//felix.b /// <summary> /// Cette méthode permet de choisir une forme à générer au hasard /// et contient ses formes /// </summary> /// <param name="ligneCourante"></param> /// <param name="coloneCourant"></param> /// <param name="formeDuBloc"></param> void GenererBloc() { coloneCourante = 0; ligneCourante = 0; int typeDeBloc = rnd.Next(0, 7 + 1); if (typeDeBloc == 0) { formeDuBloc = TypeBloc.J; } else if (typeDeBloc == 1) { formeDuBloc = TypeBloc.L; } else if (typeDeBloc == 2) { formeDuBloc = TypeBloc.LINE; } else if (typeDeBloc == 3) { formeDuBloc = TypeBloc.Z; } else if (typeDeBloc == 4) { formeDuBloc = TypeBloc.S; } else if (typeDeBloc == 5) { formeDuBloc = TypeBloc.SQUARE; } else if (typeDeBloc == 6) { formeDuBloc = TypeBloc.T; } if (formeDuBloc == TypeBloc.J) { blocActifX[0] = 1; blocActifY[0] = 0; blocActifX[1] = 1; blocActifY[1] = 1; blocActifX[2] = 1; blocActifY[2] = 2; blocActifX[3] = 0; blocActifY[3] = 2; } else if (formeDuBloc == TypeBloc.L) { blocActifX[0] = 0; blocActifY[0] = 0; blocActifX[1] = 0; blocActifY[1] = 1; blocActifX[2] = 0; blocActifY[2] = 2; blocActifX[3] = 1; blocActifY[3] = 2; } else if (formeDuBloc == TypeBloc.LINE)//La ligne est coucher { blocActifX[0] = 0; blocActifY[0] = 0; blocActifX[1] = 1; blocActifY[1] = 0; blocActifX[2] = 2; blocActifY[2] = 0; blocActifX[3] = 3; blocActifY[3] = 0; } else if (formeDuBloc == TypeBloc.S) { blocActifX[0] = 2; blocActifY[0] = 0; blocActifX[1] = 1; blocActifY[1] = 0; blocActifX[2] = 1; blocActifY[2] = 1; blocActifX[3] = 0; blocActifY[3] = 1; } else if (formeDuBloc == TypeBloc.SQUARE) { blocActifX[0] = 0; blocActifY[0] = 0; blocActifX[1] = 1; blocActifY[1] = 0; blocActifX[2] = 0; blocActifY[2] = 1; blocActifX[3] = 1; blocActifY[3] = 1; } else if (formeDuBloc == TypeBloc.T) { blocActifX[0] = 0; blocActifY[0] = 0; blocActifX[1] = 1; blocActifY[1] = 0; blocActifX[2] = 2; blocActifY[2] = 0; blocActifX[3] = 1; blocActifY[3] = 1; } else if (formeDuBloc == TypeBloc.Z) { blocActifX[0] = 0; blocActifY[0] = 0; blocActifX[1] = 1; blocActifY[1] = 0; blocActifX[2] = 1; blocActifY[2] = 1; blocActifX[3] = 2; blocActifY[3] = 1; } if (tableauDeJeu[blocActifY[0], blocActifX[0]] != TypeBloc.NONE && tableauDeJeu[blocActifY[1], blocActifX[1]] != TypeBloc.NONE && tableauDeJeu[blocActifY[2], blocActifX[2]] != TypeBloc.NONE && tableauDeJeu[blocActifY[3], blocActifX[3]] != TypeBloc.NONE) { timerPourDescenteDuJeu.Stop(); MessageBox.Show("souhaiter vous recommencer une partie ?", "Oups partie terminé", MessageBoxButtons.RetryCancel, MessageBoxIcon.Exclamation); } }