diff --git a/ZoFo/Content/Textures/Background/TilesetFloor.png b/ZoFo/Content/Textures/Background/TilesetFloor.png new file mode 100644 index 0000000..abba7bf Binary files /dev/null and b/ZoFo/Content/Textures/Background/TilesetFloor.png differ diff --git a/ZoFo/GameCore/GameManagers/MapManager/MapManager.cs b/ZoFo/GameCore/GameManagers/MapManager/MapManager.cs index 74f559e..a02a5aa 100644 --- a/ZoFo/GameCore/GameManagers/MapManager/MapManager.cs +++ b/ZoFo/GameCore/GameManagers/MapManager/MapManager.cs @@ -13,11 +13,16 @@ namespace ZoFo.GameCore.GameManagers.MapManager { public class MapManager { - private static readonly string _path = "/{0}.tmj"; + private static readonly string _path = "TileMaps/{0}.tmj"; private List _tileSets = new List(); + /// + /// Загрузка карты. Передаётся название файла карты. По умолчанию main. + /// + /// public void LoadMap(string mapName = "main") { + // Загрузка TileMap TileMap tileMap; using (StreamReader reader = new StreamReader(string.Format(_path, mapName))) { @@ -25,6 +30,7 @@ namespace ZoFo.GameCore.GameManagers.MapManager tileMap = JsonSerializer.Deserialize(data); } + // Загрузка TileSet-ов по TileSetInfo List tileSets = new List(); foreach (TileSetInfo tileSetInfo in tileMap.TileSets) { @@ -35,30 +41,32 @@ namespace ZoFo.GameCore.GameManagers.MapManager foreach (var chunk in tileMap.Layers[0].Chunks) { - int i = 0; - foreach (var id in chunk.Data) + for (int i = 0; i < chunk.Data.Length; i++) { foreach (var tileSet in tileSets) { - if (tileSet.FirstGid - id < 0) + if (tileSet.FirstGid - chunk.Data[i] < 0) { - int number = id - tileSet.FirstGid; + int number = chunk.Data[i] - tileSet.FirstGid; int relativeColumn = number % tileSet.Columns * tileSet.TileWidth; int relativeRow = number / tileSet.Columns * tileSet.TileHeight; - Rectangle sourceRectangle = new Rectangle(relativeColumn * tileSet.TileWidth, relativeRow * tileSet.TileHeight, + Rectangle sourceRectangle = new Rectangle(relativeColumn * tileSet.TileWidth, relativeRow * tileSet.TileHeight, relativeColumn * tileSet.TileWidth + tileSet.TileWidth, relativeRow * tileSet.TileHeight + tileSet.TileHeight); Vector2 position = new Vector2(i % chunk.Width, i / chunk.Height); } } - i++; } } - } + /// + /// Загружает и парсит TileSet по его пути. + /// + /// + /// private TileSet LoadTileSet(string path) { using (StreamReader reader = new StreamReader(path)) @@ -67,6 +75,5 @@ namespace ZoFo.GameCore.GameManagers.MapManager return JsonSerializer.Deserialize(data); } } - } } diff --git a/ZoFo/GameCore/GameManagers/MapManager/MapProject.tiled-session b/ZoFo/GameCore/GameManagers/MapManager/MapProject.tiled-session new file mode 100644 index 0000000..daf2ffb --- /dev/null +++ b/ZoFo/GameCore/GameManagers/MapManager/MapProject.tiled-session @@ -0,0 +1,17 @@ +{ + "activeFile": "", + "expandedProjectPaths": [ + ], + "fileStates": { + "TileSets/TileSet 1.tsj": { + "scaleInDock": 1, + "scaleInEditor": 1 + } + }, + "openFiles": [ + ], + "project": "", + "recentFiles": [ + "TileSets/TileSet 1.tsj" + ] +} diff --git a/ZoFo/GameCore/GameManagers/MapManager/MapSession.tiled-project b/ZoFo/GameCore/GameManagers/MapManager/MapSession.tiled-project new file mode 100644 index 0000000..d0eb592 --- /dev/null +++ b/ZoFo/GameCore/GameManagers/MapManager/MapSession.tiled-project @@ -0,0 +1,14 @@ +{ + "automappingRulesFile": "", + "commands": [ + ], + "compatibilityVersion": 1100, + "extensionsPath": "extensions", + "folders": [ + "." + ], + "properties": [ + ], + "propertyTypes": [ + ] +} diff --git a/ZoFo/GameCore/GameManagers/MapManager/MapSession.tiled-session b/ZoFo/GameCore/GameManagers/MapManager/MapSession.tiled-session new file mode 100644 index 0000000..9f02627 --- /dev/null +++ b/ZoFo/GameCore/GameManagers/MapManager/MapSession.tiled-session @@ -0,0 +1,21 @@ +{ + "Map/SizeTest": { + "height": 4300, + "width": 2 + }, + "activeFile": "", + "expandedProjectPaths": [ + ], + "fileStates": { + }, + "last.imagePath": "D:/C#/Я смотрел ваши ХАКАТОНЫ/ZoFo/ZoFo/Content/Textures/Background", + "map.fixedSize": false, + "map.lastUsedFormat": "tmx", + "map.tileHeight": 16, + "map.tileWidth": 16, + "openFiles": [ + ], + "project": "MapSession.tiled-project", + "recentFiles": [ + ] +} diff --git a/ZoFo/GameCore/GameManagers/MapManager/TileMaps/main.tmx b/ZoFo/GameCore/GameManagers/MapManager/TileMaps/main.tmx new file mode 100644 index 0000000..4cafd72 --- /dev/null +++ b/ZoFo/GameCore/GameManagers/MapManager/TileMaps/main.tmx @@ -0,0 +1,116 @@ + + + + + + +24,24,24,28,29,24,24,24,28,46,29,24,25,115,45,46, +24,24,24,25,23,24,24,24,50,2,51,24,50,2,2,2, +24,24,24,50,32,29,24,24,24,24,24,24,24,24,24,28, +28,29,24,28,10,32,29,24,24,28,46,29,24,24,24,50, +47,23,24,50,32,10,32,46,29,50,2,51,24,24,24,24, +1,32,29,90,25,23,50,2,32,29,24,90,28,29,24,24, +51,50,32,29,50,51,90,24,25,45,46,29,25,23,24,90, +24,24,50,32,46,29,24,28,10,2,2,51,50,51,24,90, +24,24,24,50,2,32,46,10,32,29,24,90,24,24,24,90, +29,24,89,24,24,50,3,23,50,32,46,46,46,46,29,24, +51,24,24,28,29,24,25,23,24,25,1,2,3,111,45,29, +24,90,24,50,51,24,25,23,28,47,23,89,50,3,115,23, +24,24,24,24,24,89,50,32,47,1,51,24,24,50,2,51, +28,29,24,24,24,24,28,10,2,51,24,24,24,24,24,28, +10,32,29,24,24,24,25,23,28,29,90,24,24,90,24,50, +32,10,51,24,24,24,50,32,10,32,29,24,90,28,29,24 + + +10,51,24,90,24,25,23,28,29,24,24,24,24,24,24,24, +51,24,28,29,24,50,32,10,51,24,24,24,24,24,24,24, +29,28,10,32,46,29,50,32,29,24,24,24,24,24,24,24, +51,25,23,50,2,32,29,25,23,24,24,28,29,24,90,24, +24,25,23,24,24,25,23,50,51,24,24,50,32,29,24,90, +24,50,32,29,90,25,45,29,24,24,24,24,50,51,24,89, +24,89,50,51,24,25,114,23,24,24,24,24,24,24,24,24, +24,24,28,29,24,50,2,51,24,24,90,28,29,24,24,28, +24,24,25,23,89,24,24,24,28,46,29,25,23,24,24,50, +28,46,10,51,24,28,46,29,25,111,45,10,51,28,29,24, +50,2,51,24,24,25,115,45,10,3,1,51,24,25,23,24, +24,24,24,24,24,50,2,2,32,10,51,24,90,25,23,24, +24,24,24,24,24,24,24,24,50,51,24,24,24,25,23,24, +46,29,24,24,24,24,24,89,24,24,24,28,46,47,23,90, +2,32,29,24,24,28,46,46,29,24,24,25,1,3,23,89, +24,50,32,29,24,25,1,3,23,24,89,50,32,10,51,24 + + +24,24,24,24,90,24,89,24,89,24,50,51,89,24,24,24, +24,28,29,28,29,24,24,24,24,28,29,24,24,24,28,29, +24,25,23,50,51,24,24,28,29,50,51,24,24,24,25,45, +90,50,51,28,29,24,24,25,23,24,24,28,29,24,50,3, +24,24,28,10,51,90,90,50,51,24,24,50,51,24,24,50, +24,24,25,45,29,24,28,29,24,24,24,24,24,28,29,24, +90,24,50,2,51,28,10,51,90,24,28,29,24,25,45,46, +29,90,24,24,24,50,51,24,24,28,10,32,46,10,3,1, +32,29,24,90,24,24,24,24,28,47,23,50,2,51,50,51, +25,23,24,24,28,46,46,46,47,114,45,29,24,24,24,24, +50,32,29,24,50,3,111,111,115,111,1,32,29,24,24,24, +24,50,51,24,28,10,2,2,2,2,32,10,51,24,24,89, +24,24,89,90,25,23,24,24,24,24,50,32,46,46,29,89, +24,24,24,90,25,23,89,24,28,29,90,50,2,2,51,24, +24,24,24,28,10,51,24,28,47,45,29,24,24,24,24,24, +24,24,24,25,23,24,90,50,2,2,32,46,46,46,46,46 + + +10,32,46,29,24,24,24,25,23,50,32,29,24,50,32,46, +51,50,2,32,29,24,24,25,45,29,25,23,24,24,25,1, +24,24,24,25,23,28,46,10,2,51,50,51,24,24,50,51, +90,89,90,50,51,50,2,51,24,24,28,29,90,24,24,24, +90,28,46,29,90,24,24,24,90,24,50,51,90,24,90,28, +29,50,2,51,24,24,24,89,24,24,24,24,24,89,24,50, +23,24,24,28,46,29,90,90,24,89,24,28,29,24,24,24, +32,46,29,25,115,45,29,24,90,24,24,25,23,24,24,28, +10,2,32,47,115,1,51,24,24,24,24,25,23,24,28,10, +32,29,50,2,2,51,24,24,24,24,24,25,23,28,10,51, +50,51,89,24,24,89,24,28,29,24,24,50,32,10,32,46, +24,24,90,90,28,46,29,50,51,24,24,24,25,23,25,115, +24,90,24,24,50,2,32,29,24,24,90,24,25,45,10,2, +24,24,24,24,24,24,50,32,29,24,24,28,10,3,23,24, +90,24,24,24,24,89,90,50,32,29,90,50,51,50,32,46, +46,29,24,90,24,24,24,24,50,51,28,29,24,24,50,2 + + +46,46,10,32,46,47,23,25,23,89,24,24,25,23,90,24, +2,2,32,47,1,2,51,25,23,24,28,29,50,32,29,24, +24,90,50,3,23,24,28,10,51,28,47,45,29,25,23,28, +24,24,24,50,51,28,47,23,24,50,3,114,45,10,51,50, +29,24,24,89,24,25,114,45,46,46,10,2,2,32,29,89, +51,24,24,24,24,50,3,111,115,115,23,24,24,50,32,29, +24,28,29,24,24,24,25,1,2,2,51,90,24,90,50,51, +29,50,32,29,28,29,25,23,24,24,89,28,29,24,24,24, +51,24,50,51,50,32,10,32,46,29,24,50,51,24,90,24, +24,24,24,24,89,50,32,10,2,32,46,29,89,28,29,24, +29,90,24,24,24,24,50,51,28,10,3,23,28,10,51,24, +23,89,24,24,90,24,24,24,50,32,10,51,50,51,24,24, +51,24,24,24,24,24,24,24,24,50,32,46,46,29,28,46, +24,24,24,90,24,24,24,24,24,24,50,3,1,32,47,115, +46,29,24,89,24,24,24,89,24,24,24,25,45,10,3,111, +2,51,28,29,28,29,24,28,46,46,46,10,2,51,50,2 + + +28,29,28,10,32,46,29,24,24,28,10,2,2,2,2,2, +50,51,50,51,25,115,45,46,29,50,51,24,24,24,24,24, +29,24,89,24,50,3,115,114,23,24,24,24,24,24,24,24, +51,90,24,89,24,50,2,2,51,24,89,24,24,28,46,29, +24,90,24,24,89,24,90,28,29,24,24,24,28,10,2,51, +24,24,24,24,28,29,90,50,51,28,29,24,25,23,24,24, +28,29,24,24,50,32,29,28,29,50,51,89,50,32,29,24, +50,51,24,24,24,50,32,10,51,24,89,24,24,25,23,24, +24,24,24,24,24,24,50,32,29,24,24,24,24,50,51,24, +90,24,24,24,24,24,24,25,45,29,24,24,24,89,28,29, +24,24,24,24,28,29,24,25,1,51,24,24,24,24,50,32, +28,29,28,29,50,32,46,10,51,28,29,24,24,24,24,50, +47,45,10,51,24,50,2,32,46,47,23,24,89,90,24,24, +111,115,23,24,24,90,24,50,2,2,32,29,24,89,28,46, +1,2,51,28,46,46,29,24,28,29,50,32,29,28,47,111, +51,24,24,50,3,114,23,24,50,32,46,47,23,25,111,111 + + + + diff --git a/ZoFo/GameCore/GameManagers/MapManager/TileSets/TileSet 1.tsj b/ZoFo/GameCore/GameManagers/MapManager/TileSets/TileSet 1.tsj new file mode 100644 index 0000000..3388a9e --- /dev/null +++ b/ZoFo/GameCore/GameManagers/MapManager/TileSets/TileSet 1.tsj @@ -0,0 +1,166 @@ +{ "class":"Tile", + "columns":22, + "grid": + { + "height":24, + "orientation":"orthogonal", + "width":24 + }, + "image":"..\/..\/..\/..\/Content\/Textures\/Background\/TilesetFloor.png", + "imageheight":417, + "imagewidth":352, + "margin":0, + "name":"TileSet 1", + "spacing":0, + "tilecount":572, + "tiledversion":"1.10.2", + "tileheight":16, + "tiles":[ + { + "id":27, + "probability":0.5 + }, + { + "id":28, + "probability":0.5 + }, + { + "id":49, + "probability":0.5 + }, + { + "id":50, + "probability":0.5 + }, + { + "id":88, + "probability":0.100000001490116 + }, + { + "id":89, + "probability":0.100000001490116 + }, + { + "id":110, + "probability":2 + }, + { + "id":111, + "probability":0.100000001490116 + }, + { + "id":112, + "probability":0.100000001490116 + }], + "tilewidth":16, + "type":"tileset", + "version":"1.10", + "wangsets":[ + { + "colors":[ + { + "color":"#ff0000", + "name":"Sand", + "probability":1, + "tile":23 + }, + { + "color":"#00ff00", + "name":"SandStone", + "probability":0.3, + "tile":110 + }], + "name":"\u041f\u0435\u0441\u0447\u0430\u043d\u044b\u0439", + "tile":-1, + "type":"corner", + "wangtiles":[ + { + "tileid":0, + "wangid":[0, 2, 0, 1, 0, 2, 0, 2] + }, + { + "tileid":1, + "wangid":[0, 2, 0, 1, 0, 1, 0, 2] + }, + { + "tileid":2, + "wangid":[0, 2, 0, 2, 0, 1, 0, 2] + }, + { + "tileid":9, + "wangid":[0, 2, 0, 1, 0, 2, 0, 1] + }, + { + "tileid":22, + "wangid":[0, 1, 0, 1, 0, 2, 0, 2] + }, + { + "tileid":23, + "wangid":[0, 1, 0, 1, 0, 1, 0, 1] + }, + { + "tileid":24, + "wangid":[0, 2, 0, 2, 0, 1, 0, 1] + }, + { + "tileid":27, + "wangid":[0, 1, 0, 2, 0, 1, 0, 1] + }, + { + "tileid":28, + "wangid":[0, 1, 0, 1, 0, 2, 0, 1] + }, + { + "tileid":31, + "wangid":[0, 1, 0, 2, 0, 1, 0, 2] + }, + { + "tileid":44, + "wangid":[0, 1, 0, 2, 0, 2, 0, 2] + }, + { + "tileid":45, + "wangid":[0, 1, 0, 2, 0, 2, 0, 1] + }, + { + "tileid":46, + "wangid":[0, 2, 0, 2, 0, 2, 0, 1] + }, + { + "tileid":49, + "wangid":[0, 2, 0, 1, 0, 1, 0, 1] + }, + { + "tileid":50, + "wangid":[0, 1, 0, 1, 0, 1, 0, 2] + }, + { + "tileid":88, + "wangid":[0, 1, 0, 1, 0, 1, 0, 1] + }, + { + "tileid":89, + "wangid":[0, 1, 0, 1, 0, 1, 0, 1] + }, + { + "tileid":110, + "wangid":[0, 2, 0, 2, 0, 2, 0, 2] + }, + { + "tileid":111, + "wangid":[0, 2, 0, 2, 0, 2, 0, 2] + }, + { + "tileid":112, + "wangid":[0, 2, 0, 2, 0, 2, 0, 2] + }, + { + "tileid":113, + "wangid":[0, 2, 0, 2, 0, 2, 0, 2] + }, + { + "tileid":114, + "wangid":[0, 2, 0, 2, 0, 2, 0, 2] + }] + }] +} \ No newline at end of file