начал делать загрузку карты
This commit is contained in:
parent
a24415bab7
commit
24332f240b
3 changed files with 38 additions and 5 deletions
|
@ -11,6 +11,6 @@ namespace ZoFo.GameCore.GameManagers.MapManager.MapElements
|
|||
public bool Infinite { get; set; }
|
||||
public int TileHeight { get; set; }
|
||||
public int TileWidth { get; set; }
|
||||
public List<TileSet> TileSets { get; set; }
|
||||
public List<TileSetInfo> TileSets { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -8,5 +9,15 @@ namespace ZoFo.GameCore.GameManagers.MapManager.MapElements
|
|||
{
|
||||
public class TileSet
|
||||
{
|
||||
public string Image { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int ImageHeight { get; set; }
|
||||
public int ImageWidth { get; set; }
|
||||
public int Margin { get; set; }
|
||||
public int Spacing { get; set; }
|
||||
public int TileCount { get; set; }
|
||||
public int TileHeight { get; set; }
|
||||
public int TileWidth { get; set; }
|
||||
public int Columns { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,42 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using ZoFo.GameCore.GameManagers.MapManager.MapElements;
|
||||
|
||||
namespace ZoFo.GameCore.GameManagers.MapManager
|
||||
{
|
||||
public class MapManager
|
||||
{
|
||||
public void LoadMap()
|
||||
{
|
||||
private static readonly string _path = "/{0}.tmj";
|
||||
private List<TileSet> _tileSets = new List<TileSet>();
|
||||
|
||||
public void LoadMap(string mapName = "main")
|
||||
{
|
||||
TileMap tileMap;
|
||||
using (StreamReader reader = new StreamReader(string.Format(_path, mapName)))
|
||||
{
|
||||
string data = reader.ReadToEnd();
|
||||
tileMap = JsonSerializer.Deserialize<TileMap>(data);
|
||||
}
|
||||
private void LoadTileSet()
|
||||
{
|
||||
|
||||
List<TileSet> tileSets = new List<TileSet>();
|
||||
foreach (TileSetInfo tileSetInfo in tileMap.TileSets)
|
||||
{
|
||||
tileSets.Add(LoadTileSet(tileSetInfo.Source));
|
||||
}
|
||||
}
|
||||
|
||||
private TileSet LoadTileSet(string path)
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(path))
|
||||
{
|
||||
string data = reader.ReadToEnd();
|
||||
return JsonSerializer.Deserialize<TileSet>(data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue