コード例 #1
0
ファイル: MapBase.cs プロジェクト: mapic91/JxqyHD
        public static void OpenMap(string mapFileName)
        {
            var ext = Path.GetExtension(mapFileName);

            switch (ext)
            {
            case ".map":
                Instance = new JxqyMap(mapFileName);
                break;

            case ".tmx":
                Instance = new TiledMap(mapFileName);
                break;
            }
        }
コード例 #2
0
        public override Texture2D GetTileTextureAndRegionInWorld(int x, int y, int layer, out Nullable <Rectangle> sourceRegion, ref Rectangle region)
        {
            sourceRegion = null;
            if (!IsOk)
            {
                return(null);
            }
            var texture = GetTileTexture(x, y, layer);

            if (texture != null)
            {
                var position = MapBase.ToPixelPosition(x, y) - new Vector2(texture.Width / 2f, texture.Height - 16f);
                region = new Rectangle((int)position.X, (int)position.Y, texture.Width, texture.Height);
            }
            return(texture);
        }
コード例 #3
0
ファイル: TiledMap.cs プロジェクト: zy1911/JxqyHD
        public override Texture2D GetTileTextureAndRegionInWorld(int x, int y, int layer, out Nullable <Rectangle> sourceRegion, ref Rectangle region)
        {
            var info = GetTileTextureInfo(x, y, layer);

            if (info != null)
            {
                var width = info.TextureSourceRegion.HasValue
                    ? info.TextureSourceRegion.Value.Width
                    : info.Texture.Width;
                var height = info.TextureSourceRegion.HasValue
                    ? info.TextureSourceRegion.Value.Height
                    : info.Texture.Height;
                var position = MapBase.ToPixelPosition(x, y) -
                               new Vector2(32, height - 16f) +
                               new Vector2(info.BelongTileset.TileOffset.X, info.BelongTileset.TileOffset.Y);
                region       = new Rectangle((int)position.X, (int)position.Y, width, height);
                sourceRegion = info.TextureSourceRegion;
                return(info.Texture);
            }
            sourceRegion = null;
            return(null);
        }