예제 #1
0
        void BuildMazeMaterial(MeshMaker maker, int x, int y, Texture2D[] textures, bool fil_ariane, bool[,] carte_resolution)
        {
            // S'il s'agit d'un mur
            if (carte[x, y] == 1)
            {
                if (x != 0)
                {
                    if (carte[x - 1, y] != 1 && carte[x - 1, y] != 3)
                        AddWestWall(maker, x, 0, y, textures[1]);
                    else if (carte[x - 1, y] == 3)
                        AddWestWall(maker, x, 0, y, textures[2]);
                }
                if (x != laby.Size.X - 1)
                {
                    if (carte[x + 1, y] != 1 && carte[x + 1, y] != 3)
                        AddEastWall(maker, x, 0, y, textures[1]);
                    else if (carte[x + 1, y] == 3)
                        AddEastWall(maker, x, 0, y, textures[2]);
                }
                if (y != 0)
                {
                    if (carte[x, y - 1] != 1 && carte[x, y - 1] != 3)
                        AddSouthWall(maker, x, 0, y, textures[1]);
                    else if (carte[x, y - 1] == 3)
                        AddSouthWall(maker, x, 0, y, textures[2]);
                }
                if (y != laby.Size.Y - 1)
                {
                    if (carte[x, y + 1] != 1 && carte[x, y + 1] != 3)
                        AddNorthWall(maker, x, 0, y, textures[1]);
                    else if (carte[x, y + 1] == 3)
                        AddNorthWall(maker, x, 0, y, textures[2]);
                }
            }
            // Sinon
            else
            {

                // Si la case est différent de la sortie
                if (carte[x, y] != 3)
                {
                    bool trappe = false;
                    AddRoof(maker, x, 0, y, textures[0]);
                    if (laby.Carte[x, y] == 6)
                    {
                        foreach (Pieges piege in laby.liste_pieges)
                        {
                            if (piege.position_case.X == x && piege.position_case.Y == y && piege.type == 0)
                            {
                                AddFloor(maker, x, -1, y, textures[6], false);
                                AddWestWall(maker, x, -1, y, textures[5]);
                                AddEastWall(maker, x, -1, y, textures[5]);
                                AddSouthWall(maker, x, -1, y, textures[5]);
                                AddNorthWall(maker, x, -1, y, textures[5]);

                                trappe = true;
                            }
                        }
                    }
                    if (!trappe)
                    {
                        // Si resolution
                        if(fil_ariane && carte_resolution[x, y])
                            AddFloor(maker, x, 0, y, textures[4], true);
                        else
                            AddFloor(maker, x, 0, y, textures[4], false);
                    }
                }
                // Si c'est la sortie
                else
                {
                    // Bord gauche
                    if (x == 0)
                    {
                        AddWestWall(maker, x, 0, y, textures[3]);
                        AddWestWall(maker, x, 1, y, textures[3]);
                    }
                    else
                        AddWestWall(maker, x, 1, y, textures[2]);

                    if (x == laby.Size.X - 1)
                    {
                        AddEastWall(maker, x, 0, y, textures[3]);
                        AddEastWall(maker, x, 1, y, textures[3]);
                    }
                    else
                        AddEastWall(maker, x, 1, y, textures[2]);

                    if (y == 0)
                    {
                        AddSouthWall(maker, x, 0, y, textures[3]);
                        AddSouthWall(maker, x, 1, y, textures[3]);
                    }
                    else
                        AddSouthWall(maker, x, 1, y, textures[2]);

                    if (y == laby.Size.Y - 1)
                    {
                        AddNorthWall(maker, x, 0, y, textures[3]);
                        AddNorthWall(maker, x, 1, y, textures[3]);
                    }
                    else
                        AddNorthWall(maker, x, 1, y, textures[2]);

                    AddFloor(maker, x, 0, y, textures[7], false);
                    AddRoof(maker, x, 1, y, textures[7]);

                }

                if (x == 0 && carte[x, y] != 3)
                    AddWestWall(maker, x, 0, y, textures[1]);
                if (x == laby.Size.X - 1 && carte[x, y] != 3)
                    AddEastWall(maker, x, 0, y, textures[1]);
                if (y == 0 && carte[x, y] != 3)
                    AddSouthWall(maker, x, 0, y, textures[1]);
                if (y == laby.Size.Y - 1 && carte[x, y] != 3)
                    AddNorthWall(maker, x, 0, y, textures[1]);

            }
        }
예제 #2
0
        void AddFloor(MeshMaker maker, int x, int z, int y, Texture2D texture, bool resolution)
        {
            VertexPositionNormalTexture v1, v2, v3, v4;

            v1.Position = new Vector3(x, z, y) * laby.CellSize;
            v2.Position = new Vector3(x, z, y + 1) * laby.CellSize;
            v3.Position = new Vector3(x + 1, z, y + 1) * laby.CellSize;
            v4.Position = new Vector3(x + 1, z, y) * laby.CellSize;

            v1.Normal = v2.Normal = v3.Normal = v4.Normal = Vector3.Up;

            v1.TextureCoordinate = new Vector2(0, 1);
            v2.TextureCoordinate = new Vector2(0, 0);
            v3.TextureCoordinate = new Vector2(1, 0);
            v4.TextureCoordinate = new Vector2(1, 1);

            maker.AddQuad(v1, v2, v3, v4, texture, resolution);
        }
예제 #3
0
        void AddWestWall(MeshMaker maker, int x, int z, int y, Texture2D texture)
        {
            VertexPositionNormalTexture v1, v2, v3, v4;

            v1.Position = new Vector3(x, z, y) * laby.CellSize;
            v2.Position = new Vector3(x, z + 1, y) * laby.CellSize;
            v3.Position = new Vector3(x, z + 1, y + 1) * laby.CellSize;
            v4.Position = new Vector3(x, z, y + 1) * laby.CellSize;

            v1.Normal = v2.Normal = v3.Normal = v4.Normal = Vector3.Left;

            v1.TextureCoordinate = new Vector2(0, 1);
            v2.TextureCoordinate = new Vector2(0, 0);
            v3.TextureCoordinate = new Vector2(1, 0);
            v4.TextureCoordinate = new Vector2(1, 1);

            maker.AddQuad(v1, v2, v3, v4, texture, false);
        }
예제 #4
0
        public List<Material> BuildMazeMaterial(Labyrinthe laby, GraphicsDevice graphicsDevice, Texture2D[] textures, bool fil_ariane, bool[,] carte_resolution)
        {
            this.laby = laby;
            carte = laby.Carte;

            MeshMaker maker = new MeshMaker();

            for (int y = 0; y < laby.Size.Y; y++)
                for (int x = 0; x < laby.Size.X; x++)
                    BuildMazeMaterial(maker, x, y, textures, fil_ariane, carte_resolution);

            return maker.BuildMaterials(graphicsDevice);
        }