From 531ffbf531f18b4a572ee1ef4795a696362c1f38 Mon Sep 17 00:00:00 2001 From: BraydonKains Date: Fri, 2 Jul 2021 10:15:46 -0400 Subject: [PATCH] Fix indentation so it looks okay on GitHub --- SeeNoEvil.Tests/SeeNoEvil.Tests.csproj | 19 -- SeeNoEvil.Tests/UnitTest1.cs | 18 -- .../AnimationController/AnimationParser.cs | 12 +- SeeNoEvil/Character/Cat.cs | 2 - SeeNoEvil/Level/Camera.cs | 34 ++-- SeeNoEvil/Level/Level.cs | 82 ++++----- SeeNoEvil/Level/PlayField.cs | 21 +-- SeeNoEvil/SeeNoEvil.cs | 6 +- SeeNoEvil/Tiled/MapLayer.cs | 52 +++--- SeeNoEvil/Tiled/TileSet.cs | 122 +++++++------ SeeNoEvil/Tiled/TiledMap.cs | 168 +++++++++--------- SeeNoEvil/Tiled/TiledModels.cs | 50 +++--- SeeNoEvil/Tiled/TiledParser.cs | 12 +- SeeNoEvil/Tiled/TiledStructs.cs | 46 ++--- 14 files changed, 298 insertions(+), 346 deletions(-) delete mode 100644 SeeNoEvil.Tests/SeeNoEvil.Tests.csproj delete mode 100644 SeeNoEvil.Tests/UnitTest1.cs diff --git a/SeeNoEvil.Tests/SeeNoEvil.Tests.csproj b/SeeNoEvil.Tests/SeeNoEvil.Tests.csproj deleted file mode 100644 index df192d1..0000000 --- a/SeeNoEvil.Tests/SeeNoEvil.Tests.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - netcoreapp3.1 - - false - - - - - - - - - - - - - diff --git a/SeeNoEvil.Tests/UnitTest1.cs b/SeeNoEvil.Tests/UnitTest1.cs deleted file mode 100644 index 6992bbf..0000000 --- a/SeeNoEvil.Tests/UnitTest1.cs +++ /dev/null @@ -1,18 +0,0 @@ -using NUnit.Framework; - -namespace SeeNoEvil.Tests -{ - public class Tests - { - [SetUp] - public void Setup() - { - } - - [Test] - public void Test1() - { - Assert.Pass(); - } - } -} \ No newline at end of file diff --git a/SeeNoEvil/Character/AnimationController/AnimationParser.cs b/SeeNoEvil/Character/AnimationController/AnimationParser.cs index 4b73030..48c127f 100644 --- a/SeeNoEvil/Character/AnimationController/AnimationParser.cs +++ b/SeeNoEvil/Character/AnimationController/AnimationParser.cs @@ -4,12 +4,12 @@ using System.Text.Json; namespace SeeNoEvil.Character { public static class AnimationParser { public static AnimationSetModel ReadAnimationJson(string fileName) { - StreamReader streamReader = File.OpenText(fileName); - string text = streamReader.ReadToEnd(); - var options = new JsonSerializerOptions { - PropertyNameCaseInsensitive = true, - }; - return JsonSerializer.Deserialize(text, options); + StreamReader streamReader = File.OpenText(fileName); + string text = streamReader.ReadToEnd(); + var options = new JsonSerializerOptions { + PropertyNameCaseInsensitive = true, + }; + return JsonSerializer.Deserialize(text, options); } } } \ No newline at end of file diff --git a/SeeNoEvil/Character/Cat.cs b/SeeNoEvil/Character/Cat.cs index e2911c5..2718a88 100644 --- a/SeeNoEvil/Character/Cat.cs +++ b/SeeNoEvil/Character/Cat.cs @@ -1,5 +1,3 @@ -using System; -using System.Collections.Generic; using Microsoft.Xna.Framework; namespace SeeNoEvil.Character { diff --git a/SeeNoEvil/Level/Camera.cs b/SeeNoEvil/Level/Camera.cs index f036219..60f9963 100644 --- a/SeeNoEvil/Level/Camera.cs +++ b/SeeNoEvil/Level/Camera.cs @@ -2,26 +2,26 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; namespace SeeNoEvil.Level { - public class Camera { - public Matrix Transform {get; private set;} - public Viewport Viewport {get; private set;} - public Vector2 Centre {get; set;} + public class Camera { + public Matrix Transform {get; private set;} + public Viewport Viewport {get; private set;} + public Vector2 Centre {get; set;} - private Vector3 TranslationVector => - new Vector3(-Centre.X + (Viewport.Width / 2), - -Centre.Y + (Viewport.Height / 2), - 1); + private Vector3 TranslationVector => + new Vector3(-Centre.X + (Viewport.Width / 2), + -Centre.Y + (Viewport.Height / 2), + 1); - public Camera(Viewport _viewport) { - Viewport = _viewport; - //TODO This is to experiment - Centre = new Vector2(Viewport.Width / 2, Viewport.Height / 2); - } + public Camera(Viewport _viewport) { + Viewport = _viewport; + //TODO This is to experiment + Centre = new Vector2(Viewport.Width / 2, Viewport.Height / 2); + } - //FIXME Don't need velocity anymore? + //FIXME Don't need velocity anymore? public void Update(Vector2 position) { - Centre = position; - Transform = Matrix.CreateTranslation(TranslationVector); - } + Centre = position; + Transform = Matrix.CreateTranslation(TranslationVector); + } } } \ No newline at end of file diff --git a/SeeNoEvil/Level/Level.cs b/SeeNoEvil/Level/Level.cs index 8654cf1..f0dfac6 100644 --- a/SeeNoEvil/Level/Level.cs +++ b/SeeNoEvil/Level/Level.cs @@ -11,52 +11,52 @@ namespace SeeNoEvil.Level { public class TilemapLevel { private readonly string MapName; private TiledMap Map; - private Dictionary TilesetTextures; + private Dictionary TilesetTextures; public TilemapLevel(string tilemapName) { MapName = tilemapName; } public void LoadMap(ContentManager content) { - Map = new TiledMap(TiledParser.ReadMapJson(MapName)); - Map.LoadView(); - Map.LoadObjects(); - TilesetTextures = Map.GetTilesetNames().Aggregate(new Dictionary(), - (textures, contentName) => { - textures.Add(contentName, content.Load(contentName)); - return textures; - }); - } - - private IEnumerable GetTilesetNames() => Map.GetTilesetNames(); - - public Vector2 GetPlayerPosition() { - //FIXME This fuckin sucks - Map.Objects.TryGetValue("Cat", out List catCoords); - ObjectCoordinate catCoord = catCoords.First(); - return new Vector2(catCoord.X, catCoord.Y); - } - - public PlayField GetPlayField() { - Map.View.TryGetValue("Ground", out List ground); - return new PlayField(ground); - } - - public IEnumerable GetGhostCoordinates() { - // FIXME this fuckin sucks too I think? - Map.Objects.TryGetValue("Ghosts", out List ghosts); - return ghosts; - } - - public void Draw(SpriteBatch spriteBatch, string layer) { - List locations; - if(Map.View.TryGetValue(layer, out locations)) - locations.ForEach(tile => { - Texture2D layerTexture; - if(tile.tile.gid > 0 && TilesetTextures.TryGetValue(tile.tile.setName, out layerTexture)) { - spriteBatch.Draw(layerTexture, tile.location, tile.tile.srcRectangle, Color.White); - } - }); - } + Map = new TiledMap(TiledParser.ReadMapJson(MapName)); + Map.LoadView(); + Map.LoadObjects(); + TilesetTextures = Map.GetTilesetNames().Aggregate(new Dictionary(), + (textures, contentName) => { + textures.Add(contentName, content.Load(contentName)); + return textures; + }); + } + + private IEnumerable GetTilesetNames() => Map.GetTilesetNames(); + + public Vector2 GetPlayerPosition() { + //FIXME This fuckin sucks + Map.Objects.TryGetValue("Cat", out List catCoords); + ObjectCoordinate catCoord = catCoords.First(); + return new Vector2(catCoord.X, catCoord.Y); + } + + public PlayField GetPlayField() { + Map.View.TryGetValue("Ground", out List ground); + return new PlayField(ground); + } + + public IEnumerable GetGhostCoordinates() { + // FIXME this fuckin sucks too I think? + Map.Objects.TryGetValue("Ghosts", out List ghosts); + return ghosts; + } + + public void Draw(SpriteBatch spriteBatch, string layer) { + List locations; + if(Map.View.TryGetValue(layer, out locations)) + locations.ForEach(tile => { + Texture2D layerTexture; + if(tile.tile.gid > 0 && TilesetTextures.TryGetValue(tile.tile.setName, out layerTexture)) { + spriteBatch.Draw(layerTexture, tile.location, tile.tile.srcRectangle, Color.White); + } + }); + } } } \ No newline at end of file diff --git a/SeeNoEvil/Level/PlayField.cs b/SeeNoEvil/Level/PlayField.cs index b1951ef..7d7d2a9 100644 --- a/SeeNoEvil/Level/PlayField.cs +++ b/SeeNoEvil/Level/PlayField.cs @@ -1,23 +1,20 @@ -using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using SeeNoEvil.Character; using SeeNoEvil.Tiled; namespace SeeNoEvil.Level { public class PlayField { - private IEnumerable Tiles {get; set;} - - public PlayField(IEnumerable tiles) { - Tiles = tiles; - } + private IEnumerable Tiles {get; set;} + + public PlayField(IEnumerable tiles) { + Tiles = tiles; + } - public bool TryWalk(Vector2 newLocation) => - Tiles.Any(tile => tile.location.Equals(newLocation) && tile.tile.gid != 0); + public bool TryWalk(Vector2 newLocation) => + Tiles.Any(tile => tile.location.Equals(newLocation) && tile.tile.gid != 0); - private bool Between(float pos1, float pos2, float bound) => - (bound - pos1) >= (pos2 - pos1); + private bool Between(float pos1, float pos2, float bound) => + (bound - pos1) >= (pos2 - pos1); } } \ No newline at end of file diff --git a/SeeNoEvil/SeeNoEvil.cs b/SeeNoEvil/SeeNoEvil.cs index e08b000..d434338 100644 --- a/SeeNoEvil/SeeNoEvil.cs +++ b/SeeNoEvil/SeeNoEvil.cs @@ -1,11 +1,7 @@ -using System.Collections.Generic; -using System.Linq; - -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; -using SeeNoEvil.Tiled; using SeeNoEvil.Level; using SeeNoEvil.Character; diff --git a/SeeNoEvil/Tiled/MapLayer.cs b/SeeNoEvil/Tiled/MapLayer.cs index 9b266c3..2d58f64 100644 --- a/SeeNoEvil/Tiled/MapLayer.cs +++ b/SeeNoEvil/Tiled/MapLayer.cs @@ -6,35 +6,35 @@ using SeeNoEvil.Level; namespace SeeNoEvil.Tiled { public class TileLayer { - public string Type {get; private set;} - public string Name {get; private set;} - public readonly List DataCoordinates = new List(); + public string Type {get; private set;} + public string Name {get; private set;} + public readonly List DataCoordinates = new List(); - private int Width; - private int Height; - private List Data; + private int Width; + private int Height; + private List Data; public TileLayer(MapLayerModel model) { - Name = model.Name; - Width = model.Width; - Height = model.Height; - Type = model.Type; - if(model.Type == "tilelayer") { - Data = model.Data.ToList(); - BuildCoordinates(); - } - } + Name = model.Name; + Width = model.Width; + Height = model.Height; + Type = model.Type; + if(model.Type == "tilelayer") { + Data = model.Data.ToList(); + BuildCoordinates(); + } + } - private void BuildCoordinates() { - int row = 0; - int column = 0; - Data.ForEach(gid => { - DataCoordinates.Add(new DataCoordinate(column, row, gid)); - if(column == Width-1) { - row++; - column = 0; - } else column++; - }); - } + private void BuildCoordinates() { + int row = 0; + int column = 0; + Data.ForEach(gid => { + DataCoordinates.Add(new DataCoordinate(column, row, gid)); + if(column == Width-1) { + row++; + column = 0; + } else column++; + }); + } } } diff --git a/SeeNoEvil/Tiled/TileSet.cs b/SeeNoEvil/Tiled/TileSet.cs index 37b544d..337ee7f 100644 --- a/SeeNoEvil/Tiled/TileSet.cs +++ b/SeeNoEvil/Tiled/TileSet.cs @@ -3,77 +3,75 @@ using Microsoft.Xna.Framework; namespace SeeNoEvil.Tiled { public class TileSet { - private string Image {get; set;} - private string Name {get; set;} - private int ImageHeight {get; set;} - private int ImageWidth {get; set;} - private int TileHeight {get; set;} - private int TileWidth {get; set;} - private int Spacing {get; set;} - private int Columns {get; set;} - private int FirstGid {get; set;} - private int TileCount {get; set;} - private Dictionary Tiles {get; set;} - private bool TilesLoaded {get; set;} + private string Name {get; set;} + private int ImageHeight {get; set;} + private int ImageWidth {get; set;} + private int TileHeight {get; set;} + private int TileWidth {get; set;} + private int Spacing {get; set;} + private int Columns {get; set;} + private int FirstGid {get; set;} + private int TileCount {get; set;} + private Dictionary Tiles {get; set;} + private bool TilesLoaded {get; set;} - public TileSet(TileSetModel model) { - Image = model.Image; - Name = model.Name; - ImageHeight = model.ImageHeight; - ImageWidth = model.ImageWidth; - TileHeight = model.TileHeight; - TileWidth = model.TileWidth; - Spacing = model.Spacing; - Columns = model.Columns; - FirstGid = model.FirstGid; - TileCount = model.TileCount; - Tiles = new Dictionary(); - TilesLoaded = false; - } + public TileSet(TileSetModel model) { + Image = model.Image; + Name = model.Name; + ImageHeight = model.ImageHeight; + ImageWidth = model.ImageWidth; + TileHeight = model.TileHeight; + TileWidth = model.TileWidth; + Spacing = model.Spacing; + Columns = model.Columns; + FirstGid = model.FirstGid; + TileCount = model.TileCount; + Tiles = new Dictionary(); + TilesLoaded = false; + } public bool ContainsTile(uint gid) => - !(gid < FirstGid || - gid > (FirstGid + TileCount - 1)); + !(gid < FirstGid || gid > (FirstGid + TileCount - 1)); - public Tile GetTile(uint gid) { - if(!TilesLoaded) LoadTiles(); - Tile result; - Tiles.TryGetValue(gid, out result); - return result; - } + public Tile GetTile(uint gid) { + if(!TilesLoaded) LoadTiles(); + Tile result; + Tiles.TryGetValue(gid, out result); + return result; + } public string GetContentName() { - return Name; - } + return Name; + } - private void LoadTiles() { - Tiles = new Dictionary(); - int row = 0; - int rowPx = 0; - int column = 0; - int columnPx = 0; - for(int i = 0; i < TileCount; i++) { - Rectangle rectangle = new Rectangle( - columnPx, - rowPx, + private void LoadTiles() { + Tiles = new Dictionary(); + int row = 0; + int rowPx = 0; + int column = 0; + int columnPx = 0; + for(int i = 0; i < TileCount; i++) { + Rectangle rectangle = new Rectangle( + columnPx, + rowPx, TileWidth, TileHeight - ); - uint gid = (uint)(i + FirstGid); - Tiles.Add(gid, new Tile(gid, rectangle, Name)); - if(column == Columns-1) { - row++; - rowPx += Spacing + TileHeight; - column = 0; - columnPx = 0; - } else { - column++; - columnPx += Spacing + TileWidth; - } - } + ); + uint gid = (uint)(i + FirstGid); + Tiles.Add(gid, new Tile(gid, rectangle, Name)); + if(column == Columns-1) { + row++; + rowPx += Spacing + TileHeight; + column = 0; + columnPx = 0; + } else { + column++; + columnPx += Spacing + TileWidth; + } + } - TilesLoaded = true; - } - } + TilesLoaded = true; + } + } } diff --git a/SeeNoEvil/Tiled/TiledMap.cs b/SeeNoEvil/Tiled/TiledMap.cs index ea4fbcd..b257c76 100644 --- a/SeeNoEvil/Tiled/TiledMap.cs +++ b/SeeNoEvil/Tiled/TiledMap.cs @@ -5,102 +5,102 @@ using SeeNoEvil.Level; namespace SeeNoEvil.Tiled { public class TiledMap { - public Dictionary> View {get; private set;} - public Dictionary> Objects {get; private set;} + public Dictionary> View {get; private set;} + public Dictionary> Objects {get; private set;} private bool Infinite; private List TileLayers; private List ObjectLayers; - private List TileSets; - private int TileHeight; - private int TileWidth; - private int Rows; - private int Columns; - // TODO Do I really need this? - private Dictionary TileCache; + private List TileSets; + private int TileHeight; + private int TileWidth; + private int Rows; + private int Columns; + // TODO Do I really need this? + private Dictionary TileCache; public TiledMap(TiledModel model) { - Infinite = model.Infinite; - TileLayers = model.Layers.Where(model => model.Type == "tilelayer") - .Select(model => new TileLayer(model)).ToList(); - ObjectLayers = model.Layers.Where(model => model.Type == "objectgroup") - .Select(model => new ObjectLayer(model)).ToList(); - TileSets = model.TileSets.Select(model => new TileSet(model)).ToList(); - TileHeight = model.TileHeight; - TileWidth = model.TileWidth; - Rows = model.Height; - Columns = model.Width; - TileCache = new Dictionary(); - View = new Dictionary>(); - } + Infinite = model.Infinite; + TileLayers = model.Layers.Where(model => model.Type == "tilelayer") + .Select(model => new TileLayer(model)).ToList(); + ObjectLayers = model.Layers.Where(model => model.Type == "objectgroup") + .Select(model => new ObjectLayer(model)).ToList(); + TileSets = model.TileSets.Select(model => new TileSet(model)).ToList(); + TileHeight = model.TileHeight; + TileWidth = model.TileWidth; + Rows = model.Height; + Columns = model.Width; + TileCache = new Dictionary(); + View = new Dictionary>(); + } - public IEnumerable GetTilesetNames() => - TileSets.Select(tileset => tileset.GetContentName()); + public IEnumerable GetTilesetNames() => + TileSets.Select(tileset => tileset.GetContentName()); - // Load Tile Locations for each layer - public void LoadView() { - // Get all tilelayers - Dictionary> layerData = new Dictionary>(); - TileLayers.Where(layer => layer.Type == "tilelayer").ToList() - .ForEach(layer => { - layerData.Add(layer.Name, layer.DataCoordinates); - }); + // Load Tile Locations for each layer + public void LoadView() { + // Get all tilelayers + Dictionary> layerData = new Dictionary>(); + TileLayers.Where(layer => layer.Type == "tilelayer").ToList() + .ForEach(layer => { + layerData.Add(layer.Name, layer.DataCoordinates); + }); - // Get all required unique gids and load to cache - LoadTiles(layerData.Aggregate(new HashSet(), - (tiles, layer) => { - foreach(var tile in layer.Value) { - tiles.Add(tile.gid); - } - return tiles; - }) - ); + // Get all required unique gids and load to cache + LoadTiles(layerData.Aggregate(new HashSet(), + (tiles, layer) => { + foreach(var tile in layer.Value) { + tiles.Add(tile.gid); + } + return tiles; + }) + ); - // build resulting tile location collection for each layer - View = layerData.Aggregate(new Dictionary>(), - (locations, layer) => { - int column = 0, row = 0, columnPx = 0, rowPx = 0; - var layerLocations = new List(); - layer.Value.ForEach(coord => { - Tile currTile = new Tile(); - if(coord.gid > 0) - TileCache.TryGetValue(coord.gid, out currTile); - Vector2 pxLocation = new Vector2(columnPx, rowPx); - layerLocations.Add(new TileLocation(currTile, pxLocation)); - if(column == (Columns-1)) { - row++; - rowPx += TileHeight; - column = columnPx = 0; - } else { - column++; - columnPx += TileWidth; - } - }); - locations.Add(layer.Key, layerLocations); - return locations; - }); - } + // build resulting tile location collection for each layer + View = layerData.Aggregate(new Dictionary>(), + (locations, layer) => { + int column = 0, row = 0, columnPx = 0, rowPx = 0; + var layerLocations = new List(); + layer.Value.ForEach(coord => { + Tile currTile = new Tile(); + if(coord.gid > 0) + TileCache.TryGetValue(coord.gid, out currTile); + Vector2 pxLocation = new Vector2(columnPx, rowPx); + layerLocations.Add(new TileLocation(currTile, pxLocation)); + if(column == (Columns-1)) { + row++; + rowPx += TileHeight; + column = columnPx = 0; + } else { + column++; + columnPx += TileWidth; + } + }); + locations.Add(layer.Key, layerLocations); + return locations; + }); + } - // Load objects on the level - public void LoadObjects() { - Objects = ObjectLayers.Aggregate(new Dictionary>(), - // FIXME This is stupid naming - (layers, objects) => { - layers.Add(objects.Name, objects.Objects.ToList()); - return layers; - } - ); - } + // Load objects on the level + public void LoadObjects() { + Objects = ObjectLayers.Aggregate(new Dictionary>(), + // FIXME This is stupid naming + (layers, objects) => { + layers.Add(objects.Name, objects.Objects.ToList()); + return layers; + } + ); + } - // Load tiles into cache if they don't exist + // Load tiles into cache if they don't exist private void LoadTiles(HashSet tiles) { - foreach(uint gid in tiles) { - if(!TileCache.ContainsKey(gid)) { - TileSet tileset = TileSets.FirstOrDefault(set => set.ContainsTile(gid)); - Tile tile = tileset == null ? new Tile() : tileset.GetTile(gid); - TileCache.Add(gid, tile); - } - } - } + foreach(uint gid in tiles) { + if(!TileCache.ContainsKey(gid)) { + TileSet tileset = TileSets.FirstOrDefault(set => set.ContainsTile(gid)); + Tile tile = tileset == null ? new Tile() : tileset.GetTile(gid); + TileCache.Add(gid, tile); + } + } + } } } diff --git a/SeeNoEvil/Tiled/TiledModels.cs b/SeeNoEvil/Tiled/TiledModels.cs index 2e23eee..bc860f2 100644 --- a/SeeNoEvil/Tiled/TiledModels.cs +++ b/SeeNoEvil/Tiled/TiledModels.cs @@ -4,38 +4,38 @@ namespace SeeNoEvil.Tiled { public struct TiledModel { public bool Infinite {get; set;} public IEnumerable Layers {get; set;} - public IEnumerable TileSets {get; set;} - public int TileHeight {get; set;} - public int TileWidth {get; set;} - public int Height {get; set;} - public int Width {get; set;} + public IEnumerable TileSets {get; set;} + public int TileHeight {get; set;} + public int TileWidth {get; set;} + public int Height {get; set;} + public int Width {get; set;} } - public struct TileSetModel { + public struct TileSetModel { public string Image {get; set;} - public string Name {get; set;} - public int ImageHeight {get; set;} - public int ImageWidth {get; set;} - public int TileHeight {get; set;} - public int TileWidth {get; set;} - public int Spacing {get; set;} - public int Columns {get; set;} - public int FirstGid {get; set;} - public int TileCount {get; set;} + public string Name {get; set;} + public int ImageHeight {get; set;} + public int ImageWidth {get; set;} + public int TileHeight {get; set;} + public int TileWidth {get; set;} + public int Spacing {get; set;} + public int Columns {get; set;} + public int FirstGid {get; set;} + public int TileCount {get; set;} } - public struct MapLayerModel { - public string Name {get; set;} - public int Width {get; set;} - public int Height {get; set;} - public IEnumerable Data {get; set;} - public string Type {get; set;} - public IEnumerable Objects {get; set;} + public struct MapLayerModel { + public string Name {get; set;} + public int Width {get; set;} + public int Height {get; set;} + public IEnumerable Data {get; set;} + public string Type {get; set;} + public IEnumerable Objects {get; set;} } public struct TiledObjectModel { - public int Id {get; set;} - public float X {get; set;} - public float Y {get; set;} + public int Id {get; set;} + public float X {get; set;} + public float Y {get; set;} } } \ No newline at end of file diff --git a/SeeNoEvil/Tiled/TiledParser.cs b/SeeNoEvil/Tiled/TiledParser.cs index 33ed079..0d4b1d8 100644 --- a/SeeNoEvil/Tiled/TiledParser.cs +++ b/SeeNoEvil/Tiled/TiledParser.cs @@ -4,12 +4,12 @@ using System.Text.Json; namespace SeeNoEvil.Tiled { public static class TiledParser { public static TiledModel ReadMapJson(string fileName) { - StreamReader streamReader = File.OpenText(fileName); - string text = streamReader.ReadToEnd(); - var options = new JsonSerializerOptions { - PropertyNameCaseInsensitive = true, - }; - return JsonSerializer.Deserialize(text, options); + StreamReader streamReader = File.OpenText(fileName); + string text = streamReader.ReadToEnd(); + var options = new JsonSerializerOptions { + PropertyNameCaseInsensitive = true, + }; + return JsonSerializer.Deserialize(text, options); } } } \ No newline at end of file diff --git a/SeeNoEvil/Tiled/TiledStructs.cs b/SeeNoEvil/Tiled/TiledStructs.cs index 0337b17..d776a0f 100644 --- a/SeeNoEvil/Tiled/TiledStructs.cs +++ b/SeeNoEvil/Tiled/TiledStructs.cs @@ -1,36 +1,36 @@ using Microsoft.Xna.Framework; namespace SeeNoEvil.Tiled { - public struct Tile { - public Tile(long _gid, Rectangle _srcRectangle, string _setName) { - gid = (uint)_gid; - srcRectangle = _srcRectangle; - setName = _setName; - } - public uint gid; - public Rectangle srcRectangle; - public string setName; - } + public struct Tile { + public Tile(long _gid, Rectangle _srcRectangle, string _setName) { + gid = (uint)_gid; + srcRectangle = _srcRectangle; + setName = _setName; + } + public uint gid; + public Rectangle srcRectangle; + public string setName; + } - public struct TileLocation { + public struct TileLocation { public TileLocation(Tile tile, Vector2 location) { this.tile = tile; this.location = location; } - public Tile tile; - public Vector2 location; + public Tile tile; + public Vector2 location; } - public struct DataCoordinate { - public DataCoordinate(int _x, int _y, uint _gid) { - x = _x; - y = _y; - gid = _gid; - } + public struct DataCoordinate { + public DataCoordinate(int _x, int _y, uint _gid) { + x = _x; + y = _y; + gid = _gid; + } - public int x; - public int y; - public uint gid; - } + public int x; + public int y; + public uint gid; + } } \ No newline at end of file