Exemplo n.º 1
0
        static void PrintCSV()
        {
            using (StreamWriter sw = File.CreateText("C:\\Program Files (x86)\\Steam\\steamapps\\common\\theendisnigh\\data\\map.csv"))
            {
                for (int i = 0; i < MAP_HEIGHT; i++)
                {
                    for (int j = 0; j < MAP_WIDTH; j++)
                    {
                        if (Map[i, j] != null)
                        {
                            string name = RNG.GetUInt32().ToString();

                            if (Map[i, j].Name == "start")
                            {
                                name = "start";
                            }

                            var file = LevelManip.Load($"tools/map testing/maptest/{Map[i, j].Name}.lvl");
                            LevelManip.Save(file, $"C:\\Program Files (x86)\\Steam\\steamapps\\common\\theendisnigh\\tilemaps\\{name}.lvl");

                            sw.Write($"{name}.lvl,");
                        }
                        else
                        {
                            sw.Write("a.lvl,");
                        }
                    }
                    sw.Write('\n');
                }
            }
        }
        private void LevelGenTestButton_Click(object sender, RoutedEventArgs e)
        {
            LevelGenerator.LoadPieces(this);
            //RNG.SeedMe(0);

            for (int i = 0; i < 40; i++)
            {
                LevelManip.Save(LevelGenerator.CreateLevel(), /*$"C:\\Program Files (x86)\\Steam\\steamapps\\common\\theendisnigh\\tilemaps/1-{i}.lvl"*/ $"{RSettings.ToolsOutDirectory}/1-{i}.lvl");
            }

            MessageBox.Show($"level gen test complete", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
        }
 private void FlipLevelsH_Click(object sender, RoutedEventArgs e)
 {
     foreach (var file in Directory.GetFiles(RSettings.ToolsInDirectory, "*.lvl", SearchOption.TopDirectoryOnly))
     {
         var    level    = LevelManip.Load(file);
         string filename = Path.GetFileName(file);
         LevelManip.FlipLevelH(ref level);
         string savepath = RSettings.ToolsOutDirectory + filename;
         LevelManip.Save(level, savepath);
     }
     MessageBox.Show($"Successfully Flipped Levels", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
 }
Exemplo n.º 4
0
        public static PiecePool LoadPiecePool(string fileName, string folder)
        {
            PiecePool pool = new PiecePool();

            pool.Name = fileName;
            //pool.Folder = folder;
            pool.Pieces = new List <LevelPiece>();

            var doc = XDocument.Load($"data/piecepools/{pool.Name}.xml");    // open levelpool file

            pool.Active = Convert.ToBoolean(doc.Root.Attribute("enabled").Value == "True");
            pool.Order  = Convert.ToInt16(doc.Root.Attribute("order").Value);
            pool.Author = (doc.Root.Attribute("author").Value);
            pool.Source = doc.Root.Attribute("source").Value;
            foreach (var element in doc.Root.Elements())
            {
                if (element.Name == "piece")
                {
                    var piece = new LevelPiece {
                    };
                    piece.Name      = element.Attribute("name").Value;
                    piece.Folder    = pool.Name;
                    piece.File      = LevelManip.Load($"data/levelpieces/{piece.Folder}/{piece.Name}.lvl");
                    piece.CeilingEn = Convert.ToBoolean(element.Attribute("ceilingEn").Value);
                    piece.CeilingEx = Convert.ToBoolean(element.Attribute("ceilingEx").Value);
                    piece.FloorEn   = Convert.ToBoolean(element.Attribute("floorEn").Value);
                    piece.FloorEx   = Convert.ToBoolean(element.Attribute("floorEx").Value);

                    if (element.Attribute("marginTop") != null)
                    {
                        piece.Margin.Top = Convert.ToInt32(element.Attribute("marginTop").Value);
                    }
                    if (element.Attribute("marginBottom") != null)
                    {
                        piece.Margin.Bottom = Convert.ToInt32(element.Attribute("marginTop").Value);
                    }

                    pool.Pieces.Add(piece);
                }
            }
            pool.NumPieces = pool.Pieces.Count.ToString() + " pieces";
            return(pool);
        }
        private void ColorLevelsAndDecorateMachine_Click(object sender, RoutedEventArgs e)
        {
            //var level1 = LevelManip.Load("C:\\Users\\Noah\\Documents\\GitHub\\TEiN-Randomizer\\EndModLoader\\bin\\Debug\\tools\\input\\_BGTILES.lvl");
            //CSV.LevelToCSV(ref level1, RSettings.ToolsOutDirectory + "level.csv");
            //CSV.RotateCSV("oldmap.csv");

            foreach (var file in Directory.GetFiles(RSettings.ToolsInDirectory, "*.lvl", SearchOption.TopDirectoryOnly))
            {
                var    level    = LevelManip.Load(file);
                string filename = Path.GetFileName(file);

                LevelCorruptors.ReplaceColorTiles(ref level);
                AutoDecorator.DecorateMachine(ref level);

                string savepath = RSettings.ToolsOutDirectory + filename;
                LevelManip.Save(level, savepath);
            }

            MessageBox.Show($"Successfully De-Colored Levels", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
        }
Exemplo n.º 6
0
        static void TileMaps()
        {
            string[] baseLevels = { "1-1", "1-1x", "v-connect", "v-start", "v-end" };
            var      npclevel   = LevelManip.Load($"data/tilemaps/The End is Nigh/v-npc.lvl");

            foreach (var level in baseLevels)
            {
                //File.Copy($"data/vtilemaps/The End is Nigh/{level}.lvl", saveDir + $"tilemaps/{level}.lvl", true);
                var levelFile = LevelManip.Load($"data/tilemaps/The End is Nigh/{level}.lvl");

                if (settings.MirrorMode)
                {
                    LevelManip.FlipLevelH(ref levelFile);
                }

                LevelManip.Save(levelFile, saveDir + $"tilemaps/{level}.lvl");
            }

            for (int j = 0; j < settings.NumAreas; j++)
            {
                for (int i = 0; i < settings.NumLevels; i++)
                {
                    var level     = ChosenLevels[j][i];
                    var levelFile = LevelManip.Load($"data/tilemaps/{level.Folder}/{level.Name}.lvl");

                    if (/*level.CanReverse && RNG.CoinFlip() ||*/ settings.MirrorMode)
                    {
                        LevelManip.FlipLevelH(ref levelFile);
                    }

                    if (settings.DoCorruptions)
                    {
                        level.TSNeed += LevelCorruptors.CorruptLevel(ref levelFile);
                    }

                    LevelManip.Save(levelFile, saveDir + $"tilemaps/v{j + 1}-{i + 1}.lvl");
                }
                LevelManip.Save(npclevel, saveDir + $"tilemaps/v-npc{j + 1}.lvl");
            }
        }
        private void RotateLevels_Click(object sender, RoutedEventArgs e)
        {
            //var level1 = LevelManip.Load("C:\\Users\\Noah\\Documents\\GitHub\\TEiN-Randomizer\\EndModLoader\\bin\\Debug\\tools\\input\\_BGTILES.lvl");
            //CSV.LevelToCSV(ref level1, RSettings.ToolsOutDirectory + "level.csv");
            //CSV.RotateCSV("oldmap.csv");

            foreach (var file in Directory.GetFiles(RSettings.ToolsInDirectory, "*.lvl", SearchOption.TopDirectoryOnly))
            {
                var    level    = LevelManip.Load(file);
                string filename = Path.GetFileName(file);

                int loop = Convert.ToInt32(((MenuItem)sender).Tag);
                for (int i = 0; i < loop; i++)
                {
                    level = LevelManip.RotateLevel(ref level);
                }
                level = LevelManip.FixAspect(ref level);

                string savepath = RSettings.ToolsOutDirectory + filename;
                LevelManip.Save(level, savepath);
            }

            MessageBox.Show($"Successfully Rotated Levels", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
        }
Exemplo n.º 8
0
        public static void RandomizeMod(MainWindow mw)
        {
            //ShadersList = mw.ShadersList;

            saveDir = settings.GameDirectory;

            PrepModFolders();

            // level corruptions
            string dir = $"{saveDir}tilemaps";

            if (Directory.Exists(dir))
            {
                string[] paths = Directory.GetFiles(dir);
                foreach (var file in paths)
                {
                    LevelFile level = LevelManip.Load(file);
                    //if(settings.MirrorMode)
                    //{
                    //    LevelManip.FlipLevelH(ref level);
                    //    FlipCSV(saveDir + "data/map.csv");
                    //}
                    if (settings.DoCorruptions)
                    {
                        LevelCorruptors.CorruptLevel(ref level);
                    }
                    LevelManip.Save(level, file);
                }
            }

            // data folder
            dir = $"{saveDir}data";
            if (Directory.Exists(dir))
            {
                // tilesets.txt
                var file = $"{dir}/tilesets.txt";
                if (File.Exists(file))
                {
                    string[] text = File.ReadAllLines(file);
                    for (int i = 0; i < text.Length; i++)
                    {
                        if (text[i].Contains("palette"))
                        {
                            text[i] = TilesetManip.GetPalette();
                        }
                        if (text[i].Contains("tile_graphics"))
                        {
                            text[i] = TilesetManip.GetTile();
                        }
                        if (text[i].Contains("overlay_graphics"))
                        {
                            text[i] = TilesetManip.GetOverlay();
                        }
                        if (text[i].Contains("global_particle"))
                        {
                            var split = text[i].Trim().Split(Convert.ToChar(" "));
                            text[i] = split[0] + " " + ParticleGenerator.GetParticle(settings);
                        }
                    }
                    File.Delete(file);
                    File.WriteAllLines(file, text);
                }
            }
        }
        private void CreatePiecePools(object sender, RoutedEventArgs e)
        {
            foreach (var folder in Directory.GetDirectories("data/levelpieces"))
            {
                string folderName = Path.GetFileNameWithoutExtension(folder); // get folder name
                if (folderName == "GEN")
                {
                    continue;                      // ignore GEN folder
                }
                XDocument doc  = new XDocument();
                XElement  pool = new XElement("pool");
                pool.SetAttributeValue("enabled", "True");
                pool.SetAttributeValue("source", folderName);
                pool.SetAttributeValue("author", "Uzerro");
                pool.SetAttributeValue("order", "0");

                foreach (var file in Directory.GetFiles(folder, "*.lvl", SearchOption.TopDirectoryOnly))
                {
                    string   fileName = Path.GetFileNameWithoutExtension(file); // get file name
                    XElement piece    = new XElement("piece");
                    piece.SetAttributeValue("name", fileName);
                    // create XElement for piece
                    LevelFile level = LevelManip.Load(file);                // load the associated level file

                    Pair enCoord = LevelGenerator.GetEntryCoord(ref level); // get entry coord
                    Pair exCoord = LevelGenerator.GetExitCoord(ref level);  // get exit coord

                    // check for ceilings and floors
                    piece.SetAttributeValue("ceilingEn", "False");
                    piece.SetAttributeValue("ceilingEx", "False");
                    piece.SetAttributeValue("floorEn", "False");
                    piece.SetAttributeValue("floorEx", "False");

                    int index, lw = level.header.width, lh = level.header.height;

                    if (level.data.active[0] == TileID.Solid)               // checks top left tile for solid block
                    {
                        piece.SetAttributeValue("ceilingEn", "True");
                    }
                    if (level.data.active[lw - 1] == TileID.Solid)          // checks top right tile for solid block
                    {
                        piece.SetAttributeValue("ceilingEx", "True");
                    }

                    index = (enCoord.First + 1) * lw + enCoord.Second;
                    if (index < lh * lw)
                    {
                        if (level.data.active[index] == TileID.Solid)       // checks tile underneath the entrance for solid block
                        {
                            piece.SetAttributeValue("floorEn", "True");
                        }
                    }
                    index = (exCoord.First + 1) * lw + exCoord.Second;
                    if (index < lh * lw)
                    {
                        if (level.data.active[index] == TileID.Solid)       // checks tile underneath the exit for solid block
                        {
                            piece.SetAttributeValue("floorEx", "True");
                        }
                    }

                    // FullHeight, AllowBuildingAbove/Below, Margin will need to be set manually.

                    pool.Add(piece);
                }

                doc.Add(pool);
                doc.Save($"data/piecepools/{folderName}.xml");
            }

            MessageBox.Show($"creating piece pools complete", "Info", MessageBoxButton.OK, MessageBoxImage.Information);
        }