Example #1
0
        public void TestDeplacementNain()
        {
            Coordonnee destination;

            f = new FabriqueNain();
            c = new Coordonnee(1, 2); //Desert
            // - Vers case basique
            destination = new Coordonnee(1, 1); //Montagne
            u = f.fabriquerUnite(c);
            u.deplacement(destination);
            Assert.AreEqual(u.mouvement, 0);
            Assert.IsTrue(u.coordonnees.Equals(destination));
            // - Vers case eau
            destination = new Coordonnee(1, 3); //Eau
            u = f.fabriquerUnite(c);
            u.deplacement(destination);
            Assert.AreEqual(u.mouvement, 1);
            Assert.IsTrue(u.coordonnees.Equals(c));
            // - Montagne -> Montagne
            c = new Coordonnee(1, 1); //Montagne
            destination = new Coordonnee(3, 3); //Montagne
            u = f.fabriquerUnite(c);
            u.deplacement(destination);
            Assert.AreEqual(u.mouvement, 0);
            Assert.IsTrue(u.coordonnees.Equals(destination));
        }
Example #2
0
 /**
  * Constructeur de la classe Peuple
  *
  * t Type d'unites de l'instance
  * nb Nombre initial d'unites de l'instance
  * j Identifiant du joueur a qui appartient le peuple
  * posInit Position initiale des unites
  */
 public Peuple(TypePeuple t, int nb, int j, Coordonnee posInit)
 {
     this._type = t;
     IFabriqueUnite fab = new FabriqueUnite();
     this._nbUnites = nb;
     this._unites = fab.CreerUnites(this._type, this._nbUnites, j, posInit);
 }
Example #3
0
        public void nouvellePartie(TypeCarte taille, TypeUnite typeJ1, TypeUnite typeJ2)
        {
            SmallWorld.Instance.carte = fabAutre.creerCarte(taille);
            SmallWorld.Instance.carte.initialiseVortexs();
            SmallWorld.Instance.carte.print();

            List<Joueur> joueurs = new List<Joueur>();

            r = new Random();
            SmallWorld.Instance.premierJoueur = r.Next(SmallWorld.NOMBRE_JOUEURS);
            SmallWorld.Instance.joueurCourant = SmallWorld.Instance.premierJoueur;
            Console.WriteLine("Premier joueur : " + SmallWorld.Instance.premierJoueur);

            joueurs.Add(fabAutre.creerJoueur(typeJ1, 0));
            joueurs.Add(fabAutre.creerJoueur(typeJ2, 1));

            SmallWorld.Instance.joueurs = joueurs;
            SmallWorld.Instance.nbTours = 0;

            int nombreUnites = SmallWorld.Instance.carte.getNombreUniteMax();
            List<Coordonnee> posDepartJoueurs = SmallWorld.Instance.carte.getDepartJoueurs();
            foreach (Joueur j in SmallWorld.Instance.joueurs)
            {

                switch (j.Peuple)
                {
                    case TypeUnite.Gaulois:
                        fabUnit = new FabriqueGaulois();
                        break;
                    case TypeUnite.Viking:
                        fabUnit = new FabriqueViking();
                        break;
                    case TypeUnite.Nain:
                        fabUnit = new FabriqueNain();
                        break;
                    default:
                        throw new Exception("Type unité non reconnue");
                }

                for (int i = 0; i < nombreUnites; i++)
                {
                    j.addUnite(fabUnit.fabriquerUnite(posDepartJoueurs[j.idJoueur]));

                }
            }
        }
 public void Test_FabriqueUnite_1()
 {
     IFabriqueUnite f = new FabriqueUnite();
     List<Unite> l = f.CreerUnites(TypePeuple.GAULOIS, 2, 0, new Coordonnee(0, 0));
     Assert.IsTrue(l[0].Coordonnees.Equals(new Coordonnee(0, 0)));
     Assert.IsTrue(l[1].Coordonnees.Equals(new Coordonnee(0, 0)));
     Assert.IsTrue(l[0].Joueur == 0);
     Assert.IsTrue(l[1].Joueur == 0);
 }
        public static Unit BuildUnitHMI(TypeEntite type, Case position, Joueur j)
        {
            Unit unit = null;

            switch (type)
            {
            case TypeEntite.ASTRONEF:
                unit       = new Spaceship((Unite)FabriqueUnite.CreeUnite(type, position, j), _map);
                unit.Image = new Image()
                {
                    Source = new BitmapImage(fileLoader.GetUri("astronef.png")),
                };
                break;

            case TypeEntite.BARGE:
                unit       = new BargeHMI((Unite)FabriqueUnite.CreeUnite(type, position, j));
                unit.Image = new Image()
                {
                    Source = new BitmapImage(fileLoader.GetUri("barge.png"))
                };
                break;

            case TypeEntite.TANK:
                unit       = new TankHMI((Unite)FabriqueUnite.CreeUnite(type, position, j));
                unit.Image = new Image()
                {
                    Source = new BitmapImage(fileLoader.GetUri("tank.png"))
                };
                break;

            case TypeEntite.CRABE:
                unit       = new Crab((Unite)FabriqueUnite.CreeUnite(type, position, j));
                unit.Image = new Image()
                {
                    Source = new BitmapImage(fileLoader.GetUri("Crab3.png"))
                };
                break;

            case TypeEntite.GROS_TAS:
                unit       = new T99((Unite)FabriqueUnite.CreeUnite(type, position, j));
                unit.Image = new Image()
                {
                    Source = new BitmapImage(fileLoader.GetUri("big_tank.png"))
                };
                break;

            case TypeEntite.PONDEUSE:
                unit       = new WeatherLayerHMI((Unite)FabriqueUnite.CreeUnite(type, position, j));
                unit.Image = new Image()
                {
                    Source = new BitmapImage(fileLoader.GetUri("weather_layer.png"))
                };
                break;

            case TypeEntite.VEDETTE:
                unit       = new Speedboat((Unite)FabriqueUnite.CreeUnite(type, position, j));
                unit.Image = new Image()
                {
                    Source = new BitmapImage(fileLoader.GetUri("boat.png")),
                };
                break;
            }
            unit.Image.Height = unit.Height;
            unit.Image.Width  = unit.Width;
            unit.AddHandler();
            return(unit);
        }
Example #6
0
        public void TestPoints()
        {
            //Gaulois
            f = new FabriqueGaulois();
            // - Montagne
            c = new Coordonnee(1, 1);
            u = f.fabriquerUnite(c);
            Assert.AreEqual(u.getPoints(), 0);
            // - Plaine
            c = new Coordonnee(3, 1);
            u = f.fabriquerUnite(c);
            Assert.AreEqual(u.getPoints(), 2);
            // - Desert
            c = new Coordonnee(2, 1);
            u = f.fabriquerUnite(c);
            Assert.AreEqual(u.getPoints(), 1);
            // - Foret
            c = new Coordonnee(3, 2);
            u = f.fabriquerUnite(c);
            Assert.AreEqual(u.getPoints(), 1);

            //Nain
            f = new FabriqueNain();
            // - Montagne
            c = new Coordonnee(1, 1);
            u = f.fabriquerUnite(c);
            Assert.AreEqual(u.getPoints(), 1);
            // - Plaine
            c = new Coordonnee(3, 1);
            u = f.fabriquerUnite(c);
            Assert.AreEqual(u.getPoints(), 0);
            // - Desert
            c = new Coordonnee(2, 1);
            u = f.fabriquerUnite(c);
            Assert.AreEqual(u.getPoints(), 1);
            // - Foret
            c = new Coordonnee(3, 2);
            u = f.fabriquerUnite(c);
            Assert.AreEqual(u.getPoints(), 2);

            //Vinking
            f = new FabriqueViking();
            // - Montagne
            c = new Coordonnee(1, 1);
            u = f.fabriquerUnite(c);
            Assert.AreEqual(u.getPoints(), 1);
            // - Plaine
            c = new Coordonnee(3, 1);
            u = f.fabriquerUnite(c);
            Assert.AreEqual(u.getPoints(), 1);
            // - Desert
            c = new Coordonnee(2, 1);
            u = f.fabriquerUnite(c);
            Assert.AreEqual(u.getPoints(), 0);
            // - Foret
            c = new Coordonnee(3, 2);
            u = f.fabriquerUnite(c);
            Assert.AreEqual(u.getPoints(), 1);
            // - Eau
            c = new Coordonnee(1, 3);
            u = f.fabriquerUnite(c);
            Assert.AreEqual(u.getPoints(), 0);
            // - Bord Eau
            c = new Coordonnee(1, 2);
            u = f.fabriquerUnite(c);
            Assert.AreEqual(u.getPoints(), 2);
        }