Example #1
0
        /// <summary>
        /// On écrase les tuiles de gazon par du sable
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        private void RemplacementGazonEnclos(int x, int y)
        {
            int longueur = 14;
            int hauteur  = 8;

            for (int i = 0; i < longueur; i++)
            {
                for (int j = 0; j < hauteur; j++)
                {
                    if (x + i > 0)
                    {
                        tabGazon[x + i, y + j] = TilesetImageGenerator.GetTile(TilesetImageGenerator.SABLE);
                        tabAjout[x + i, y + j] = TilesetImageGenerator.GetTile(TilesetImageGenerator.SABLE);
                    }
                }
            }

            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 8; j++)
                {
                    if (x + i > 0)
                    {
                        tabGazon[x + i, y + j] = TilesetImageGenerator.GetTile(TilesetImageGenerator.EAU);
                        tabAjout[x + i, y + j] = TilesetImageGenerator.GetTile(TilesetImageGenerator.EAU);
                    }
                }
            }
        }
Example #2
0
 /// <summary>
 /// Creation des enclos
 /// </summary>
 private void PeuplerBitmapFence()
 {
     for (int i = 0; i < bmFence.GetLength(0); i++)
     {
         for (int j = 0; j < bmFence.GetLength(1); j++)
         {
             if (j == 6 && i == 10)
             {
                 bmFence[i, j] = TilesetImageGenerator.GetTile(43);
             }
             else if ((j == 0 && i != 13) || (j == 6 && i != 13))
             {
                 bmFence[i, j] = TilesetImageGenerator.GetTile(1);
             }
             else if ((i == 0 || i == 13) && (j != 0 || j != 6))
             {
                 bmFence[i, j] = TilesetImageGenerator.GetTile(2);
             }
             else
             {
                 bmFence[i, j] = TilesetImageGenerator.GetTile(0);
             }
         }
     }
 }
Example #3
0
 /// <summary>
 /// Ajouter un enclos d'animal
 /// </summary>
 /// <param name="x">Positionnement horizontale</param>
 /// <param name="y">Positionnement verticale</param>
 private void AjoutTuileEnclos(int x, int y, int longueur, int hauteur)
 {
     for (int i = 0; i < longueur; i++)
     {
         for (int j = 0; j < hauteur; j++)
         {
             if (i == 0 || i == longueur - 1)
             {
                 tabAjout[x + i, y + j] = TilesetImageGenerator.GetTile(TilesetImageGenerator.CLOTURE_PIERRE_COIN_GAUCHE);
             }
             if (j == 0)
             {
                 tabAjout[x + i, y + j] = TilesetImageGenerator.GetTile(TilesetImageGenerator.CLOTURE_PIERRE_HAUT);
             }
             if (j == hauteur - 1)
             {
                 tabAjout[x + i, y + j] = TilesetImageGenerator.GetTile(TilesetImageGenerator.CLOTURE_PIERRE_BAS_HAUT);
             }
             if ((i == 0 && j == 0) || (i == 0 && j == hauteur - 1))
             {
                 tabAjout[x + i, y + j] = TilesetImageGenerator.GetTile(TilesetImageGenerator.CLOTURE_PIERRE_COIN_GAUCHE);
             }
             if (i == longueur - 1 && j == hauteur - 1)
             {
                 tabAjout[x + i, y + j] = TilesetImageGenerator.GetTile(TilesetImageGenerator.CLOTURE_PIERRE_COIN_BAS_DROITE);
             }
             if (i == longueur - 1 && j == 0)
             {
                 tabAjout[x + i, y + j] = TilesetImageGenerator.GetTile(TilesetImageGenerator.CLOTURE_PIERRE_COIN_HAUT_DROITE);
             }
         }
     }
 }
Example #4
0
 /// <summary>
 /// Ajout de l'enclos de rhinocéros en bas à gauche
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="longueur"></param>
 /// <param name="hauteur"></param>
 private void AjoutTuileEnclosRhino(int x, int y, int longueur, int hauteur)
 {
     //Il faudra changer dans tabGazon pour changer au sable pour l'esthetique
     for (int i = 0; i < longueur; i++)
     {
         for (int j = 0; j < hauteur; j++)
         {
             if (i == 0 || i == longueur - 1)
             {
                 tabAjout[x + i, y + j] = TilesetImageGenerator.GetTile(TilesetImageGenerator.CLOTURE_PIERRE_COIN_GAUCHE);
             }
             if (j == 0)
             {
                 tabAjout[x + i, y + j] = TilesetImageGenerator.GetTile(TilesetImageGenerator.CLOTURE_PIERRE_HAUT);
             }
             if (j == hauteur - 1)
             {
                 tabAjout[x + i, y + j] = TilesetImageGenerator.GetTile(TilesetImageGenerator.CLOTURE_PIERRE_BAS_HAUT);
             }
             if ((i == 0 && j == 0) || (i == 0 && j == hauteur - 1))
             {
                 tabAjout[x + i, y + j] = TilesetImageGenerator.GetTile(TilesetImageGenerator.CLOTURE_PIERRE_COIN_GAUCHE);
             }
             if (i == longueur - 1 && j == hauteur - 1)
             {
                 tabAjout[x + i, y + j] = TilesetImageGenerator.GetTile(TilesetImageGenerator.CLOTURE_PIERRE_COIN_BAS_DROITE);
             }
             if (i == longueur - 1 && j == 0)
             {
                 tabAjout[x + i, y + j] = TilesetImageGenerator.GetTile(TilesetImageGenerator.CLOTURE_PIERRE_COIN_HAUT_DROITE);
             }
         }
     }
 }
Example #5
0
        /// <summary>
        /// Creation des bancs verticals
        /// </summary>
        private void PeuplerBitmapBenchUp()
        {
            int countBenchV = 37;

            for (int i = 0; i < bmBenchV.GetLength(0); i++)
            {
                bmBenchV[i] = TilesetImageGenerator.GetTile(countBenchV);
                countBenchV++;
            }
        }
Example #6
0
        /// <summary>
        /// Creation des bancs horizontals
        /// </summary>
        private void PeuplerBitmapBenchSide()
        {
            int countBenchH = 34;

            for (int i = 0; i < bmBenchH.GetLength(0); i++)
            {
                bmBenchH[i] = TilesetImageGenerator.GetTile(countBenchH);
                countBenchH++;
            }
        }
Example #7
0
 /// <summary>
 /// Ajout des buissons
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="longueur"></param>
 /// <param name="hauteur"></param>
 private void AjoutTuileBuisson(int x, int y, int longueur, int hauteur)
 {
     for (int i = 0; i < longueur; i++)
     {
         for (int j = 0; j < hauteur; j++)
         {
             tabAjout[x + i, y + j] = TilesetImageGenerator.GetTile(TilesetImageGenerator.BUISSON);
         }
     }
 }
Example #8
0
        /// <summary>
        /// Creation des boites de fruits
        /// </summary>
        private void PeuplerBitmapApple()
        {
            int countApple = 39;

            for (int i = 0; i < bmApple.GetLength(0); i++)
            {
                bmApple[i] = TilesetImageGenerator.GetTile(countApple);
                countApple++;
            }
        }
Example #9
0
 /// <summary>
 /// Ajout des tuiles divers dans le jeu
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="longueur"></param>
 /// <param name="hauteur"></param>
 /// <param name="tile"></param>
 private void AjoutTuileDivers(int x, int y, int longueur, int hauteur, int tile)
 {
     for (int i = 0; i < longueur; i++)
     {
         for (int j = 0; j < hauteur; j++)
         {
             tabAjout[x + i, y + j] = TilesetImageGenerator.GetTile(tile);
             tile += 1;
         }
     }
 }
Example #10
0
 /// <summary>
 /// On vérifie que le joueur n'a pas cliqué sur un enclos (utilisé avec !)
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <returns></returns>
 private bool SurEnclos(int x, int y)
 {
     if (Map.GetTabAjout()[x, y] == TilesetImageGenerator.GetTile(TilesetImageGenerator.CLOTURE_PIERRE_HAUT) ||
         Map.GetTabAjout()[x, y] == TilesetImageGenerator.GetTile(TilesetImageGenerator.CLOTURE_PIERRE_COIN_HAUT_DROITE) ||
         Map.GetTabAjout()[x, y] == TilesetImageGenerator.GetTile(TilesetImageGenerator.CLOTURE_PIERRE_COIN_GAUCHE) ||
         Map.GetTabAjout()[x, y] == TilesetImageGenerator.GetTile(TilesetImageGenerator.CLOTURE_PIERRE_COIN_BAS_DROITE) ||
         Map.GetTabAjout()[x, y] == TilesetImageGenerator.GetTile(TilesetImageGenerator.CLOTURE_PIERRE_BAS_HAUT))
     {
         return(true);
     }
     return(false);
 }
Example #11
0
 /// <summary>
 /// Ajout de la route
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="longueur"></param>
 /// <param name="hauteur"></param>
 private void AjoutTuileRoute(int x, int y, int longueur, int hauteur)
 {
     for (int i = 0; i < longueur; i++)
     {
         for (int j = 0; j < hauteur; j++)
         {
             if (i > 0)
             {
                 tabAjout[x + i, y + j] = TilesetImageGenerator.GetTile(TilesetImageGenerator.ASPHALTE);
             }
         }
     }
 }
Example #12
0
        /// <summary>
        /// Creation du puits
        /// </summary>
        private void PeuplerBitmapWell()
        {
            int countWell = 25;

            for (int i = 0; i < bmWell.GetLength(0); i++)
            {
                for (int j = 0; j < bmWell.GetLength(1); j++)
                {
                    bmWell[i, j] = TilesetImageGenerator.GetTile(countWell);
                    countWell++;
                }
            }
        }
Example #13
0
 /// <summary>
 /// Vérifie qu'il peut se déplace seulement sur une tuile de gazon, asphalte ou sable
 /// </summary>
 /// <param name="tab"></param>
 /// <returns></returns>
 public bool VerifDeplacementObstacleGauche(Bitmap[,] tab)
 {
     if (tab[x - 1, y] == TilesetImageGenerator.GetTile(TilesetImageGenerator.SABLE) ||
         tab[x - 1, y] == TilesetImageGenerator.GetTile(TilesetImageGenerator.GAZON) ||
         tab[x - 1, y] == TilesetImageGenerator.GetTile(TilesetImageGenerator.ASPHALTE))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #14
0
        /// <summary>
        /// Creation de la maison
        /// </summary>
        private void PeuplerBitmapHouse()
        {
            int countHouse = 5;

            for (int i = 0; i < bmHouse.GetLength(0); i++)
            {
                for (int j = 0; j < bmHouse.GetLength(1); j++)
                {
                    bmHouse[i, j] = TilesetImageGenerator.GetTile(countHouse);
                    countHouse++;
                }
            }
        }
Example #15
0
        /// <summary>
        /// Affiche les informations de l'animal dans les labels
        /// </summary>
        /// <param name="_liste"></param>
        /// <param name="indexAnimal"></param>
        public void AfficherInformationAnimal(List <Animal> _liste, int indexAnimal)
        {
            LblEnceinte.Visible      = false;
            LblEnceinteEcrit.Visible = false;
            index                   = indexAnimal;
            listeAnimal             = _liste;
            LblTypeEcrit.Text       = _liste[index].TypeAnimal.ToString();
            LblGenreEcrit.Text      = _liste[index].Genre.ToString();
            LblVieillesseEcrit.Text = _liste[index].Vieillesse.ToString();

            //Pour afficher combien de jours l'animal a faim
            if (_liste[index].Etat.ToString() == "Faim")
            {
                LblEtatEcrit.Text = _liste[index].Etat.ToString() + ", " + _liste[index].TempsZooAnimal.ToString() + " jours";
            }
            else
            {
                LblEtatEcrit.Text = _liste[index].Etat.ToString();
            }

            //Si c'est une femelle, affiche si elle est enceinte
            if (LblGenreEcrit.Text == "Femelle")
            {
                foreach (Animal a in _liste)
                {
                    //Il faut avoir au moins 1 male dans l'enclos, qu'elle soit une adulte et qu'ils soient du meme type d'animal
                    if (a.Genre == Genre.Male &&
                        a.TypeAnimal == _liste[index].TypeAnimal &&
                        _liste[index].Vieillesse != Vieillesse.Bebe)
                    {
                        LblEnceinte.Visible      = true;
                        LblEnceinteEcrit.Visible = true;
                        LblEnceinteEcrit.Text    = _liste[index].Enceinte.ToString();
                        break;
                    }
                }
            }

            if (LblTypeEcrit.Text == "Licorne")
            {
                PicAnimal.Image = TilesetImageGenerator.GetTile(TilesetImageGenerator.LICORNE_BAS);
            }
            else if (LblTypeEcrit.Text == "Rhino")
            {
                PicAnimal.Image = TilesetImageGenerator.GetTile(TilesetImageGenerator.RHINO_BAS);
            }
            else
            {
                PicAnimal.Image = TilesetImageGenerator.GetTile(TilesetImageGenerator.LION_BAS);
            }
        }
Example #16
0
        private void DessinerPillar(Graphics gr)
        {
            Image pillarTop = TilesetImageGenerator.GetTile(3);

            gr.DrawImage(pillarTop, 17 * 32, 0 * 32, 32, 32);
            gr.DrawImage(pillarTop, 21 * 32, 0 * 32, 32, 32);
            gr.DrawImage(pillarTop, 17 * 32, 23 * 32, 32, 32);
            gr.DrawImage(pillarTop, 21 * 32, 23 * 32, 32, 32);

            gr.DrawImage(pillarTop, 17 * 32, 1 * 32, 32, 32);
            gr.DrawImage(pillarTop, 21 * 32, 1 * 32, 32, 32);
            gr.DrawImage(pillarTop, 17 * 32, 24 * 32, 32, 32);
            gr.DrawImage(pillarTop, 21 * 32, 24 * 32, 32, 32);
        }
Example #17
0
        /// <summary>
        /// Méthode paint
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            Graphics g = e.Graphics;

            //Dessin initiale de la map
            for (int i = 0; i < tabGazon.GetLength(0); i++)
            {
                for (int j = 0; j < tabGazon.GetLength(1); j++)
                {
                    g.DrawImage(tabGazon[i, j], i * dimensionTuile, j * dimensionTuile, dimensionTuile, dimensionTuile);
                    g.DrawImage(tabAjout[i, j], i * dimensionTuile, j * dimensionTuile, dimensionTuile, dimensionTuile);
                }
            }
            //Dessiner hero
            int direction_h = hero.DeterminerOrientation();

            g.DrawImage(hero.TabOrientation[direction_h], hero.X * dimensionTuile, hero.Y * dimensionTuile, dimensionTuile, dimensionTuile);

            //Dessiner animaux
            foreach (Animal a in listeAnimal)
            {
                int direction = a.DeterminerOrientation();
                g.DrawImage(a.TabTypeAnimal[direction], a.X * dimensionTuile, a.Y * dimensionTuile, dimensionTuile, dimensionTuile);
            }

            //Dessiner visiteurs
            foreach (Visiteur v in listeVisiteur)
            {
                int direction = v.DeterminerOrientation();
                g.DrawImage(v.TabOrientation[direction], v.X * dimensionTuile, v.Y * dimensionTuile, dimensionTuile, dimensionTuile);
            }

            //Dessiner concierge
            foreach (Concierge c in listeConcierge)
            {
                int direction = c.DeterminerOrientation();
                g.DrawImage(c.TabOrientation[direction], c.X * dimensionTuile, c.Y * dimensionTuile, dimensionTuile, dimensionTuile);
                Bitmap[] testbmp = c.TabOrientation;
                //Console.WriteLine("Concierge: " + c.X + "," + c.Y);
            }

            //Dessiner dechet
            foreach (Dechet d in listeDechet)
            {
                g.DrawImage(TilesetImageGenerator.GetTile(TilesetImageGenerator.DECHET), d.X * dimensionTuile, d.Y * dimensionTuile, dimensionTuile, dimensionTuile);
            }
        }
Example #18
0
        /// <summary>
        /// Constructeur du User Control Map et ce qui s'initialise au départ
        /// </summary>
        public Map()
        {
            InitializeComponent();
            //test
            hero = new Hero(46, 20, tabAjout, listeVisiteur, listeConcierge, listeAnimal);
            for (int x = 0; x < tabGazon.GetLength(0); x++)
            {
                for (int y = 0; y < tabGazon.GetLength(1); y++)
                {
                    tabGazon[x, y] = TilesetImageGenerator.GetTile(TilesetImageGenerator.GAZON);
                }
            }

            for (int x = 0; x < tabAjout.GetLength(0); x++)
            {
                for (int y = 0; y < tabAjout.GetLength(1); y++)
                {
                    tabAjout[x, y] = TilesetImageGenerator.GetTile(TilesetImageGenerator.GAZON);
                }
            }
            RemplacementGazonEnclos(0, 1);        //sable dans l'enclos
            AjoutTuileEnclos(0, 1, 14, 8);        //enclos en haut à gauche
            AjoutTuileEnclos(17, 1, 14, 8);       //enclos en haut au milieu
            AjoutTuileEnclos(34, 1, 14, 8);       //enclos en haut à droite
            AjoutTuileEnclosRhino(0, 11, 31, 10); //gros enclos en bas a gauche
            AjoutTuileBuisson(14, 1, 3, 8);       //buissons en haut a gauche
            AjoutTuileBuisson(31, 1, 3, 8);       //buissons en haut a droite
            AjoutTuileBuisson(31, 11, 3, 12);     //buissons en bas
            AjoutTuileBuisson(48, 1, 1, 22);      //buisson seul a droite
            AjoutTuileBuisson(0, 0, 49, 1);       //buisson en haut completement
            AjoutTuileRoute(0, 9, 49, 2);         //route horizontale
            AjoutTuileRoute(33, 11, 16, 12);      //route entrée
            AjoutTuileBuisson(47, 9, 2, 14);
            AjoutTuileDivers(43, 15, 4, 5, 18);   //MAISON
            AjoutTuileDivers(7, 8, 1, 1, 50);     //porte enclos en haut a gauche
            AjoutTuileDivers(24, 8, 1, 1, 50);    //porte enclos en haut au milieu
            AjoutTuileDivers(41, 8, 1, 1, 50);    //porte enclos en haut a droite
            AjoutTuileDivers(15, 11, 1, 1, 50);   //porte enclos en bas

            //Pour enlever les screen flash quand on se deplace, le CreateParams n'aide pas
            this.SetStyle(
                ControlStyles.AllPaintingInWmPaint |
                ControlStyles.UserPaint |
                ControlStyles.DoubleBuffer,
                true);
        }
Example #19
0
 private void PeuplerBitmapFenceUp()
 {
     for (int i = 0; i < bmFenceVert.GetLength(0); i++)
     {
         if (i == 19 || i == 20 || i == 21)
         {
             bmFenceVert[i] = TilesetImageGenerator.GetTile(0);
         }
         else if (i == 12)
         {
             bmFenceVert[i] = TilesetImageGenerator.GetTile(41);
         }
         else
         {
             bmFenceVert[i] = TilesetImageGenerator.GetTile(2);
         }
     }
 }
Example #20
0
 /// <summary>
 /// Construction de la rue et du gazon
 /// </summary>
 private void PeuplerBitmapMap()
 {
     for (int i = 0; i < bmMap.GetLength(0); i++)
     {
         for (int j = 0; j < bmMap.GetLength(1); j++)
         {
             if ((i == 2 && (j > 1 && j < 23)) || i == 19 || (i == 36 && (j > 1 && j < 23)) ||
                 (i == 40 && (j > 4 && j < 13)) || (j == 2 && (i > 1 && i < 37)) || (j == 12 && (i > 1 && i < 41)) ||
                 (j == 22 && (i > 1 && i < 37)) || (j == 23 && i == 18) || (j == 23 && i == 20) || (j == 24 && i == 18) ||
                 (j == 24 && i == 20) || (j == 0 && i == 18) || (j == 0 && i == 20) || (j == 1 && i == 18) || (j == 1 && i == 20))
             {
                 bmMap[i, j] = TilesetImageGenerator.GetTile(41);
             }
             else
             {
                 bmMap[i, j] = TilesetImageGenerator.GetTile(0);
             }
         }
     }
 }
Example #21
0
        /// <summary>
        /// Methode qui permet de cliquer sur la map
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Map_MouseClick(object sender, MouseEventArgs e)
        {
            //Permet de creer un animal dans l'enclos et ajoute un visiteur (1:1), permet de nourrir l'animal et d'enlever les dechets
            switch (e.Button)
            {
            case MouseButtons.Left:

                if (bmInteraction[e.X / 32, e.Y / 32] && interieurEnclos[e.X / 32, e.Y / 32] && noMouvAnimal[e.X / 32, e.Y / 32])
                {
                    int xAnimal = e.X / 32;
                    int yAnimal = e.Y / 32;
                    switch (animalChoisi)
                    {
                    case "Lion":
                        if (bmInteraction[e.X / 32, e.Y / 32] && interieurEnclos[e.X / 32, e.Y / 32] &&
                            (enclosAnimal[e.X / 32, e.Y / 32] == null || enclosAnimal[e.X / 32, e.Y / 32] == Animaux.Lion))
                        {
                            listeAnimaux.Add(new Animal(Animaux.Lion, xAnimal, yAnimal));
                            bmAnimaux[e.X / 32, e.Y / 32] = TilesetImageGenerator.GetTile(44);
                            placedAnimal = true;
                            prixAnimal   = 35;
                            RemplirEnclosAnimal(e, listeAnimaux.Last().TypeAnimal);
                            AjouterVisiteur();
                        }
                        animalChoisi = "";
                        break;

                    case "Mouton":
                        if (bmInteraction[e.X / 32, e.Y / 32] && interieurEnclos[e.X / 32, e.Y / 32] &&
                            (enclosAnimal[e.X / 32, e.Y / 32] == null || enclosAnimal[e.X / 32, e.Y / 32] == Animaux.Mouton))
                        {
                            listeAnimaux.Add(new Animal(Animaux.Mouton, xAnimal, yAnimal));
                            bmAnimaux[e.X / 32, e.Y / 32] = TilesetImageGenerator.GetTile(45);
                            placedAnimal = true;
                            prixAnimal   = 20;
                            RemplirEnclosAnimal(e, listeAnimaux.Last().TypeAnimal);
                            AjouterVisiteur();
                        }
                        animalChoisi = "";
                        break;

                    case "Grizzly":
                        if (bmInteraction[e.X / 32, e.Y / 32] && interieurEnclos[e.X / 32, e.Y / 32] &&
                            (enclosAnimal[e.X / 32, e.Y / 32] == null || enclosAnimal[e.X / 32, e.Y / 32] == Animaux.Grizzly))
                        {
                            listeAnimaux.Add(new Animal(Animaux.Grizzly, xAnimal, yAnimal));
                            bmAnimaux[e.X / 32, e.Y / 32] = TilesetImageGenerator.GetTile(46);
                            placedAnimal = true;
                            prixAnimal   = 30;
                            RemplirEnclosAnimal(e, listeAnimaux.Last().TypeAnimal);
                            AjouterVisiteur();
                        }
                        animalChoisi = "";
                        break;

                    case "Rhino":
                        if (bmInteraction[e.X / 32, e.Y / 32] && interieurEnclos[e.X / 32, e.Y / 32] &&
                            (enclosAnimal[e.X / 32, e.Y / 32] == null || enclosAnimal[e.X / 32, e.Y / 32] == Animaux.Rhinoceros))
                        {
                            listeAnimaux.Add(new Animal(Animaux.Rhinoceros, xAnimal, yAnimal));
                            bmAnimaux[e.X / 32, e.Y / 32] = TilesetImageGenerator.GetTile(47);
                            placedAnimal = true;
                            prixAnimal   = 40;
                            RemplirEnclosAnimal(e, listeAnimaux.Last().TypeAnimal);
                            AjouterVisiteur();
                        }
                        animalChoisi = "";
                        break;

                    case "Licorne":
                        if (bmInteraction[e.X / 32, e.Y / 32] && interieurEnclos[e.X / 32, e.Y / 32] &&
                            (enclosAnimal[e.X / 32, e.Y / 32] == null || enclosAnimal[e.X / 32, e.Y / 32] == Animaux.Licorne))
                        {
                            listeAnimaux.Add(new Animal(Animaux.Licorne, xAnimal, yAnimal));
                            bmAnimaux[e.X / 32, e.Y / 32] = TilesetImageGenerator.GetTile(48);
                            placedAnimal = true;
                            prixAnimal   = 50;
                            RemplirEnclosAnimal(e, listeAnimaux.Last().TypeAnimal);
                            AjouterVisiteur();
                        }
                        animalChoisi = "";
                        break;

                    case "Buffle":
                        if (bmInteraction[e.X / 32, e.Y / 32] && interieurEnclos[e.X / 32, e.Y / 32] &&
                            (enclosAnimal[e.X / 32, e.Y / 32] == null || enclosAnimal[e.X / 32, e.Y / 32] == Animaux.Buffle))
                        {
                            listeAnimaux.Add(new Animal(Animaux.Buffle, xAnimal, yAnimal));
                            bmAnimaux[e.X / 32, e.Y / 32] = TilesetImageGenerator.GetTile(49);
                            placedAnimal = true;
                            prixAnimal   = 40;
                            RemplirEnclosAnimal(e, listeAnimaux.Last().TypeAnimal);
                            AjouterVisiteur();
                        }
                        animalChoisi = "";
                        break;
                    }
                }
                else if (bmInteraction[e.X / 32, e.Y / 32] && conciergeChoisi && (e.X / 32) < 38 && noMouvCoordAI[e.X / 32, e.Y / 32] /** && noMouvTrash[e.X / 32, e.X / 32]**/)
                {
                    conciergeChoisi = false;
                    bmVisiteurEtConcierge[e.X / 32, e.Y / 32] = GeneratorPersonnage.GetTile(40);
                    AjouterConcierge(e.X / 32, e.Y / 32);
                    conciergeChoisi = false;
                }
                else if (bmInteraction[e.X / 32, e.Y / 32] && !noMouvTrash[e.X / 32, e.Y / 32])
                {
                    foreach (Point p in listeTrash)
                    {
                        if (p.X == e.X / 32 && p.Y == e.Y / 32)
                        {
                            listeTrash.Remove(p);
                            break;
                        }
                    }
                }
                else if (bmInteraction[e.X / 32, e.Y / 32] && !noMouvAnimal[e.X / 32, e.Y / 32])
                {
                    foreach (Animal a in listeAnimaux)
                    {
                        if (a.x == e.X / 32 && a.y == e.Y / 32)
                        {
                            a.Nourri            = true;
                            a.TimePassedLastFed = 0;
                            SoundPlayer soundPlayer;
                            switch (a.TypeAnimal)
                            {
                            case Animaux.Lion:
                                soundPlayer = new SoundPlayer("lion.wav");
                                soundPlayer.PlaySync();
                                break;

                            case Animaux.Mouton:
                                soundPlayer = new SoundPlayer("mouton.wav");
                                soundPlayer.PlaySync();
                                break;

                            case Animaux.Grizzly:
                                soundPlayer = new SoundPlayer("ours.wav");
                                soundPlayer.PlaySync();
                                break;

                            case Animaux.Rhinoceros:
                                soundPlayer = new SoundPlayer("hippopotame.wav");
                                soundPlayer.PlaySync();
                                break;

                            case Animaux.Licorne:
                                soundPlayer = new SoundPlayer("licorne.wav");
                                soundPlayer.PlaySync();
                                break;

                            case Animaux.Buffle:
                                soundPlayer = new SoundPlayer("buffalo.wav");
                                soundPlayer.PlaySync();
                                break;
                            }
                        }
                    }
                }
                Refresh();
                break;

            //Permet de get les informations de soi un animal ou un visiteur
            case MouseButtons.Right:

                int comptA = 0;
                int comptV = 0;

                foreach (Animal a in listeAnimaux)
                {
                    if (a.x == e.X / 32 && a.y == e.Y / 32)
                    {
                        placeListeAnimal = comptA;
                        break;
                    }
                    comptA++;
                }

                foreach (Visiteur v in listeVisiteur)
                {
                    if (v.x == e.X / 32 && v.y == e.Y / 32)
                    {
                        placeListeVisiteur = comptV;
                        break;
                    }
                    comptV++;
                }

                break;
            }
        }
Example #22
0
 private void DessinerTrash(Graphics gr, Point p)
 {
     gr.DrawImage(TilesetImageGenerator.GetTile(42), p.X * 32, p.Y * 32, 32, 32);
 }
Example #23
0
        /// <summary>
        /// Intéraction du joueur avec la souris selon le click gauche ou droit
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Map_MouseDown(object sender, MouseEventArgs e)
        {
            InformationAnimal.Visible   = false;
            InformationVisiteur.Visible = false;
            bool   animalPresent    = false;
            String animalDeterminer = DeterminerEnclos();
            int    x = e.X / 32;
            int    y = e.Y / 32;

            switch (e.Button)
            {
            case MouseButtons.Left:
                if (EstAdjacentHero(x, y))
                {
                    if (EstDansEnclos())
                    {
                        foreach (Animal a in _listeAnimal)
                        {
                            if (x + 1 > a.X && x - 1 < a.X)
                            {
                                if (y + 1 > a.Y && y - 1 < a.Y)
                                {
                                    //On nourrit l'animal et il émet un son
                                    animalPresent = true;
                                    a._etat       = Etat.Nourrit;
                                    switch (animalDeterminer)
                                    {
                                    case "RHINO":
                                        sonRhino.Play();
                                        nourrirAnimal++;
                                        break;

                                    case "LION":
                                        sonLion.Play();
                                        nourrirAnimal++;
                                        break;

                                    case "LICORNE":
                                        sonLicorne.Play();
                                        nourrirAnimal++;
                                        break;
                                    }
                                    break;
                                }
                            }
                        }
                        if (!animalPresent)
                        {
                            if (animalDeterminer != "")
                            {
                                if (!SurEnclos(x, y))
                                {
                                    //On ajoute un animal dans l'enclos
                                    switch (animalDeterminer)
                                    {
                                    case "RHINO":
                                        Map.AjouterAdulteRhino(x, y);
                                        nbRhino++;
                                        break;

                                    case "LION":
                                        Map.AjouterAdulteLion(x, y);
                                        nbLion++;
                                        break;

                                    case "LICORNE":
                                        Map.AjouterAdulteLicorne(x, y);
                                        nbLicorne++;
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        //On ramasse le déchet si c'est adjacent au héro
                        if (ValiderDechet(x, y))
                        {
                            List <Dechet> listeTemp = _listeDechet;
                            int           index     = 0;
                            foreach (Dechet d in listeTemp)
                            {
                                if (d.X == x)
                                {
                                    if (d.Y == y)
                                    {
                                        listeTemp.RemoveAt(index);
                                        _listeDechet = listeTemp;
                                        nbDechet     = _listeDechet.Count;
                                        break;
                                    }
                                }
                                index++;
                            }
                        }
                        else
                        {
                            bool dechetExistant = false;
                            if (!(Map.GetTabAjout()[Map.Hero.X, Map.Hero.Y] == TilesetImageGenerator.GetTile(TilesetImageGenerator.PORTE_ENCLOS)))
                            {
                                foreach (Dechet d in _listeDechet)
                                {
                                    if (d.X == x && d.Y == y)
                                    {
                                        dechetExistant = true;
                                        break;
                                    }
                                }
                                //On ajoute un concierge
                                if (!dechetExistant)
                                {
                                    Map.AjoutConcierge(x, y);
                                }
                            }
                        }
                    }
                }
                break;

            case MouseButtons.Right:
                if (!EstAdjacentHero(x, y))
                {
                    int indexAnimal   = 0;
                    int indexVisiteur = 0;
                    foreach (Animal a in _listeAnimal)
                    {
                        if (x + 1 > a.X && x - 1 < a.X)
                        {
                            if (y + 1 > a.Y && y - 1 < a.Y)     //il faut viser en bas a gauche du carre, j'ai ajouter + 1 ou - 1 pour une marge d'erreur
                            {
                                //On affiche les informations de l'animal avec le User Control
                                InformationAnimal.AfficherInformationAnimal(_listeAnimal, indexAnimal);
                                InformationAnimal.Visible = true;
                                break;
                            }
                        }
                        indexAnimal++;
                    }
                    indexAnimal = 0;

                    foreach (Visiteur v in _listeVisiteur)
                    {
                        if (x + 1 > v.X && x - 1 < v.X)
                        {
                            if (y + 1 > v.Y && y - 1 < v.Y)     //il faut viser en bas a gauche du carre, j'ai ajouter + 1 ou - 1 pour une marge d'erreur
                            {
                                //On affiche les informations du visiteur avec le User Control
                                InformationVisiteur.AfficherInformationsVisiteur(_listeVisiteur, indexVisiteur);
                                InformationVisiteur.Visible = true;
                                break;
                            }
                        }
                        indexVisiteur++;
                    }
                    indexVisiteur = 0;
                }
                break;
            }
        }
Example #24
0
        /// <summary>
        /// Methode qui permet les animaux a se deplacer
        /// </summary>
        /// <param name="a"></param>
        public void DeplacementAnimal(Animal a)
        {
            Random r           = new Random();
            int    deplacement = r.Next(1, 5);

            int x2 = a.x;
            int y2 = a.y;

            Bitmap[] l = new Bitmap[1];
            switch (a.TypeAnimal)
            {
            case Animaux.Lion:
                l[0] = TilesetImageGenerator.GetTile(44);
                break;

            case Animaux.Mouton:
                l[0] = TilesetImageGenerator.GetTile(45);
                break;

            case Animaux.Grizzly:
                l[0] = TilesetImageGenerator.GetTile(46);
                break;

            case Animaux.Rhinoceros:
                l[0] = TilesetImageGenerator.GetTile(47);
                break;

            case Animaux.Licorne:
                l[0] = TilesetImageGenerator.GetTile(48);
                break;

            case Animaux.Buffle:
                l[0] = TilesetImageGenerator.GetTile(49);
                break;
            }

            if (deplacement == 1)
            {
                y2--;
                if (y2 >= 0)
                {
                    if (noMouvCoordAI[x2, y2] && (h.x != x2 && h.y != y2) && noMouvAnimal[x2, y2])
                    {
                        bmAnimaux[a.x, a.y] = null;
                        a.y--;
                        bmAnimaux[a.x, a.y] = l[0];
                        Refresh();
                    }
                }
            }
            else if (deplacement == 2)
            {
                x2--;
                if (x2 >= 0)
                {
                    if (noMouvCoordAI[x2, y2] && (h.x != x2 && h.y != y2) && noMouvAnimal[x2, y2])
                    {
                        bmAnimaux[a.x, a.y] = null;
                        a.x--;
                        bmAnimaux[a.x, a.y] = l[0];
                        Refresh();
                    }
                }
            }
            else if (deplacement == 3)
            {
                y2++;
                if (y2 <= 24)
                {
                    if (noMouvCoordAI[x2, y2] && (h.x != x2 && h.y != y2) && noMouvAnimal[x2, y2])
                    {
                        bmAnimaux[a.x, a.y] = null;
                        a.y++;
                        bmAnimaux[a.x, a.y] = l[0];
                        Refresh();
                    }
                }
            }
            else if (deplacement == 4)
            {
                x2++;
                if (x2 <= 42)
                {
                    if (noMouvCoordAI[x2, y2] && (h.x != x2 && h.y != y2) && noMouvAnimal[x2, y2])
                    {
                        bmAnimaux[a.x, a.y] = null;
                        a.x++;
                        bmAnimaux[a.x, a.y] = l[0];
                        Refresh();
                    }
                }
            }
        }
Example #25
0
 /// <summary>
 /// Lorsque le joueur pèse soit W-A-S-D pour se déplacer, on vérifie que la prochaine position est valide
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Map_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.D)                                 //Droite
     {
         if (Map.Hero.X + 1 < Map.GetTabGazon().GetLength(0)) ///////////////////////////////enlevé le -1 au get length
         {
             if (Map.Hero.VerifDeplacementObstacleDroite(Map.GetTabAjout()))
             {
                 if (!Map.Hero.VerifAucuneObstacleHero(Map.Hero.X + 1, Map.Hero.Y))
                 {
                     Map.Hero.X          += 1;
                     Map.Hero.Orientation = "DROITE";
                 }
             }
         }
     }
     else if (e.KeyCode == Keys.A) // Gauche
     {
         if (Map.Hero.X - 1 > -1)
         {
             if (Map.Hero.VerifDeplacementObstacleGauche(Map.GetTabAjout()))
             {
                 if (!Map.Hero.VerifAucuneObstacleHero(Map.Hero.X - 1, Map.Hero.Y))
                 {
                     Map.Hero.X          -= 1;
                     Map.Hero.Orientation = "GAUCHE";
                 }
             }
         }
     }
     else if (e.KeyCode == Keys.W) // Haut
     {
         if (Map.Hero.Y - 1 > -1)
         {
             if (Map.Hero.VerifDeplacementObstacleHaut(Map.GetTabAjout()) || Map.GetTabAjout()[Map.Hero.X, Map.Hero.Y - 1] == TilesetImageGenerator.GetTile(TilesetImageGenerator.PORTE_ENCLOS))
             {
                 if (!Map.Hero.VerifAucuneObstacleHero(Map.Hero.X, Map.Hero.Y - 1))
                 {
                     Map.Hero.Y          -= 1;
                     Map.Hero.Orientation = "HAUT";
                 }
             }
         }
     }
     else if (e.KeyCode == Keys.S) // Bas
     {
         if (Map.Hero.Y + 1 < Map.GetTabGazon().GetLength(1) - 1)
         {
             if (Map.Hero.VerifDeplacementObstacleBas(Map.GetTabAjout()) || Map.GetTabAjout()[Map.Hero.X, Map.Hero.Y + 1] == TilesetImageGenerator.GetTile(TilesetImageGenerator.PORTE_ENCLOS))
             {
                 if (!Map.Hero.VerifAucuneObstacleHero(Map.Hero.X, Map.Hero.Y + 1))
                 {
                     Map.Hero.Y          += 1;
                     Map.Hero.Orientation = "BAS";
                 }
             }
         }
     }
     //Console.WriteLine(Map.Hero.X + " " + Map.Hero.Y);
     Refresh();
 }