コード例 #1
0
ファイル: Map.cs プロジェクト: falc410/RuinExplorers
        /// <summary>
        /// Reads the map from file.
        /// </summary>
        public void Read()
        {
            BinaryReader file = new BinaryReader(File.Open(@"Content/data/maps/" + path + ".zmx", 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() * 2f, file.ReadSingle() *2f);
                }
                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();
                }
            }

            mapScript = new MapScript(this);
            for (int i = 0; i < mapScript.Lines.Length; i++)
            {
                String s = file.ReadString();
                if (s.Length > 0)
                    mapScript.Lines[i] = new MapScriptLine(s);
                else
                    mapScript.Lines[i] = null;
            }

            file.Close();

            // turn off fog by default and start reading MapScript
            // if we find the init tag in the first line we process
            // the rest of the script in the update method
            Bucket = null;
            Water = 0f;
            Fog = -1;

            if (mapScript.GotoTag("init"))
                mapScript.IsReading = true;
        }
コード例 #2
0
ファイル: Map.cs プロジェクト: falc410/RuinExplorers
 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;
 }