Created
May 18, 2012 17:05
-
-
Save eriksk/2726443 to your computer and use it in GitHub Desktop.
Oh IO I really love/hate you
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<MapLayer> layers = new List<MapLayer>(); | |
MapSettings settings = new MapSettings(); | |
List<Ledge> ledges = new List<Ledge>(); | |
int[,] grid; | |
using (StreamReader r = new StreamReader(path)) | |
{ | |
settings.gravity = float.Parse(r.ReadLine(), CultureInfo.InvariantCulture); | |
settings.friction = float.Parse(r.ReadLine(), CultureInfo.InvariantCulture); | |
settings.mood = int.Parse(r.ReadLine()); | |
int layerCount = int.Parse(r.ReadLine()); | |
for (int i = 0; i < layerCount; i++) | |
{ | |
float parallax = float.Parse(r.ReadLine(), CultureInfo.InvariantCulture); | |
int partCount = int.Parse(r.ReadLine()); | |
List<MapPart> parts = new List<MapPart>(); | |
for (int j = 0; j < partCount; j++) | |
{ | |
string[] pos = r.ReadLine().Split(','); | |
Vector2 position = new Vector2(float.Parse(pos[0], CultureInfo.InvariantCulture), float.Parse(pos[1], CultureInfo.InvariantCulture)); | |
string[] src = r.ReadLine().Split(','); | |
Rectangle source = new Rectangle(int.Parse(src[0]), int.Parse(src[1]), int.Parse(src[2]), int.Parse(src[3])); | |
float rotation = float.Parse(r.ReadLine(), CultureInfo.InvariantCulture); | |
float scale = float.Parse(r.ReadLine(), CultureInfo.InvariantCulture); | |
parts.Add(new MapPart(position, rotation, scale) { Source = source }); | |
} | |
MapLayer l = new MapLayer(parts, parallax); | |
layers.Add(l); | |
} | |
int ledgeCount = int.Parse(r.ReadLine()); | |
for (int i = 0; i < ledgeCount; i++) | |
{ | |
bool solid = bool.Parse(r.ReadLine()); | |
List<Vector2> points = new List<Vector2>(); | |
int pointCount = int.Parse(r.ReadLine()); | |
for (int j = 0; j < pointCount; j++) | |
{ | |
string[] pos = r.ReadLine().Split(','); | |
Vector2 point = new Vector2(float.Parse(pos[0], CultureInfo.InvariantCulture), float.Parse(pos[1], CultureInfo.InvariantCulture)); | |
points.Add(point); | |
} | |
Ledge l = new Ledge(points, solid); | |
ledges.Add(l); | |
} | |
string[] gridLengths = r.ReadLine().Split(','); | |
int width = int.Parse(gridLengths[0]); | |
int height = int.Parse(gridLengths[1]); | |
grid = new int[width, height]; | |
string[] data = r.ReadLine().Split(','); | |
for (int i = 0; i < width; i++) | |
{ | |
for (int j = 0; j < height; j++) | |
{ | |
grid[i, j] = int.Parse(data[i + j * width]); | |
} | |
} | |
} | |
Map map = new Map(layers, settings, ledges, grid); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment