Browse Source

fix how the first line of World is parsed

GitOrigin-RevId: 9409e491fd
master
Colin McMillen 4 years ago
parent
commit
0ee671c8b1
  1. 15
      Shared/Levels.cs
  2. 4
      Shared/World.cs

15
Shared/Levels.cs

@ -5,14 +5,15 @@
}; };
public const string DEMO = @" public const string DEMO = @"
7 <=============>
6 { { { } { ;
5 } ; ; ; }
4 } ; }
3 }
8 <=============>
7 { { { } { ;
6 } ; ; ; }
5 } ; }
4 }
3
2 2
1 1
0 <=X=X=X=> <=============> (__________)
0 <=X=X=X=> <===> <===> (__________)
5 / \ 5 / \
4 | | 4 | |
3 | | 3 | |
@ -32,6 +33,7 @@ w wr wqw t wew ww dfffxfffxfffb v twq r wtwv
......................................... .........................................
......................................... .........................................
......................................... .........................................
.........................................
......................................... .........................................
0 [................................. 0 [.................................
1 [................................. 1 [.................................
@ -43,6 +45,7 @@ w wr wqw t wew ww dfffxfffxfffb v twq r wtwv
public const string ONE_ONE = @" public const string ONE_ONE = @"

4
Shared/World.cs

@ -15,7 +15,7 @@ namespace SemiColinGames {
} }
} }
private static Dictionary<char, Terrain> mapping = new Dictionary<char, Terrain>();
private readonly static Dictionary<char, Terrain> mapping = new Dictionary<char, Terrain>();
public static Terrain Grass = new Terrain('=', true); public static Terrain Grass = new Terrain('=', true);
public static Terrain GrassL = new Terrain('<', true); public static Terrain GrassL = new Terrain('<', true);
@ -160,7 +160,7 @@ namespace SemiColinGames {
TileFactory factory = new TileFactory(); TileFactory factory = new TileFactory();
var tilesList = new List<Tile>(); var tilesList = new List<Tile>();
var decorationsList = new List<Tile>(); var decorationsList = new List<Tile>();
string[] worldDesc = levelSpecification.Split('\n');
string[] worldDesc = levelSpecification.Substring(1).Split('\n');
tileWidth = worldDesc.AsQueryable().Max(a => a.Length); tileWidth = worldDesc.AsQueryable().Max(a => a.Length);
tileHeight = worldDesc.Length; tileHeight = worldDesc.Length;
Debug.WriteLine("world size: {0}x{1}", tileWidth, tileHeight); Debug.WriteLine("world size: {0}x{1}", tileWidth, tileHeight);

Loading…
Cancel
Save