Exemple #1
0
        public static List<Case> CalculChemin(Carte carte, Case depart, Case arrivee)
        {
            List<Case> resultat = new List<Case>();
            NodeList<Noeud> listeOuverte = new NodeList<Noeud>();
            NodeList<Noeud> listeFermee = new NodeList<Noeud>();
            List<Noeud> noeudsPossibles;
            int nombreNoeudsPossibles;

            listeOuverte.Add(new Noeud(depart, null, arrivee));

            while (listeOuverte.Count > 0)
            {
                Noeud current = listeOuverte[0];
                listeOuverte.RemoveAt(0);
                listeFermee.Add(current);

                if (current.Case == arrivee)
                {
                    List<Case> solution = new List<Case>();
                    while (current.Parent != null)
                    {
                        solution.Add(current.Case);
                        current = current.Parent;
                    }
                    return solution;
                }

                noeudsPossibles = current.NoeudsPossibles(carte, arrivee);
                nombreNoeudsPossibles = noeudsPossibles.Count;

                foreach (Noeud voisin in current.NoeudsPossibles(carte, arrivee))
                    if (!listeFermee.Contains(voisin))
                    {
                        if (listeOuverte.Contains(voisin))
                        {
                            if (voisin.Manhattan < listeOuverte[voisin].Manhattan)
                                listeOuverte[voisin].Parent = current;
                        }
                        else
                            listeOuverte.DichotomicInsertion(voisin);
                    }
            }

            return null;
        }
Exemple #2
0
        public List<Noeud> NoeudsPossibles(Carte carte, Case destination)
        {
            List<Noeud> result = new List<Noeud>();
            // Bas
            if (CaseValide(Case.X, Case.Y + 1) && carte.Cases[Case.Y + 1, Case.X].EstFranchissable)
                result.Add(new Noeud(carte.Cases[Case.Y + 1, Case.X], this, destination));
            // Droite
            if (CaseValide(Case.X + 1, Case.Y) && carte.Cases[Case.Y, Case.X + 1].EstFranchissable)
                result.Add(new Noeud(carte.Cases[Case.Y, Case.X + 1], this, destination));
            // Haut
            if (CaseValide(Case.X, Case.Y - 1) && carte.Cases[Case.Y - 1, Case.X].EstFranchissable)
                result.Add(new Noeud(carte.Cases[Case.Y - 1, Case.X], this, destination));
            // Gauche
            if (CaseValide(Case.X - 1, Case.Y) && carte.Cases[Case.Y, Case.X - 1].EstFranchissable)
                result.Add(new Noeud(carte.Cases[Case.Y, Case.X - 1], this, destination));

            return result;
        }
Exemple #3
0
        public void Switch(string s, int x, int y)
        {
            switch (s)
            {
                case "a1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.arbre, 1);
                    break;
                case "a2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.arbre, 2);
                    break;
                case "a3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.arbre, 3);
                    break;
                case "a4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.arbre, 4);
                    break;
                case "a5":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.arbre, 5);
                    break;
                case "a6":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.arbre, 6);
                    break;

                case "u1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.canape, 1);
                    break;
                case "u2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.canape, 2);
                    break;
                case "u3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.canape, 3);
                    break;
                case "u4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.canape, 4);
                    break;
                case "u5":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.canape, 5);
                    break;
                case "u6":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.canape, 6);
                    break;

                case "x1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.porteFenetre, 1);
                    break;
                case "x2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.porteFenetre, 2);
                    break;
                case "x3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.porteFenetre, 3);
                    break;
                case "x4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.porteFenetre, 4);
                    break;
                case "x5":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.porteFenetre, 5);
                    break;
                case "x6":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.porteFenetre, 6);
                    break;

                case "y1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grdSiege, 1);
                    break;
                case "y2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grdSiege, 2);
                    break;
                case "y3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grdSiege, 3);
                    break;
                case "y4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grdSiege, 4);
                    break;
                case "y5":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grdSiege, 5);
                    break;
                case "y6":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grdSiege, 6);
                    break;

                case "s1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.pont1, 1);
                    break;
                case "s2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.pont1, 2);
                    break;

                case "C1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.bibliotheque, 1);
                    break;
                case "C2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.bibliotheque, 2);
                    break;

                case "t1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.pont2, 1);
                    break;
                case "t2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.pont2, 2);
                    break;
                case "t3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.pont2, 3);
                    break;
                case "t4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.pont2, 4);
                    break;
                case "t5":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.pont2, 5);
                    break;
                case "t6":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.pont2, 6);
                    break;
                case "t7":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.pont2, 7);
                    break;
                case "t8":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.pont2, 8);
                    break;

                case "b1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.commode, 1);
                    break;
                case "b2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.commode, 2);
                    break;
                case "b3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.commode, 3);
                    break;
                case "b4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.commode, 4);
                    break;

                case "c1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.lit, 1);
                    break;
                case "c2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.lit, 2);
                    break;
                case "c3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.lit, 3);
                    break;
                case "c4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.lit, 4);
                    break;

                case "d1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.mur, 1);
                    break;
                case "d2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.mur, 2);
                    break;
                case "d3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.mur, 3);
                    break;
                case "d4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.mur, 4);
                    break;

                case "e1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murBlanc, 1);
                    break;
                case "e2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murBlanc, 2);
                    break;
                case "e3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murBlanc, 3);
                    break;
                case "e4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murBlanc, 4);
                    break;

                case "f1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murBlancDrap, 1);
                    break;
                case "f2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murBlancDrap, 2);
                    break;
                case "f3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murBlancDrap, 3);
                    break;
                case "f4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murBlancDrap, 4);
                    break;

                case "g1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murBlancEpee, 1);
                    break;
                case "g2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murBlancEpee, 2);
                    break;
                case "g3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murBlancEpee, 3);
                    break;
                case "g4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murBlancEpee, 4);
                    break;

                case "h1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murBlancTableau, 1);
                    break;
                case "h2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murBlancTableau, 2);
                    break;
                case "h3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murBlancTableau, 3);
                    break;
                case "h4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murBlancTableau, 4);
                    break;

                case "i1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murEpee, 1);
                    break;
                case "i2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murEpee, 2);
                    break;
                case "i3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murEpee, 3);
                    break;
                case "i4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murEpee, 4);
                    break;

                case "j1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murTableau, 1);
                    break;
                case "j2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murTableau, 2);
                    break;
                case "j3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murTableau, 3);
                    break;
                case "j4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.murTableau, 4);
                    break;

                case "k1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.tableauMurBlanc, 1);
                    break;
                case "k2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.tableauMurBlanc, 2);
                    break;
                case "k3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.tableauMurBlanc, 3);
                    break;
                case "k4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.tableauMurBlanc, 4);
                    break;

                case "l1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.tableMoyenne, 1);
                    break;
                case "l2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.tableMoyenne, 2);
                    break;
                case "l3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.tableMoyenne, 3);
                    break;
                case "l4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.tableMoyenne, 4);
                    break;

                case "o1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.nvlHerbe, 1);
                    break;
                case "o2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.nvlHerbe, 2);
                    break;
                case "o3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.nvlHerbe, 3);
                    break;
                case "o4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.nvlHerbe, 4);
                    break;

                case "p1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.parquet, 1);
                    break;
                case "p2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.parquet, 2);
                    break;
                case "p3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.parquet, 3);
                    break;
                case "p4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.parquet, 4);
                    break;

                case "q1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.parquetArbre, 1);
                    break;
                case "q2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.parquetArbre, 2);
                    break;
                case "q3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.parquetArbre, 3);
                    break;
                case "q4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.parquetArbre, 4);
                    break;

                case "r1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.parquetBuisson, 1);
                    break;
                case "r2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.parquetBuisson, 2);
                    break;
                case "r3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.parquetBuisson, 3);
                    break;
                case "r4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.parquetBuisson, 4);
                    break;

                case "v1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.canapeRalonge, 1);
                    break;
                case "v2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.canapeRalonge, 2);
                    break;
                case "v3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.canapeRalonge, 3);
                    break;
                case "v4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.canapeRalonge, 4);
                    break;

                case "w1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.fenetre, 1);
                    break;
                case "w2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.fenetre, 2);
                    break;
                case "w3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.fenetre, 3);
                    break;
                case "w4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.fenetre, 4);
                    break;

                case "z1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.pillier, 1);
                    break;
                case "z2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.pillier, 2);
                    break;
                case "z3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.pillier, 3);
                    break;
                case "z4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.pillier, 4);
                    break;

                case "A1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.porte, 1);
                    break;
                case "A2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.porte, 2);
                    break;
                case "A3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.porte, 3);
                    break;
                case "A4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.porte, 4);
                    break;

                case "B1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.rocher, 1);
                    break;
                case "B2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.rocher, 2);
                    break;
                case "B3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.rocher, 3);
                    break;
                case "B4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.rocher, 4);
                    break;

                case "m1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grandeTable, 1);
                    break;
                case "m2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grandeTable, 2);
                    break;
                case "m3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grandeTable, 3);
                    break;
                case "m4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grandeTable, 4);
                    break;
                case "m5":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grandeTable, 5);
                    break;
                case "m6":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grandeTable, 6);
                    break;
                case "m7":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grandeTable, 7);
                    break;
                case "m8":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grandeTable, 8);
                    break;
                case "m9":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grandeTable, 9);
                    break;

                case "n1":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grandeTableDeco, 1);
                    break;
                case "n2":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grandeTableDeco, 2);
                    break;
                case "n3":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grandeTableDeco, 3);
                    break;
                case "n4":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grandeTableDeco, 4);
                    break;
                case "n5":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grandeTableDeco, 5);
                    break;
                case "n6":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grandeTableDeco, 6);
                    break;
                case "n7":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grandeTableDeco, 7);
                    break;
                case "n8":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grandeTableDeco, 8);
                    break;
                case "n9":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.grandeTableDeco, 9);
                    break;

                case ("a7"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.buissonSurHerbe, 1);
                    break;
                case ("a8"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.coinbotdroit, 1);
                    break;
                case ("a9"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.coinbotgauche, 1);
                    break;
                case ("a0"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.cointopdroit, 1);
                    break;
                case ("b0"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.cointopgauche, 1);
                    break;
                case ("b5"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.finMurDroit, 1);
                    break;
                case ("b6"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.finMurGauche, 1);
                    break;
                case ("b7"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.fondNoir, 1);
                    break;
                case ("b8"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.piedMurBois, 1);
                    break;
                case ("b9"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.bois, 1);
                    break;
                case ("c0"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.boisCarre, 1);
                    break;
                case ("c5"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.boisDeco, 1);
                    break;
                case ("c6"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.carlageNoir, 1);
                    break;
                case ("c7"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.carlageNoirDeco, 1);
                    break;
                case ("c8"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.herbe, 1);
                    break;
                case ("c9"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.herbeDeco, 1);
                    break;
                case ("d0"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.herbeFoncee, 1);
                    break;
                case ("d5"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.herbeH, 1);
                    break;
                case ("d6"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.tapisRougeBC, 1);
                    break;
                case ("d7"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.terre, 1);
                    break;
                case ("d8"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.finMurBas, 1);
                    break;
                case ("d9"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.finMurHaut, 1);
                    break;
                case "e5":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.eau, 1);
                    break;
                case ("e6"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.caisse, 1);
                    break;
                case ("e7"):
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.chaiseGauche, 1);
                    break;
                case "e8":
                    _case[y, x] = new Case(28 * new Vector2(x, y), TypeCase.chaiseDroite, 1);
                    break;
            }
        }
Exemple #4
0
 public void Initialisation(Vector2 size)
 {
     for (int y = 0; y < size.Y; y++)
         for (int x = 0; x < size.X; x++)
             _case[y, x] = new Case(new Vector2(x, y), TypeCase.herbe, 1);
 }
Exemple #5
0
        public void Update(GameTime gameTime, Carte carte, Heros heros, Rectangle camera)
        {
            rectangle.X = (int)position.X + 1;
            rectangle.Y = (int)position.Y + 1;

            if (pseudoChrono < 10 && Math.Sqrt((this.X - heros.X) * (this.X - heros.X) + (this.Y - heros.Y) * (this.Y - heros.Y)) > 5)
                pseudoChrono += gameTime.ElapsedGameTime.TotalSeconds;
            else
            {
                pseudoChrono = 0;
                depart = carte.Cases[Y, X];
                arrivee = carte.Cases[heros.Y, heros.X];
                chemin = Pathfinding.CalculChemin(carte, depart, arrivee);
            }

            if (chemin != null && chemin.Count != 0)
            {
                if (VaEnHaut && VaEnBas && VaADroite && VaAGauche)
                {
                    if ((int)chemin[chemin.Count - 1].X < X)
                    {
                        positionDesiree.X -= 28;
                        VaAGauche = false;
                        chemin.RemoveAt(chemin.Count - 1);
                    }
                    else if ((int)chemin[chemin.Count - 1].X > X)
                    {
                        positionDesiree.X += 28;
                        VaADroite = false;
                        chemin.RemoveAt(chemin.Count - 1);
                    }
                    else if ((int)chemin[chemin.Count - 1].Y < Y)
                    {
                        positionDesiree.Y -= 28;
                        VaEnHaut = false;
                        chemin.RemoveAt(chemin.Count - 1);
                    }
                    else if ((int)chemin[chemin.Count - 1].Y > Y)
                    {
                        positionDesiree.Y += 28;
                        VaEnBas = false;
                        chemin.RemoveAt(chemin.Count - 1);
                    }
                    else
                        chemin.RemoveAt(chemin.Count - 1);
                }
            }

            if (SourceRectangle.Value.Y == 0)
            {
                SourceRectangle = new Rectangle((int)Index * 24, 0, 16, 24);
                Regarde_Haut = true;
            }
            else
                Regarde_Haut = false;

            if (SourceRectangle.Value.Y == 97)
            {
                SourceRectangle = new Rectangle((int)Index * 24, 97, 16, 24);
                Regarde_Gauche = true;
            }
            else
                Regarde_Gauche = false;

            if (SourceRectangle.Value.Y == 64)
            {
                SourceRectangle = new Rectangle((int)Index * 24, 64, 16, 24);
                Regarde_Bas = true;
            }
            else
                Regarde_Bas = false;

            if (SourceRectangle.Value.Y == 33)
            {
                SourceRectangle = new Rectangle((int)Index * 24, 33, 16, 24);
                Regarde_Droite = true;
            }
            else
                Regarde_Droite = false;

            if (!VaEnHaut)
            {
                if (position != positionDesiree)
                {
                    position.Y -= VitesseSprite;
                    SourceRectangle = new Rectangle((int)Index * 24, 0, 16, 24);
                    Index += gameTime.ElapsedGameTime.Milliseconds * VitesseAnimation;

                    if (Index >= MaxIndex)
                        Index = 0f;
                }
                else
                {
                    VaEnHaut = true;
                    position = positionDesiree;
                    Index = 0f;
                }
            }

            if (!VaEnBas)
            {
                if (position != positionDesiree)
                {
                    position.Y += VitesseSprite;
                    SourceRectangle = new Rectangle((int)Index * 24, 64, 16, 24);
                    Index += gameTime.ElapsedGameTime.Milliseconds * VitesseAnimation;

                    if (Index >= MaxIndex)
                        Index = 0f;
                }
                else
                {
                    VaEnBas = true;
                    position = positionDesiree;
                    Index = 0f;
                }
            }

            if (!VaAGauche)
            {
                if (position != positionDesiree)
                {
                    position.X -= VitesseSprite;
                    SourceRectangle = new Rectangle((int)Index * 24, 97, 16, 24);
                    Index += gameTime.ElapsedGameTime.Milliseconds * VitesseAnimation;

                    if (Index >= MaxIndex)
                        Index = 0f;
                }
                else
                {
                    VaAGauche = true;
                    position = positionDesiree;
                    Index = 0f;
                }
            }

            if (!VaADroite)
            {
                if (position != positionDesiree)
                {
                    position.X += VitesseSprite;
                    SourceRectangle = new Rectangle((int)Index * 24, 33, 16, 24);
                    Index += gameTime.ElapsedGameTime.Milliseconds * VitesseAnimation;

                    if (Index >= MaxIndex)
                        Index = 0f;
                }
                else
                {
                    VaADroite = true;
                    position = positionDesiree;
                    Index = 0f;
                }
            }
        }
Exemple #6
0
 public Noeud(Case _case, Noeud parent, Case destination)
 {
     this.Case = _case;
     this.Parent = parent;
     this.Manhattan = Math.Abs(_case.X - destination.X) + Math.Abs(_case.Y - destination.Y);
 }