public int AddSeg(int layer, int index) { // 64 is the max size of mapSegment array. 3 Layers with 64 segments per map for (int i = 0; i < 64; i++) { if (mapSegment[layer, i] == null) { mapSegment[layer, i] = new MapSegment(); mapSegment[layer, i].Index = index; return i; } } return -1; }
public void Read() { BinaryReader file = new BinaryReader(File.Open(path, FileMode.Open)); // read ledge information first 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].isHardLedge = file.ReadInt32(); } // read layer / segment information for (int l = 0; l < 3; l++) { for (int i = 0; i < 64; i++) { int t = file.ReadInt32(); if (t == -1) mapSegment[l, i] = null; else { mapSegment[l, i] = new MapSegment(); mapSegment[l, i].Index = t; mapSegment[l, i].location = new Vector2( file.ReadSingle(), file.ReadSingle()); } } } // read collision grid information for (int x = 0; x < 20; x++) { for (int y = 0; y < 20; y++) { colisionGrid[x, y] = file.ReadInt32(); } } // read script information for (int i = 0; i < Scripts.Length; i++) Scripts[i] = file.ReadString(); file.Close(); }