Beispiel #1
0
        public bool ReadEncounters(Location location)
        {
            if (_root == null)
            {
                return(false);
            }

            XmlElement node = _root["Encounters"];

            if (node == null)
            {
                return(false);
            }

            if (!node.GetBoolean("IsExists"))
            {
                return(true);
            }

            ushort[] enemyIds = new ushort[node.ChildNodes.Count];
            for (int i = 0; i < enemyIds.Length; i++)
            {
                enemyIds[i] = ((XmlElement)node.ChildNodes[i]).GetUInt16("Id");
            }
            byte frequency = node.GetByte("Frequency");

            Encounters result = new Encounters(enemyIds, frequency);

            location.Encounters = result;

            location.SaveRequest &= ~LocationProperty.Encounters;
            location.Importable  |= LocationProperty.Encounters;
            return(true);
        }
Beispiel #2
0
        public bool ReadEncounters(Location location)
        {
            ArchiveFileEntry mrtEntry = (ArchiveFileEntry)_locationDirectory.Childs.TryGetValue(_name + ".mrt");
            ArchiveFileEntry ratEntry = (ArchiveFileEntry)_locationDirectory.Childs.TryGetValue(_name + ".rat");

            if (mrtEntry == null || ratEntry == null)
            {
                return(true);
            }

            using (MrtFileReader mrtReader = new MrtFileReader(mrtEntry.OpenReadableContentStream()))
                using (RatFileReader ratReader = new RatFileReader(ratEntry.OpenReadableContentStream()))
                {
                    Encounters result = new Encounters(mrtReader.Troops, (byte)(ratReader.Rates & 0xFF));
                    location.Encounters = result;
                }

            location.SaveRequest &= ~LocationProperty.Encounters;
            location.Importable  &= ~LocationProperty.Encounters;
            return(true);
        }
Beispiel #3
0
        public void WriteEncounters(Encounters encounters)
        {
            XmlElement node = _root.EnsureChildElement("Encounters");

            node.RemoveAll();

            bool isExists = encounters != null;

            node.SetBoolean("IsExists", isExists);

            if (!isExists)
            {
                return;
            }

            node.SetByte("Frequency", encounters.Frequency);

            foreach (ushort enemyId in encounters.EnemiesID)
            {
                node.CreateChildElement("Enemy").SetUInt16("Id", enemyId);
            }
        }
Beispiel #4
0
 public void WriteEncounters(Encounters encounters)
 {
     throw new NotImplementedException();
 }