Example #1
0
        public MapImpl(int s)
        {
            //Utilisation de la dll cpp pour remplir
            //un tableau d'entier
            Algo a = new Algo();
            size = s;
            int nbTiles = size * size;
            int[] tab = a.FillMap(size);

            //Utilisation de ce tableau pour générer le
            //tableau de Tiles
            tiles = new Tile[nbTiles];
            TileFactory tf = TileFactoryImpl.getTileFactory();
            for (int i = 0; i < nbTiles; i++){
                tiles[i] = tf.getTile(tab[i]);
            }

            int j,k;
            units = new Dictionary<Position, List<Unit>>();
            for (k = 0; k < size; k++)
                for (j = 0; j < size; j++)
                    units.Add(PositionImpl.getPosition(k, j), new List<Unit>());

            _instance = this;
            
        }
Example #2
0
        public MapImpl(int s)
        {
            //Utilisation de la dll cpp pour remplir
            //un tableau d'entier
            Algo a = new Algo();

            size = s;
            int nbTiles = size * size;

            int[] tab = a.FillMap(size);

            //Utilisation de ce tableau pour générer le
            //tableau de Tiles
            tiles = new Tile[nbTiles];
            TileFactory tf = TileFactoryImpl.getTileFactory();

            for (int i = 0; i < nbTiles; i++)
            {
                tiles[i] = tf.getTile(tab[i]);
            }

            int j, k;

            units = new Dictionary <Position, List <Unit> >();
            for (k = 0; k < size; k++)
            {
                for (j = 0; j < size; j++)
                {
                    units.Add(PositionImpl.getPosition(k, j), new List <Unit>());
                }
            }

            _instance = this;
        }
Example #3
0
 public void TestAlgo() {
     Algo algo = new Algo();
     int[] tab = algo.FillMap(4);
     List<int> mm = new List<int>(tab);
     Assert.AreEqual(mm.Count, 16);
     Dictionary<int, int> d = new Dictionary<int, int>();
     d.Add(0, 0); d.Add(1, 0); d.Add(2, 0); d.Add(3, 0);
     foreach (int n in tab)
     {
         d[n] += 1;
     }
     Assert.AreEqual(d[0], d[1]);
     Assert.AreEqual(d[1], d[2]);
     Assert.AreEqual(d[2], d[3]);
 }