Exemplo n.º 1
0
        private void ReadGat()
        {
            using (FileStream s = new FileStream(txtFile.Text, FileMode.Open)) {
                if (s.CanRead == false)
                {
                    MessageBox.Show("Can not read form File Stream?!", "Error!");
                    try { s.Close(); } catch { }
                    return;
                }
                using (BinaryReader bin = new BinaryReader(s)) {
                    s.Position  = 6;                    // 0-6 = Magic Header [GRAT..]
                    mGat        = new GATFile();
                    mGat.Width  = bin.ReadInt32();
                    mGat.Height = bin.ReadInt32();

                    int num_cells = (mGat.Width * mGat.Height);
                    mGat.CellType = new EMapCellType[num_cells];
                    for (int i = 0; i < num_cells; i++)
                    {
                        bin.BaseStream.Position += 4 * 4;
                        mGat.CellType[i]         = EEnum <EMapCellType> .Parse(bin.ReadByte().ToString());

                        bin.BaseStream.Position += 3;                         // 3x unknown Char
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void ReadXml()
        {
            XmlSerializer xml = new XmlSerializer(typeof(GATFile));

            using (StreamReader sr = new StreamReader(txtFile.Text))
                mGat = (GATFile)xml.Deserialize(sr);
        }