public void Load() { var file = new BinaryReader(File.Open(@"data/" + Path + ".zmx", FileMode.Open)); for (int i = 0; i < Ledges.Length; i++) { Ledges[i] = new Ledge(); Ledges[i].TotalNodes = file.ReadInt32(); for (int n = 0; n < Ledges[i].TotalNodes; n++) { Ledges[i].Nodes[n] = new Vector2(file.ReadSingle(), file.ReadSingle()); } Ledges[i].Flags = file.ReadInt32(); } var keyCount = file.ReadInt32(); for (int i = 0; i < keyCount; i++) { var key = file.ReadInt32(); var segmentCount = file.ReadInt32(); if (!MapSegments.ContainsKey(key)) { MapSegments[key] = new List <MapSegment>(); } for (int index = 0; index < segmentCount; index++) { var mapSegment = new MapSegment(); mapSegment.Index = index; mapSegment.Layer = key; mapSegment.Location = new Vector2(file.ReadSingle(), file.ReadSingle()); MapSegments[key].Add(mapSegment); } } for (int x = 0; x < 20; x++) { for (int y = 0; y < 20; y++) { Grid[x, y] = file.ReadInt32(); } } file.Close(); Console.WriteLine("Read"); }
public int AddSegment(int layer, int index) { if (!MapSegments.ContainsKey(layer)) { MapSegments[layer] = new List <MapSegment>(); } var mapSegment = new MapSegment(); mapSegment.Index = index; mapSegment.Layer = layer; MapSegments[layer].Add(mapSegment); return(MapSegments[layer].Count - 1); }
public MoveCommand(MapSegment segment, Vector2 newLocation) { this.segment = segment; oldLocation = newLocation; this.newLocation = segment.Location; }