Ejemplo n.º 1
0
        public TileCompiler()
        {
            string tileNameFilePath = Path.Combine(Program.InputDirectory.FullName, Program.TileNameOutputFileName);

            TileNameFile = new FileInfo(tileNameFilePath);
            if (TileNameFile.Exists)
            {
                try
                {
                    TileNameFile.Delete();
                }
                catch (Exception ex)
                {
                    throw new Exception(string.Format("Error deleting TileNameFile '{0}'.", TileNameFile.FullName), ex);
                }
            }

            try
            {
                TileNameWriter = new StreamWriter(new FileStream(TileNameFile.FullName, FileMode.CreateNew, FileAccess.Write, FileShare.None));
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("Unable to create StreamWriter for file '{0}'.", TileNameFile.FullName), ex);
            }

            MonsterCompiler             = new MonsterCompiler(TileNameWriter);
            ObjectCompiler              = new ObjectCompiler(TileNameWriter);
            ArtifactCompiler            = new ArtifactCompiler(TileNameWriter);
            CmapCompiler                = new CmapCompiler(TileNameWriter);
            CmapVariationCompiler       = new CmapVariationCompiler(TileNameWriter);
            MiscCompiler                = new MiscCompiler(TileNameWriter);
            PlayerCompiler              = new PlayerCompiler(TileNameWriter);
            UICompiler                  = new UICompiler(TileNameWriter);
            AnimationCompiler           = new AnimationCompiler(TileNameWriter);
            EnlargementCompiler         = new EnlargementCompiler(TileNameWriter);
            ReplacementCompiler         = new ReplacementCompiler(TileNameWriter);
            BrokenCmapCompiler          = new BrokenCmapCompiler(TileNameWriter);
            BrokenCmapVariationCompiler = new BrokenCmapVariationCompiler(TileNameWriter);

            string manifestPath = Path.Combine(BaseDirectory.FullName, _manifestFile);

            Manifest = new FileInfo(manifestPath);

            if (!BaseDirectory.Exists)
            {
                throw new Exception(string.Format("Base Directory '{0}' does not exist.", BaseDirectory.FullName));
            }

            if (!Manifest.Exists)
            {
                throw new Exception(string.Format("Manifest File '{0}' not found.", Manifest.FullName));
            }
        }
Ejemplo n.º 2
0
        public void Compile()
        {
            using (var stream = Manifest.OpenText())
            {
                string line = null;
                while ((line = stream.ReadLine()) != null)
                {
                    var splitLine = line.Split(',');
                    var tileType  = splitLine[0];

                    if (tileType == _tileType_monster)
                    {
                        MonsterCompiler.CompileOne(splitLine);
                    }
                    else if (tileType == _tileType_object)
                    {
                        ObjectCompiler.CompileOne(splitLine);
                    }
                    else if (tileType == _tileType_artifact)
                    {
                        ArtifactCompiler.CompileOne(splitLine);
                    }
                    else if (tileType == _tileType_cmap)
                    {
                        CmapCompiler.CompileOne(splitLine);
                    }
                    else if (tileType == _tileType_misc)
                    {
                        MiscCompiler.CompileOne(splitLine);
                    }
                    else if (tileType == _tileType_player)
                    {
                        PlayerCompiler.CompileOne(splitLine);
                    }
                    else if (tileType == _tileType_cmap_variation)
                    {
                        CmapVariationCompiler.CompileOne(splitLine);
                    }
                    else if (tileType == _tileType_UI)
                    {
                        UICompiler.CompileOne(splitLine);
                    }
                    else if (tileType == _tileType_animation)
                    {
                        AnimationCompiler.CompileOne(splitLine);
                    }
                    else if (tileType == _tileType_enlargement)
                    {
                        EnlargementCompiler.CompileOne(splitLine);
                    }
                    else if (tileType == _tileType_replacement)
                    {
                        ReplacementCompiler.CompileOne(splitLine);
                    }
                    else if (tileType == _tileType_broken_cmap)
                    {
                        BrokenCmapCompiler.CompileOne(splitLine);
                    }
                    else if (tileType == _tileType_broken_cmap_variation)
                    {
                        BrokenCmapVariationCompiler.CompileOne(splitLine);
                    }
                    else
                    {
                        throw new Exception(string.Format("Unknown tile type '{0}' in line '{1}'.", tileType, line));
                    }
                }

                // Close Manifest Steram
                stream.Close();
            }
        }