示例#1
0
        private static void Render(
            Tiles.Visible tile,
            int tileIndex, // Tile index in its layer
            Map map,
            ContentManager contentManager,
            SpriteBatch spriteBatch,
            Camera camera
            )
        {
            if (tile.gid == 0)
            {
                // Skip empty tiles
                return;
            }

            PhysicalVector2 tilePos  = GetTilePosition(map, tileIndex);
            var             position = new Ecs.Components.Position()
            {
                data = tilePos
            };

            Tileset   tileset             = GetTilesetOfTile(map, tile.gid);
            Texture2D tilesetTexture      = GetTexture(contentManager, tileset);
            var       texturePosRectangle = GetTexturePosRectangle(
                tile.gid,
                tileset,
                map
                );
            var           destRectangle = GetDestRectangle(map);
            SpriteEffects effects       = GetSpriteEffects(tile);

            var sprite = new EcsExt.Components.Visibles.Sprite()
            {
                texture             = tilesetTexture,
                texturePosRectangle = texturePosRectangle,
                destRectangle       = destRectangle,
                tint    = Color.White,
                effects = effects
            };

            EcsExt.Systems.SpriteRender.Render(
                sprite,
                position,
                spriteBatch,
                camera
                );
        }
示例#2
0
        private static void Render(
            GameTile tile,
            int tileIndex, // Tile index in its layer
            Map map,
            ContentManager contentManager,
            SpriteBatch spriteBatch,
            Camera camera
            )
        {
            if (tile.kind == GameTile.Kind.Empty)
            {
                // Skip empty tiles
                return;
            }

            PhysicalVector2 tilePos  = GetTilePosition(map, tileIndex);
            var             position = new Ecs.Components.Position()
            {
                data = tilePos
            };

            Tileset   tileset             = map.GameTileset;
            Texture2D tilesetTexture      = GetTexture(contentManager, tileset);
            int       tileFrame           = tile.GetTileFrame;
            var       texturePosRectangle = GetTexturePosRectangleWithTileFrame(
                tileFrame,
                tileset,
                map
                );
            var destRectangle = GetDestRectangle(map);

            var sprite = new EcsExt.Components.Visibles.Sprite()
            {
                texture             = tilesetTexture,
                texturePosRectangle = texturePosRectangle,
                destRectangle       = destRectangle,
                tint = Color.White
            };

            EcsExt.Systems.SpriteRender.Render(
                sprite,
                position,
                spriteBatch,
                camera
                );
        }