Ejemplo n.º 1
0
        public GLTexture GetRandomTexture(string texName)
        {
            var texNameIndex = 0;

            if (Rnd.Next(0, 3) == 1)
            {
                texNameIndex = 1;
            }
            else
            if (Rnd.Next(0, 3) == 1)
            {
                texNameIndex = 3;
            }
            else
            if (Rnd.Next(0, 7) == 1)
            {
                texNameIndex = 2;
            }

            texName = texName + texNameIndex.ToString();
            var tex = GLTextureAdmin.GetTextureByName(texName);

            return(tex);
        }
Ejemplo n.º 2
0
        public List <GLPolygon> GeneratePosition(double x, double y, double z,
                                                 bool left, bool right, bool front, bool back,
                                                 string specialTexture = null, string specialBottomTexture = null, string specialTopTexture = null)
        {
            var polygons = new List <GLPolygon>();

            // bottom

            var bottomPolygon = new GLPolygon();

            bottomPolygon.Points = new List <GLPoint>()
            {
                new GLPoint(x + TileWidth, y, z + TileWidth),
                new GLPoint(x + TileWidth, y, z),
                new GLPoint(x, y, z),

                new GLPoint(x, y, z + TileWidth),
            };

            bottomPolygon.Texture = specialBottomTexture == null?GLTextureAdmin.GetTextureByName("labBottom")
                                        : GLTextureAdmin.GetTextureByName(specialBottomTexture);

            polygons.Add(bottomPolygon);


            // top
            var topPolygon = new GLPolygon();

            topPolygon.Points = new List <GLPoint>()
            {
                new GLPoint(x, y + TileWidth, z + TileWidth),
                new GLPoint(x + TileWidth, y + TileWidth, z + TileWidth),
                new GLPoint(x + TileWidth, y + TileWidth, z),
                new GLPoint(x, y + TileWidth, z),
            };

            topPolygon.Texture = specialTopTexture == null?GLTextureAdmin.GetTextureByName("labTop")
                                     : GLTextureAdmin.GetTextureByName(specialTopTexture);

            polygons.Add(topPolygon);


            if (left)
            {
                var leftPolygon = new GLPolygon();
                leftPolygon.Points = new List <GLPoint>()
                {
                    new GLPoint(x + TileWidth, y, z),
                    new GLPoint(x + TileWidth, y + TileWidth, z),
                    new GLPoint(x + TileWidth, y + TileWidth, z + TileWidth),
                    new GLPoint(x + TileWidth, y, z + TileWidth),
                };

                leftPolygon.Texture = specialTexture == null?GetRandomTexture("labWall") :  GLTextureAdmin.GetTextureByName(specialTexture);

                polygons.Add(leftPolygon);
            }


            if (right)
            {
                var rightPolygon = new GLPolygon();
                rightPolygon.Points = new List <GLPoint>()
                {
                    new GLPoint(x, y, z),
                    new GLPoint(x, y + TileWidth, z),
                    new GLPoint(x, y + TileWidth, z + TileWidth),
                    new GLPoint(x, y, z + TileWidth),
                };

                rightPolygon.Texture = specialTexture == null?GetRandomTexture("labWall") :  GLTextureAdmin.GetTextureByName(specialTexture);

                polygons.Add(rightPolygon);
            }

            if (front)
            {
                var frontPolygon = new GLPolygon();
                frontPolygon.Points = new List <GLPoint>()
                {
                    new GLPoint(x + TileWidth, y, z + TileWidth),
                    new GLPoint(x + TileWidth, y + TileWidth, z + TileWidth),
                    new GLPoint(x, y + TileWidth, z + TileWidth),
                    new GLPoint(x, y, z + TileWidth)
                };

                frontPolygon.Texture = specialTexture == null?GetRandomTexture("labWall") :  GLTextureAdmin.GetTextureByName(specialTexture);

                polygons.Add(frontPolygon);
            }

            if (back)
            {
                var backPolygon = new GLPolygon();
                backPolygon.Points = new List <GLPoint>()
                {
                    new GLPoint(x + TileWidth, y, z),
                    new GLPoint(x + TileWidth, y + TileWidth, z),
                    new GLPoint(x, y + TileWidth, z),
                    new GLPoint(x, y, z)
                };


                backPolygon.Texture = specialTexture == null?GetRandomTexture("labWall") :  GLTextureAdmin.GetTextureByName(specialTexture);

                polygons.Add(backPolygon);
            }


            foreach (var polygon in polygons)
            {
                Polygons.Add(polygon);
            }

            return(polygons);
        }