Ejemplo n.º 1
0
 public MapArea()
 {
     areaName   = Randomizer.GetFunnyName();
     numScreens = 0;
     tileset    = new Tileset();
 }
Ejemplo n.º 2
0
        public static Tileset GetTileset(SettingsFile settings, bool isAreaTS)
        {
            Tileset tileset = new Tileset();

            try
            {
                // Select Tileset Info
                if (isAreaTS)
                {
                    //if (settings.DeadRacer) tileset.AreaType = "glitch";
                    if (settings.RandomizeAreaType)
                    {
                        tileset.AreaType = AreaTypes[RNG.random.Next(0, 5)];
                    }
                    else
                    {
                        tileset.AreaType = settings.AreaType;
                    }
                }

                tileset.Tile    = ($"    tile_graphics { TileGraphicsPool[RNG.random.Next(0, TileGraphicsPool.Count())] }\n");
                tileset.Overlay = ($"    overlay_graphics { OverlayGraphicsPool[RNG.random.Next(0, OverlayGraphicsPool.Count())] }\n");
                tileset.Palette = ($"    palette { RNG.random.Next(1, NumPalettes) }\n");
                tileset.Music   = ($"    music { MusicPool[RNG.random.Next(0, MusicPool.Count())] }\n");

                if (RNG.random.Next(0, 2) == 0)  // set shader
                {
                    tileset.Shader = ($"    { ShaderPool[RNG.random.Next(0, ShaderPool.Count())] }\n");
                }
                tileset.Shader += "shader_param " + ((float)RNG.random.Next(0, 101) / 100);

                // set particles
                if (settings.DoParticles)
                {
                    var loop = RNG.random.Next(1, settings.MaxParticleEffects);
                    if (settings.GenerateCustomParticles)
                    {
                        for (int i = 0; i < loop; i++)
                        {
                            tileset.Particles += ("    global_particle_" + (i + 1).ToString() + $" { ParticleGenerator.GetParticle(settings) }\n");
                        }
                    }
                    else
                    {
                        for (int i = 0; i < loop; i++)
                        {
                            tileset.Particles += ("    global_particle_" + (i + 1).ToString() + $" { ParticlePool[RNG.random.Next(0, ParticlePool.Count())] }\n");
                        }
                    }
                }

                // bgsolid for auto-refresh
                //if (settings.AutoRefresh || settings.LevelMerge)
                //    Extras += "background_graphics bgsolid\n";

                if (settings.LevelMerge)
                {
                    tileset.Extras += "global_particle_1 None\nglobal_particle_2 None\nglobal_particle_3 None tile_particle_1 None tile_particle_2 None tile_particle_3 None tile_particle_4 None tile_particle_5 None\n";
                }

                // generate Art Alts
                if (settings.AltLevel != "None")
                {
                    tileset.ArtAlts = GetArtAlts(settings);
                }

                // extras and physics
                if (settings.UseAreaTileset == isAreaTS)
                {
                    if (settings.DoNevermoreTilt && RNG.random.Next(0, 6) == 0 /*!(isAreaTS && !settings.UseAreaTileset)*/)
                    {
                        tileset.DoTilt = ($"    do_tilt true\n");
                    }
                    if (settings.DoExodusWobble && RNG.random.Next(0, 6) == 0 /*!(isAreaTS && !settings.UseAreaTileset)*/)
                    {
                        tileset.DoWobble = ($"    do_wobble true\n");
                    }
                    if (settings.DoPhysics)
                    {
                        if (settings.PlatformPhysics)
                        {
                            tileset.Extras += "    platform_physics " + Physics.PlatformPhysics() + "\n";
                        }
                        if (settings.WaterPhysics)
                        {
                            tileset.Extras += "    water_physics " + Physics.WaterPhysics() + "\n";
                        }
                        if (settings.PlayerPhysics)
                        {
                            tileset.Extras += "    player_physics " + Physics.PlayerPhysics() + "\n";
                        }
                        if (settings.LowGravPhysics)
                        {
                            tileset.Extras += "    lowgrav_physics " + Physics.LowGravPhysics() + "\n";
                        }
                    }
                }

                // create "all", which is just the entire tileset in one string
                tileset.All = $"area_type {tileset.AreaType}\n" + tileset.Tile + "\n" + tileset.Overlay + "\n" + tileset.Particles + "\n" + tileset.Shader + "\n" + tileset.Palette + "\n" + tileset.Music + "\n" + tileset.Extras;
            }
            catch (Exception ex) { MessageBox.Show($"Error creating tileset. Exception {ex}", "Error", MessageBoxButton.OK, MessageBoxImage.Error); throw; }

            return(tileset);
        }