commit
2ec1b3b268
7 changed files with 350 additions and 9 deletions
BIN
ZoFo/Content/Textures/Background/TilesetFloor.png
Normal file
BIN
ZoFo/Content/Textures/Background/TilesetFloor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
|
@ -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<TileSet> _tileSets = new List<TileSet>();
|
||||
|
||||
/// <summary>
|
||||
/// Загрузка карты. Передаётся название файла карты. По умолчанию main.
|
||||
/// </summary>
|
||||
/// <param name="mapName"></param>
|
||||
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<TileMap>(data);
|
||||
}
|
||||
|
||||
// Загрузка TileSet-ов по TileSetInfo
|
||||
List<TileSet> tileSets = new List<TileSet>();
|
||||
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++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Загружает и парсит TileSet по его пути.
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <returns></returns>
|
||||
private TileSet LoadTileSet(string path)
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(path))
|
||||
|
@ -67,6 +75,5 @@ namespace ZoFo.GameCore.GameManagers.MapManager
|
|||
return JsonSerializer.Deserialize<TileSet>(data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"activeFile": "",
|
||||
"expandedProjectPaths": [
|
||||
],
|
||||
"fileStates": {
|
||||
"TileSets/TileSet 1.tsj": {
|
||||
"scaleInDock": 1,
|
||||
"scaleInEditor": 1
|
||||
}
|
||||
},
|
||||
"openFiles": [
|
||||
],
|
||||
"project": "",
|
||||
"recentFiles": [
|
||||
"TileSets/TileSet 1.tsj"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"automappingRulesFile": "",
|
||||
"commands": [
|
||||
],
|
||||
"compatibilityVersion": 1100,
|
||||
"extensionsPath": "extensions",
|
||||
"folders": [
|
||||
"."
|
||||
],
|
||||
"properties": [
|
||||
],
|
||||
"propertyTypes": [
|
||||
]
|
||||
}
|
|
@ -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": [
|
||||
]
|
||||
}
|
116
ZoFo/GameCore/GameManagers/MapManager/TileMaps/main.tmx
Normal file
116
ZoFo/GameCore/GameManagers/MapManager/TileMaps/main.tmx
Normal file
|
@ -0,0 +1,116 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map version="1.10" tiledversion="1.10.2" orientation="orthogonal" renderorder="right-down" width="30" height="20" tilewidth="16" tileheight="16" infinite="1" nextlayerid="2" nextobjectid="1">
|
||||
<tileset firstgid="1" source="../TileSets/TileSet 1.tsj"/>
|
||||
<layer id="1" name="Слой тайлов 1" width="30" height="20">
|
||||
<data encoding="csv">
|
||||
<chunk x="-16" y="-16" width="16" height="16">
|
||||
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
|
||||
</chunk>
|
||||
<chunk x="0" y="-16" width="16" height="16">
|
||||
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
|
||||
</chunk>
|
||||
<chunk x="16" y="-16" width="16" height="16">
|
||||
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
|
||||
</chunk>
|
||||
<chunk x="-16" y="0" width="16" height="16">
|
||||
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
|
||||
</chunk>
|
||||
<chunk x="0" y="0" width="16" height="16">
|
||||
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
|
||||
</chunk>
|
||||
<chunk x="16" y="0" width="16" height="16">
|
||||
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
|
||||
</chunk>
|
||||
</data>
|
||||
</layer>
|
||||
</map>
|
166
ZoFo/GameCore/GameManagers/MapManager/TileSets/TileSet 1.tsj
Normal file
166
ZoFo/GameCore/GameManagers/MapManager/TileSets/TileSet 1.tsj
Normal file
|
@ -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]
|
||||
}]
|
||||
}]
|
||||
}
|
Loading…
Add table
Reference in a new issue