当前位置: 首页>>代码示例>>C#>>正文


C# Texture2D.ToList方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.Texture2D.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# Texture2D.ToList方法的具体用法?C# Texture2D.ToList怎么用?C# Texture2D.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.Graphics.Texture2D的用法示例。


在下文中一共展示了Texture2D.ToList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Initialize

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public void Initialize()
        {
            //RenderTarget = RenderTargetUtils.CreateRenderTarget(game.GraphicsDevice, 1, SurfaceFormat.Color, 800, 600);

            /** Load the terrain effect **/
            effect = GameFacade.Game.Content.Load<Effect>("Effects/TerrainSplat");

            /** Setup **/
            //SetCity("0020");
            SetCity("0013");

            //transX = -(City.Width * Geom.CellWidth / 2);
            //transY = +(City.Height / 2 * Geom.CellHeight / 2);

            /**
             * Setup terrain texture
             */

            var device = GameFacade.GraphicsDevice;

            var textureBase = GameFacade.GameFilePath("gamedata/terrain/newformat/");

            var grass = Texture2D.FromFile(device, Path.Combine(textureBase, "gr.tga"));
            var rock = Texture2D.FromFile(device, Path.Combine(textureBase, "rk.tga"));
            var snow = Texture2D.FromFile(device, Path.Combine(textureBase, "sn.tga"));
            var sand = Texture2D.FromFile(device, Path.Combine(textureBase, "sd.tga"));
            var water = Texture2D.FromFile(device, Path.Combine(textureBase, "wt.tga"));

            TextureTerrain = TextureUtils.MergeHorizontal(device, grass, snow, sand, rock, water);

            TextureGrass = grass;
            TextureSand = sand;
            TextureSnow = snow;
            TextureRock = rock;
            TextureWater = water;

            effect.Parameters["xTextureBlend"].SetValue(TextureBlend);
            effect.Parameters["xTextureTerrain"].SetValue(TextureTerrain);

            /** Dont need these anymore **/
            //grass.Dispose();
            //rock.Dispose();
            //snow.Dispose();
            //sand.Dispose();
            //water.Dispose();

            /**
             * Setup alpha map texture
             */
            /** Construct a single texture out of the alpha maps **/
            Texture2D[] alphaMaps = new Texture2D[15];
            for (var t = 0; t < 15; t++)
            {
                var index = t.ToString();
                if (t < 10) { index = "0" + index; }
                alphaMaps[t] = Texture2D.FromFile(device, Path.Combine(textureBase, "transb" + index + "b.tga"));
            }

            /** We add an extra 64px so that the last slot in the sheet is a solid color aka no blending **/
            TextureBlend = TextureUtils.MergeHorizontal(device, 64, alphaMaps);
            alphaMaps.ToList().ForEach(x => x.Dispose());

            effect.Parameters["xTextureBlend"].SetValue(TextureBlend);
            effect.Parameters["xTextureTerrain"].SetValue(TextureTerrain);

            //TextureBlend.Save(@"C:\Users\Admin\Desktop\blendBB.jpg", ImageFileFormat.Jpg);
        }
开发者ID:ddfczm,项目名称:Project-Dollhouse,代码行数:71,代码来源:CitySceneElement.cs

示例2: Initialize


//.........这里部分代码省略.........
                case "Zavadaville":
                    SetCity("0012");
                    break;
                case "Queen Margaret's":
                    SetCity("0013");
                    break;
                case "Shannopolis":
                    SetCity("0014");
                    break;
                case "Grantley Grove":
                    SetCity("0015");
                    break;
                case "Calvin's Creek":
                    SetCity("0016");
                    break;
                case "The Billabong":
                    SetCity("0017");
                    break;
                case "Mount Fuji":
                    SetCity("0018");
                    break;
                case "Dan's Grove":
                    SetCity("0019");
                    break;
                case "Jolly Pines":
                    SetCity("0020");
                    break;
                case "Yatesport":
                    SetCity("0021");
                    break;
                case "Landry Lakes":
                    SetCity("0022");
                    break;
                case "Nichol's Notch":
                    SetCity("0023");
                    break;
                case "King Canyons":
                    SetCity("0024");
                    break;
                case "Virginia Islands":
                    SetCity("0025");
                    break;
                case "Pixie Point":
                    SetCity("0026");
                    break;
                case "West Darrington":
                    SetCity("0027");
                    break;
                case "Upper Shankelston":
                    SetCity("0028");
                    break;
                case "Albertstown":
                    SetCity("0029");
                    break;
                case "Terra Tablante":
                    SetCity("0030");
                    break;
                default:
                    SetCity("0001");
                    break;
            }

            /**
             * Setup terrain texture
             */

            var device = GameFacade.GraphicsDevice;

            var textureBase = GameFacade.GameFilePath("gamedata/terrain/newformat/");

            var grass = Texture2D.FromFile(device, Path.Combine(textureBase, "gr.tga"));
            var rock = Texture2D.FromFile(device, Path.Combine(textureBase, "rk.tga"));
            var snow = Texture2D.FromFile(device, Path.Combine(textureBase, "sn.tga"));
            var sand = Texture2D.FromFile(device, Path.Combine(textureBase, "sd.tga"));
            var water = Texture2D.FromFile(device, Path.Combine(textureBase, "wt.tga"));

            TextureTerrain = TextureUtils.MergeHorizontal(device, grass, snow, sand, rock, water);

            TextureGrass = grass;
            TextureSand = sand;
            TextureSnow = snow;
            TextureRock = rock;
            TextureWater = water;

            /**
             * Setup alpha map texture
             */
            /** Construct a single texture out of the alpha maps **/
            Texture2D[] alphaMaps = new Texture2D[15];
            for (var t = 0; t < 15; t++)
            {
                var index = t.ToString();
                if (t < 10) { index = "0" + index; }
                alphaMaps[t] = Texture2D.FromFile(device, Path.Combine(textureBase, "transb" + index + "b.tga"));
            }

            /** We add an extra 64px so that the last slot in the sheet is a solid color aka no blending **/
            TextureBlend = TextureUtils.MergeHorizontal(device, 64, alphaMaps);
            alphaMaps.ToList().ForEach(x => x.Dispose());
        }
开发者ID:Tranquill6,项目名称:Project-Dollhouse,代码行数:101,代码来源:CitySceneElement.cs


注:本文中的Microsoft.Xna.Framework.Graphics.Texture2D.ToList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。