Esempio n. 1
0
 public personnage(Labyrinth lab)
 {
     this.mylab = lab;
     this.mypos = lab.Depart;
 }
Esempio n. 2
0
        public Labyrinth(string [] map, int _nbligne, int _nbcolone)
        {
            this.nbLignes   = _nbligne;
            this.nbColonnes = _nbcolone;
            this.matrice    = new int[_nbligne, _nbcolone];
            int  test      = map[0].Length;
            bool stillokay = true;

            //toutes les colones ont la meme taille
            foreach (string lligne in map)
            {
                if (test != lligne.Length)
                {
                    stillokay = false;
                    break;
                }
            }
            if (!stillokay)
            {
                throw new ArgumentException("erreur de dimesnion");
            }
            if (stillokay)
            {
                for (int x = 0; x < this.matrice.GetLength(0); x++)
                {
                    for (int y = 0; y < this.matrice.GetLength(1); y++)
                    {
                        char temp = map[x][y];
                        switch (temp)
                        {
                        case '*':
                            this.matrice[x, y] = 1;
                            break;

                        case 'd':
                            this.matrice[x, y] = 2;
                            this.depart        = new position(x, y);
                            break;

                        case '-':
                            this.matrice[x, y] = 0;
                            break;

                        case 'a':
                            this.matrice[x, y] = 3;
                            this.arrivee       = new position(x, y);
                            break;

                        default:
                            this.matrice[x, y] = 99;
                            break;
                        }
                    }
                }
            }

            // un point de depart et d arrivée existe
            if (this.depart == null || this.arrivee == null)
            {
                stillokay = false;
            }
            if (!stillokay)
            {
                throw new ArgumentException("les points de departs et arrive mal config");
            }
            //check les murs sont bien present
            if (stillokay)
            {
                for (int x = 0; x < this.matrice.GetLength(0); x++)
                {
                    for (int y = 0; y < this.matrice.GetLength(1); y++)
                    {
                        int temp = this.matrice[x, y];
                        if (x == 0 || x == this.matrice.GetLength(0) - 1 || y == 0 || y == this.matrice.GetLength(1) - 1)
                        {
                            if (temp != 1)
                            {
                                stillokay = false;
                                break;
                            }
                        }
                    }
                }
            }
            if (!stillokay)
            {
                throw new ArgumentException("murs pas continu");
            }
        }
Esempio n. 3
0
 public bool EstUnMur(position pos)
 {
     return(this.matrice[pos.x, pos.y] == 1);
 }
Esempio n. 4
0
 public bool EstOccupee(position pos)
 {
     return(this.matrice[pos.x, pos.y] == 4);
 }
Esempio n. 5
0
 public position(position pos)
 {
     this.x = pos.x;
     this.y = pos.y;
 }