Пример #1
0
        public void Constructeur()
        {
            Generateur g = new GenerateurParDefault(new Noise());
            Monde      m = new Monde(g);

            Assert.AreEqual(m.Chunks.Count, 0);
            Assert.AreEqual(m.Entites.Count, 0);
            Assert.AreEqual(m.Generateur, g);
        }
Пример #2
0
        public void GenerateChunk()
        {
            {
                Generateur g = new FlatGenerateur(new Noise());
                Monde      m = new Monde(g);
                Chunk      c = g.Generer(0, 0, new Chunk(new Block[16, 16])).Item1;
                m.GenerateChunk(0, 0);
                for (int x = 0; x < 16; x++)
                {
                    for (int y = 0; y < 16; y++)
                    {
                        Block b1 = m.Chunks["0/0"].Blocks[x, y];
                        Block b2 = c.Blocks[x, y];
                        Assert.IsTrue((b1 == null && b2 == null) || (b1 != null && b2 != null && b1.Name == b2.Name));
                    }
                }
            }
            {
                Generateur g = new GenerateurParDefault(new Noise(100));
                Monde      m = new Monde(g);
                Tuple <Chunk, Tuple <int, int, Schematique>[], Entite[]> s = g.Generer(0, 0, new Chunk(new Block[16, 16]));
                Chunk c = s.Item1;

                foreach (Tuple <int, int, Schematique> shematic in s.Item2)
                {
                    foreach (KeyValuePair <string, Block> b in shematic.Item3.Blocks)
                    {
                        string[] a = b.Key.Split('/');
                        int      x = int.Parse(a[0]) + shematic.Item1;
                        int      y = int.Parse(a[1]) + shematic.Item1;
                        if (x >= 0 && x < 16 && y >= 0 && y < 16)
                        {
                            c.SetBlock(x % 16, y % 16, b.Value);
                        }
                    }
                }

                m.GenerateChunk(0, 0);
                for (int x = 0; x < 16; x++)
                {
                    for (int y = 0; y < 16; y++)
                    {
                        Block b1 = m.Chunks["0/0"].Blocks[x, y];
                        Block b2 = c.Blocks[x, y];
                        Assert.IsTrue((b1 == null && b2 == null) || (b1 != null && b2 != null && b1.Name == b2.Name));
                    }
                }
            }
        }