Ejemplo n.º 1
0
        protected void MakeSafe(Level level)
        {
            var t = Tiles.RandomFloor();

            Painter.Call(level, this, 1, (x, y) => {
                if (level.Get(x, y).Matches(Tile.SpikeOffTmp, Tile.SensingSpikeTmp, Tile.Chasm, Tile.Lava))
                {
                    level.Set(x, y, t);
                }
            });

            /*if (Run.Depth == Run.ContentEndDepth) {
             *      var om = new OldMan();
             *      level.Area.Add(om);
             *      om.Center = ((GetRandomDoorFreeCell() ?? GetTileCenter()) * 16 + new Dot(8)).ToVector();
             * }*/
        }
Ejemplo n.º 2
0
        public override void Paint(Level level)
        {
            var t = Tiles.RandomFloor();

            Painter.Call(level, this, 1, (x, y) => {
                if (level.Get(x, y).Matches(Tile.SpikeOffTmp, Tile.SensingSpikeTmp))
                {
                    level.Set(x, y, t);
                }
            });

            PaintRoom(level);

            if (LevelSave.BiomeGenerated is LibraryBiome && !BK.Version.Dev)
            {
                return;
            }

            var boss = BossRegistry.Generate();

            if (boss == null)
            {
                if (BK.Version.Dev)
                {
                    return;
                }

                var exit = new Exit();
                level.Area.Add(exit);
                exit.Center = GetCenterVector();

                Log.Error("Failed to generate the boss!");
                return;
            }

            level.Area.Add(boss);
            boss.Center = GetCenterVector();

            /*var trigger = new SpawnTrigger();
             * var w = GetWidth() - 2;
             * var h = GetHeight() - 2;
             * var s = w * h;
             *
             * trigger.Tiles = new byte[s];
             * trigger.Liquid = new byte[s];
             * trigger.RoomX = (ushort) (Left + 1);
             * trigger.RoomY = (ushort) (Top + 1);
             * trigger.RoomWidth = (byte) w;
             * trigger.RoomHeight = (byte) h;
             *
             * for (var y = 0; y < h; y++) {
             *      for (var x = 0; x < w; x++) {
             *              var li = level.ToIndex(Left + 1 + x, Top + 1 + y);
             *              var i = x + y * w;
             *
             *              trigger.Tiles[i] = level.Tiles[li];
             *              trigger.Liquid[i] = level.Liquid[li];
             *      }
             * }
             *
             * Painter.Fill(level, this, 1, Tile.WallA);
             *
             * var c = GetCenterRect();
             * c.Resize(1, 1);
             *
             * Painter.Fill(level, c, -3, Tiles.RandomFloor());
             * PaintTunnel(level, Tile.FloorD, c);
             * Painter.Fill(level, c, -2, Tiles.RandomFloor());
             *
             * var x = (c.Left - 2) * 16;
             * var y = (c.Top - 2) * 16;
             *
             * var ta = new Torch();
             * level.Area.Add(ta);
             * ta.CenterX = x + 8;
             * ta.Bottom = y + 12;
             *
             * ta = new Torch();
             * level.Area.Add(ta);
             * ta.CenterX = x + 4 * 16 + 8;
             * ta.Bottom = y + 12;
             *
             * ta = new Torch();
             * level.Area.Add(ta);
             * ta.CenterX = x + 8;
             * ta.Bottom = y + 4 * 16 + 12;
             *
             * ta = new Torch();
             * level.Area.Add(ta);
             * ta.CenterX = x + 4 * 16 + 8;
             * ta.Bottom = y + 4 * 16 + 12;
             *
             * var st = new BkStand();
             * level.Area.Add(st);
             *
             * st.CenterX = c.Left * 16 + 8;
             * st.CenterY = c.Top * 16 + 8;
             * st.SetItem(Items.CreateAndAdd("bk:the_key", level.Area), null);
             *
             * Painter.Fill(level, c, -2, Tile.FloorD);
             * Painter.Fill(level, c, -1, Tiles.RandomFloor());*/
        }
Ejemplo n.º 3
0
        public override void Paint(Level level)
        {
            if (LevelSave.BiomeGenerated is IceBiome)
            {
                var clip = Painter.Clip;
                Painter.Clip = null;
                Painter.Rect(level, this, 0, Tile.WallB);
                Painter.Clip = clip;
            }

            var scourged = Rnd.Chance(Run.Scourge + 1);

            if (Rnd.Chance(30))
            {
                var t = Tiles.Pick(Tile.FloorC, Tile.FloorD);

                if (Rnd.Chance())
                {
                    Painter.FillEllipse(level, this, 3, t);
                }
                else
                {
                    Painter.Fill(level, this, 3, t);
                }

                if (Rnd.Chance())
                {
                    t = Tiles.Pick(Tile.FloorC, Tile.FloorD);

                    if (Rnd.Chance())
                    {
                        Painter.FillEllipse(level, this, 4, t);
                    }
                    else
                    {
                        Painter.Fill(level, this, 4, t);
                    }
                }
            }

            if (Rnd.Chance())
            {
                if (Rnd.Chance())
                {
                    PaintTunnel(level, Tiles.RandomFloor(), GetCenterRect(), true);
                    PaintTunnel(level, Tiles.RandomNewFloor(), GetCenterRect());
                }
                else
                {
                    PaintTunnel(level, Tiles.RandomNewFloor(), GetCenterRect(), Rnd.Chance());
                }
            }

            if (GameSave.IsTrue("sk_enraged"))
            {
                var rp  = GetCenter();
                var rsk = new ShopKeeper();

                level.Area.Add(rsk);
                rsk.Center = new Vector2(rp.X * 16 + 8, rp.Y * 16 + 16);

                return;
            }

            var stands = ValidateStands(level, GenerateStands());

            if (stands.Count < 4)
            {
                Painter.Fill(level, this, 1, Tile.FloorD);
                Paint(level);
                return;
            }

            if (scourged)
            {
                var f = Tiles.RandomFloor();

                for (var m = Left + 1; m <= Right - 1; m++)
                {
                    for (var j = Top + 1; j <= Bottom - 1; j++)
                    {
                        var t = level.Get(m, j);

                        if (t.IsPassable() && t != f)
                        {
                            level.Set(m, j, Tile.EvilFloor);
                        }
                    }
                }
            }

            var pool           = Items.GeneratePool(Items.GetPool(Run.Type == RunType.BossRush ? ItemPool.BossRush : ItemPool.Shop));
            var consumablePool = Items.GeneratePool(Items.GetPool(ItemPool.ShopConsumable));

            var con = Math.Max(1, Math.Ceiling(stands.Count / 4f));
            var i   = 0;
            var g   = (Run.Depth == 5 && Run.Loop == 0 && LevelSave.GenerateMarket) ? Rnd.Int(stands.Count) : -1;

            foreach (var s in stands)
            {
                var stand = new ShopStand();
                level.Area.Add(stand);
                stand.Center = new Vector2(s.X * 16 + 8, s.Y * 16 + 8);

                var id   = g == i ? "bk:bucket" : Items.GenerateAndRemove(i < con && consumablePool.Count > 0 ? consumablePool : pool, null, true);
                var item = Items.CreateAndAdd(id, level.Area, false);

                if (scourged)
                {
                    item.Scourged = true;
                }

                stand.SetItem(item, null);

                if (pool.Count == 0)
                {
                    break;
                }

                i++;
            }

            var p  = stands[Rnd.Int(stands.Count)];
            var sk = new ShopKeeper();

            level.Area.Add(sk);
            sk.Center = new Vector2(p.X * 16 + 8, p.Y * 16 + 16);

            // Painter.DrawLine(level, new Dot(Left + 1, Top + 1), new Dot(Right - 1, Top + 1), Tiles.RandomFloor());

            var points = new List <Point>();

            for (var x = Left + 2; x < Right - 1; x++)
            {
                var found = false;

                foreach (var c in Connected.Values)
                {
                    if (c.X == x && c.Y == Top)
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    points.Add(new Point(x, Top + 2));
                }
            }

            var props = new List <Entity> {
                new Gramophone()
            };

            if (Rnd.Chance(40 + Run.Luck * 7))
            {
                props.Add(new RerollMachine());
            }

            if (Rnd.Chance(40 + Run.Luck * 7))
            {
                props.Add(new VendingMachine());
            }

            foreach (var prop in props)
            {
                var pl = points[Rnd.Int(points.Count)];
                points.Remove(pl);

                level.Area.Add(prop);
                prop.CenterX = pl.X * 16 + 8 + Rnd.Int(-4, 4);
                prop.Bottom  = pl.Y * 16;

                if (points.Count == 0)
                {
                    break;
                }
            }

            var tt = Tiles.RandomFloor();

            Painter.Call(level, this, 1, (x, y) => {
                if (level.Get(x, y).Matches(Tile.SpikeOffTmp, Tile.SensingSpikeTmp, Tile.Chasm, Tile.Lava))
                {
                    level.Set(x, y, tt);
                }
            });

            var letters = new[] { 'a', 'b', 'c' };
            var spr     = $"mat_{letters[Rnd.Int(letters.Length)]}";

            foreach (var pair in Connected)
            {
                if (pair.Key is SubShopRoom)
                {
                    continue;
                }

                var door = pair.Value;
                var mat  = new SlicedProp(spr, Layers.Entrance);
                level.Area.Add(mat);

                if (door.X == Left)
                {
                    PlaceSign(level, new Vector2(door.X * 16 - 8, door.Y * 16 - 5));
                    mat.Center = new Vector2(door.X * 16 - 8, door.Y * 16 + 8);
                }
                else if (door.X == Right)
                {
                    PlaceSign(level, new Vector2(door.X * 16 + 24, door.Y * 16 - 5));
                    mat.Center = new Vector2(door.X * 16 + 24, door.Y * 16 + 8);
                }
                else if (door.Y == Top)
                {
                    mat.Center = new Vector2(door.X * 16 + 8, door.Y * 16 - 8);
                }
                else
                {
                    mat.Center = new Vector2(door.X * 16 + 8, door.Y * 16 + 24);
                }
            }
        }