• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ILocalChunkCache类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ILocalChunkCache的典型用法代码示例。如果您正苦于以下问题:C# ILocalChunkCache类的具体用法?C# ILocalChunkCache怎么用?C# ILocalChunkCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ILocalChunkCache类属于命名空间,在下文中一共展示了ILocalChunkCache类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetProperties

 public override PhysicalProperties GetProperties(ILocalChunkCache manager, int x, int y, int z)
 {
     return new PhysicalProperties()
     {
         Density = 1.5f,
         FractureToughness = 0.2f,
         Granularity = 0.9f,
         Hardness = 0.05f
     };
 }
开发者ID:jvbsl,项目名称:octoawesome,代码行数:10,代码来源:SnowBlockDefinition.cs


示例2: SetChunk

        public void SetChunk(ILocalChunkCache manager, int x, int y, int z)
        {
            var newPosition = new Index3(x, y, z);

            if (_manager == manager && newPosition == ChunkPosition)
                return;

            _manager = manager;
            ChunkPosition = newPosition;

            chunk = null;
            loaded = false;
        }
开发者ID:RapidHelmus,项目名称:octoawesome,代码行数:13,代码来源:ChunkRenderer.cs


示例3: GetBottomTextureRotation

        public override int GetBottomTextureRotation(ILocalChunkCache manager, int x, int y, int z)
        {
            OrientationFlags orientation = (OrientationFlags)manager.GetBlockMeta(x, y, z);

            switch (orientation)
            {
                case OrientationFlags.SideWest:
                case OrientationFlags.SideEast:
                    return 1;
                case OrientationFlags.SideSouth:
                case OrientationFlags.SideNorth:
                case OrientationFlags.SideBottom:
                case OrientationFlags.SideTop:
                default:
                    return 0;
            }
        }
开发者ID:BlackOrca,项目名称:octoawesome,代码行数:17,代码来源:CactusBlockDefinition.cs


示例4: GetEastTextureIndex

        public override int GetEastTextureIndex(ILocalChunkCache manager, int x, int y, int z)
        {
            OrientationFlags orientation = (OrientationFlags)manager.GetBlockMeta(x, y, z);
            ushort topblock = manager.GetBlock(x, y, z + 1);

            switch (orientation)
            {
                case OrientationFlags.SideWest:
                case OrientationFlags.SideEast:
                    if (topblock != 0)
                        return 0;
                    else
                        return 2;
                case OrientationFlags.SideSouth:
                case OrientationFlags.SideNorth:
                case OrientationFlags.SideBottom:
                case OrientationFlags.SideTop:
                default:
                    return 1;
            }
        }
开发者ID:BlackOrca,项目名称:octoawesome,代码行数:21,代码来源:CactusBlockDefinition.cs


示例5: GetWestTextureIndex

 public override int GetWestTextureIndex(ILocalChunkCache manager, int x, int y, int z)
 {
     return 2;
 }
开发者ID:jvbsl,项目名称:octoawesome,代码行数:4,代码来源:SnowBlockDefinition.cs


示例6: GetBottomTextureIndex

 public override int GetBottomTextureIndex(ILocalChunkCache manager, int x, int y, int z)
 {
     return 1;
 }
开发者ID:jvbsl,项目名称:octoawesome,代码行数:4,代码来源:SnowBlockDefinition.cs


示例7: GetCollisionBoxes

 /// <summary>
 /// Liefert die Kollisionsbox für den Block. Da ein Array zurück gegeben wird, lässt sich die 
 /// </summary>
 /// <param name="manager">[Bitte ergänzen]</param>
 /// <param name="x">X-Anteil der Koordinate des Blocks</param>
 /// <param name="y">Y-Anteil der Koordinate des Blocks</param>
 /// <param name="z">Z-Anteil der Koordinate des Blocks</param>
 /// <returns>Ein Array von Kollisionsboxen</returns>
 public virtual BoundingBox[] GetCollisionBoxes(ILocalChunkCache manager, int x, int y, int z)
 {
     return new[] { new BoundingBox(new Vector3(0, 0, 0), new Vector3(1, 1, 1)) };
 }
开发者ID:reicheltp,项目名称:octoawesome,代码行数:12,代码来源:BlockDefinition.cs


示例8: GetBottomTextureRotation

 /// <summary>
 /// Rotation der Textur in 90° Schritten für die Unterseite (Negativ Z) des Blocks
 /// </summary>
 /// <param name="manager">[Bitte ergänzen]</param>
 /// <param name="x">X-Anteil der Koordinate des Blocks</param>
 /// <param name="y">Y-Anteil der Koordinate des Blocks</param>
 /// <param name="z">Z-Anteil der Koordinate des Blocks</param>
 /// <returns>Rotation der Textur in 90° Schritten</returns>
 public virtual int GetBottomTextureRotation(ILocalChunkCache manager, int x, int y, int z)
 {
     return 0;
 }
开发者ID:reicheltp,项目名称:octoawesome,代码行数:12,代码来源:BlockDefinition.cs


示例9: IsWestSolidWall

 /// <summary>
 /// Gibt an, ob die Westseite (Positiv X) undurchsichtig ist, also Blöcke dahinter nicht gesehen werden können
 /// </summary>
 /// <param name="manager">[Bitte ergänzen]</param>
 /// <param name="x">X-Anteil der Koordinate des Blocks</param>
 /// <param name="y">Y-Anteil der Koordinate des Blocks</param>
 /// <param name="z">Z-Anteil der Koordinate des Blocks</param>
 /// <returns>True, wenn die Wand undurchsichtig ist</returns>
 public virtual bool IsWestSolidWall(ILocalChunkCache manager, int x, int y, int z)
 {
     return true;
 }
开发者ID:reicheltp,项目名称:octoawesome,代码行数:12,代码来源:BlockDefinition.cs


示例10: GetWestTextureIndex

 /// <summary>
 /// Texturindex für das Array <see cref="Textures"/> für die Westseite (Negativ X) des Blocks
 /// </summary>
 /// <param name="manager">[Bitte ergänzen]</param>
 /// <param name="x">X-Anteil der Koordinate des Blocks</param>
 /// <param name="y">Y-Anteil der Koordinate des Blocks</param>
 /// <param name="z">Z-Anteil der Koordinate des Blocks</param>
 /// <returns>Index für das Array <see cref="Textures"/></returns>
 public virtual int GetWestTextureIndex(ILocalChunkCache manager, int x, int y, int z)
 {
     return 0;
 }
开发者ID:reicheltp,项目名称:octoawesome,代码行数:12,代码来源:BlockDefinition.cs


示例11: GetProperties

 /// <summary>
 /// Liefert die Physikalischen Paramerter, wie härte, dichte und bruchzähigkeit
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="x">X-Anteil der Koordinate des Blocks</param>
 /// <param name="y">Y-Anteil der Koordinate des Blocks</param>
 /// <param name="z">Z-Anteil der Koordinate des Blocks</param>
 /// <returns>Die physikalischen Parameter</returns>
 public abstract PhysicalProperties GetProperties(ILocalChunkCache manager, int x, int y, int z);
开发者ID:reicheltp,项目名称:octoawesome,代码行数:9,代码来源:BlockDefinition.cs


示例12: IsWestSolidWall

 public override bool IsWestSolidWall(ILocalChunkCache manager, int x, int y, int z)
 {
     return false;
 }
开发者ID:reicheltp,项目名称:octoawesome,代码行数:4,代码来源:WaterBlockDefinition.cs


示例13: GetProperties

 public override PhysicalProperties GetProperties(ILocalChunkCache manager, int x, int y, int z)
 {
     throw new NotImplementedException();
 }
开发者ID:RapidHelmus,项目名称:octoawesome,代码行数:4,代码来源:TestBlockDefinition.cs


示例14: ActorHost

        public ActorHost(Player player)
        {
            Player = player;
            planet = ResourceManager.Instance.GetPlanet(Player.Position.Planet);

            localChunkCache = new LocalChunkCache(ResourceManager.Instance.GlobalChunkCache, 2, 1, true);
            _oldIndex = Player.Position.ChunkIndex;

            ActiveTool = null;
            ReadyState = false;
        }
开发者ID:RapidHelmus,项目名称:octoawesome,代码行数:11,代码来源:ActorHost.cs


示例15: SceneControl

        public SceneControl(ScreenComponent manager, string style = "")
            : base(manager, style)
        {
            player = manager.Player;
            camera = manager.Camera;

            Manager = manager;

            simpleShader = manager.Game.Content.Load<Effect>("simple");
            sunTexture = manager.Game.Content.LoadTexture2DFromFile("./Assets/OctoAwesome.Client/sun.png", manager.GraphicsDevice);

            List<Bitmap> bitmaps = new List<Bitmap>();
            var definitions = DefinitionManager.Instance.GetBlockDefinitions();
            foreach (var definition in definitions)
                bitmaps.AddRange(definition.Textures);

            int size = (int)Math.Ceiling(Math.Sqrt(bitmaps.Count));
            Bitmap blocks = new Bitmap(size * TEXTURESIZE, size * TEXTURESIZE);
            using (Graphics g = Graphics.FromImage(blocks))
            {
                int counter = 0;
                foreach (var bitmap in bitmaps)
                {
                    int x = counter % size;
                    int y = (int)(counter / size);
                    g.DrawImage(bitmap, new System.Drawing.Rectangle(TEXTURESIZE * x, TEXTURESIZE * y, TEXTURESIZE, TEXTURESIZE));
                    counter++;
                }
            }

            using (MemoryStream stream = new MemoryStream())
            {
                blocks.Save(stream, ImageFormat.Png);
                stream.Seek(0, SeekOrigin.Begin);
                blockTextures = Texture2D.FromStream(manager.GraphicsDevice, stream);
            }

            planet = ResourceManager.Instance.GetPlanet(0);

            // TODO: evtl. Cache-Size (Dimensions) VIEWRANGE + 1

            int range = ((int)Math.Pow(2, VIEWRANGE) - 2) / 2;
            localChunkCache = new LocalChunkCache(ResourceManager.Instance.GlobalChunkCache, VIEWRANGE, range);

            chunkRenderer = new ChunkRenderer[
                (int)Math.Pow(2, VIEWRANGE) * (int)Math.Pow(2, VIEWRANGE),
                planet.Size.Z];
            orderedChunkRenderer = new List<ChunkRenderer>(
                (int)Math.Pow(2, VIEWRANGE) * (int)Math.Pow(2, VIEWRANGE) * planet.Size.Z);

            for (int i = 0; i < chunkRenderer.GetLength(0); i++)
            {
                for (int j = 0; j < chunkRenderer.GetLength(1); j++)
                {
                    ChunkRenderer renderer = new ChunkRenderer(simpleShader, manager.GraphicsDevice, camera.Projection, blockTextures);
                    chunkRenderer[i, j] = renderer;
                    orderedChunkRenderer.Add(renderer);
                }
            }

            backgroundThread = new Thread(BackgroundLoop);
            backgroundThread.Priority = ThreadPriority.Lowest;
            backgroundThread.IsBackground = true;
            backgroundThread.Start();

            selectionLines = new[]
            {
                new VertexPositionColor(new Vector3(-0.001f, +1.001f, +1.001f), Microsoft.Xna.Framework.Color.Black * 0.5f),
                new VertexPositionColor(new Vector3(+1.001f, +1.001f, +1.001f), Microsoft.Xna.Framework.Color.Black * 0.5f),
                new VertexPositionColor(new Vector3(-0.001f, -0.001f, +1.001f), Microsoft.Xna.Framework.Color.Black * 0.5f),
                new VertexPositionColor(new Vector3(+1.001f, -0.001f, +1.001f), Microsoft.Xna.Framework.Color.Black * 0.5f),
                new VertexPositionColor(new Vector3(-0.001f, +1.001f, -0.001f), Microsoft.Xna.Framework.Color.Black * 0.5f),
                new VertexPositionColor(new Vector3(+1.001f, +1.001f, -0.001f), Microsoft.Xna.Framework.Color.Black * 0.5f),
                new VertexPositionColor(new Vector3(-0.001f, -0.001f, -0.001f), Microsoft.Xna.Framework.Color.Black * 0.5f),
                new VertexPositionColor(new Vector3(+1.001f, -0.001f, -0.001f), Microsoft.Xna.Framework.Color.Black * 0.5f),
            };

            billboardVertices = new[]
            {
                new VertexPositionTexture(new Vector3(-0.5f, 0.5f, 0), new Vector2(0, 0)),
                new VertexPositionTexture(new Vector3(0.5f, 0.5f, 0), new Vector2(1, 0)),
                new VertexPositionTexture(new Vector3(-0.5f, -0.5f, 0), new Vector2(0, 1)),
                new VertexPositionTexture(new Vector3(0.5f, 0.5f, 0), new Vector2(1, 0)),
                new VertexPositionTexture(new Vector3(0.5f, -0.5f, 0), new Vector2(1, 1)),
                new VertexPositionTexture(new Vector3(-0.5f, -0.5f, 0), new Vector2(0, 1)),
            };

            selectionIndeces = new short[]
            {
                0, 1, 0, 2, 1, 3, 2, 3,
                4, 5, 4, 6, 5, 7, 6, 7,
                0, 4, 1, 5, 2, 6, 3, 7
            };

            sunEffect = new BasicEffect(manager.GraphicsDevice);
            sunEffect.TextureEnabled = true;

            selectionEffect = new BasicEffect(manager.GraphicsDevice);
            selectionEffect.VertexColorEnabled = true;

//.........这里部分代码省略.........
开发者ID:ManuelHu,项目名称:octoawesome,代码行数:101,代码来源:SceneControl.cs


示例16: SceneControl

        public SceneControl(ScreenComponent manager, string style = "")
            : base(manager, style)
        {
            player = manager.Player;
            camera = manager.Camera;
            assets = manager.Game.Assets;

            Manager = manager;

            simpleShader = manager.Game.Content.Load<Effect>("simple");
            sunTexture = assets.LoadTexture(typeof(ScreenComponent), "sun");

            //List<Bitmap> bitmaps = new List<Bitmap>();
            var definitions = DefinitionManager.Instance.GetBlockDefinitions();
            int textureCount = 0;
            foreach (var definition in definitions)
            {
                textureCount += definition.Textures.Length;
            }
            int bitmapSize = 128;
            blockTextures = new Texture2DArray(manager.GraphicsDevice, 1, bitmapSize, bitmapSize, textureCount);
            int layer = 0;
            foreach (var definition in definitions)
            {
                foreach (var bitmap in definition.Textures)
                {
                    System.Drawing.Bitmap texture = manager.Game.Assets.LoadBitmap(definition.GetType(), bitmap);

                    var scaled = texture;//new Bitmap(bitmap, new System.Drawing.Size(bitmapSize, bitmapSize));
                    int[] data = new int[scaled.Width * scaled.Height];
                    var bitmapData = scaled.LockBits(new System.Drawing.Rectangle(0, 0, scaled.Width, scaled.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                    System.Runtime.InteropServices.Marshal.Copy(bitmapData.Scan0, data, 0, data.Length);
                    blockTextures.SetData(data, layer);
                    scaled.UnlockBits(bitmapData);
                    layer++;
                }
            }

            /*int size = (int)Math.Ceiling(Math.Sqrt(bitmaps.Count));
            Bitmap blocks = new Bitmap(size * TEXTURESIZE, size * TEXTURESIZE);
            using (Graphics g = Graphics.FromImage(blocks))
            {
                int counter = 0;
                foreach (var bitmap in bitmaps)
                {
                    int x = counter % size;
                    int y = (int)(counter / size);
                    g.DrawImage(bitmap, new System.Drawing.Rectangle(TEXTURESIZE * x, TEXTURESIZE * y, TEXTURESIZE, TEXTURESIZE));
                    counter++;
                }
            }

            using (MemoryStream stream = new MemoryStream())
            {
                blocks.Save(stream, ImageFormat.Png);
                stream.Seek(0, SeekOrigin.Begin);
                blockTextures = Texture2D.FromStream(manager.GraphicsDevice, stream);
            }*/

            planet = ResourceManager.Instance.GetPlanet(0);

            // TODO: evtl. Cache-Size (Dimensions) VIEWRANGE + 1

            int range = ((int)Math.Pow(2, VIEWRANGE) - 2) / 2;
            localChunkCache = new LocalChunkCache(ResourceManager.Instance.GlobalChunkCache, VIEWRANGE, range);

            chunkRenderer = new ChunkRenderer[
                (int)Math.Pow(2, VIEWRANGE) * (int)Math.Pow(2, VIEWRANGE),
                planet.Size.Z];
            orderedChunkRenderer = new List<ChunkRenderer>(
                (int)Math.Pow(2, VIEWRANGE) * (int)Math.Pow(2, VIEWRANGE) * planet.Size.Z);

            for (int i = 0; i < chunkRenderer.GetLength(0); i++)
            {
                for (int j = 0; j < chunkRenderer.GetLength(1); j++)
                {
                    ChunkRenderer renderer = new ChunkRenderer(simpleShader, manager.GraphicsDevice, camera.Projection, blockTextures);
                    chunkRenderer[i, j] = renderer;
                    orderedChunkRenderer.Add(renderer);
                }
            }

            backgroundThread = new Thread(BackgroundLoop);
            backgroundThread.Priority = ThreadPriority.Lowest;
            backgroundThread.IsBackground = true;
            backgroundThread.Start();

            var selectionVertices = new[]
            {
                new VertexPositionColor(new Vector3(-0.001f, +1.001f, +1.001f), Color.Black * 0.5f),
                new VertexPositionColor(new Vector3(+1.001f, +1.001f, +1.001f), Color.Black * 0.5f),
                new VertexPositionColor(new Vector3(-0.001f, -0.001f, +1.001f), Color.Black * 0.5f),
                new VertexPositionColor(new Vector3(+1.001f, -0.001f, +1.001f), Color.Black * 0.5f),
                new VertexPositionColor(new Vector3(-0.001f, +1.001f, -0.001f), Color.Black * 0.5f),
                new VertexPositionColor(new Vector3(+1.001f, +1.001f, -0.001f), Color.Black * 0.5f),
                new VertexPositionColor(new Vector3(-0.001f, -0.001f, -0.001f), Color.Black * 0.5f),
                new VertexPositionColor(new Vector3(+1.001f, -0.001f, -0.001f), Color.Black * 0.5f),
            };

            var billboardVertices = new[]
//.........这里部分代码省略.........
开发者ID:BlackOrca,项目名称:octoawesome,代码行数:101,代码来源:SceneControl.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ILocalDefinition类代码示例发布时间:2022-05-24
下一篇:
C# ILoader类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap