Esempio n. 1
0
        public static MissileData GetData(string data)
        {
            MissileData missileData = new MissileData();

            StringReader reader = new StringReader(data);

            string line = "";
            int lineNumber = 0;

            while ((line = reader.ReadLine()) != null)
            {
                lineNumber++;

                if (line == "[/MISSILES]")
                {
                    break;
                }
                else if (line == "[MISSILE]")
                {
                    missileData.Missiles.Add(ReadMissile(ref reader, ref lineNumber));
                }
            }

            reader.Close();
            reader.Dispose();

            return missileData;
        }
Esempio n. 2
0
        public static string GetString(MissileData missileData)
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendLine("[MISSILES]");

            if (missileData.Missiles.Count > 0)
            {
                foreach (var missile in missileData.Missiles)
                {
                    builder.AppendMissile(missile);
                }
            }

            builder.Append("[/MISSILES]");

            return builder.ToString();
        }
Esempio n. 3
0
 private void WriteMissileDataFile(MissileData missileData)
 {
     _writer.Write((short)missileData.Missiles.Count);
     foreach (var missile in missileData.Missiles)
     {
         WriteMissile(missile);
     }
 }
Esempio n. 4
0
        private MissileData ReadMissileDataFile()
        {
            MissileData rawFile = new MissileData();

            int missileCount = _reader.ReadInt16();
            for (int i = 0; i < missileCount; i++)
            {
                rawFile.Missiles.Add(ReadMissile());
            }

            return rawFile;
        }