Example #1
0
        public LevelRulesEditor(FileManager fileManager, PackFileEntry fileEntry)
        {
            InitializeComponent();
            DoubleBuffered = true;

            _fileManager = fileManager;
            byte[] fileBytes = fileManager.GetFileBytes(fileEntry);
            _levelRules = new LevelRulesFile(fileEntry.Path, null);
            _levelRules.ParseFileBytes(fileBytes);

            foreach (LevelRulesFile.LevelRule levelRule in _levelRules.LevelRules)
            {
                if (levelRule.StaticRooms != null)
                {
                    _LoadRooms(levelRule.StaticRooms, fileEntry.Path);
                }
                else
                {
                    foreach (LevelRulesFile.Room[] levelRules in levelRule.Rules)
                    {
                        _LoadRooms(levelRules, fileEntry.Path);
                    }
                }
            }
        }
Example #2
0
        // really should make a base for .drl and .rom
        public static void CookLevelRulesFiles(IEnumerable <String> levelRulesFiles)
        {
            Console.WriteLine("Processing level rules...");
            foreach (String filePath in levelRulesFiles)
            {
                try
                {
                    XmlDocument xmlDocument = new XmlDocument();
                    xmlDocument.Load(filePath);

                    LevelRulesFile levelRulesFile = new LevelRulesFile(filePath, null);
                    levelRulesFile.ParseXmlDocument(xmlDocument);
                    byte[] fileBytes = levelRulesFile.ToByteArray();

                    File.WriteAllBytes(filePath.Replace(LevelRulesFile.ExtensionDeserialised, LevelRulesFile.Extension), fileBytes);
                }
                catch (Exception e)
                {
                    ExceptionLogger.LogException(e);
                    Console.WriteLine(String.Format("Error: Failed to serialize file {0}", filePath));
                }
            }
        }