Esempio n. 1
0
        public void Decorate(Floor floor, MapArea area, IGenerator rng)
        {
            MapArea restrictedArea = new MapArea();

            restrictedArea.Add(area.Positions);
            restrictedArea.Remove(area.Bounds.PerimeterPositions());

            Placeable.Place(floor, restrictedArea.RandomPosition(rng), rng);
        }
Esempio n. 2
0
        public void Decorate(Floor floor, MapArea area, IGenerator rng)
        {
            MapArea restrictedArea = new MapArea();

            restrictedArea.Add(area.Positions);
            restrictedArea.Remove(area.Bounds.PerimeterPositions());

            int amount       = Math.Min(rng.Next(MinAmount, MaxAmount + 1), restrictedArea.Count);
            int amountPlaced = 0;

            while (amountPlaced < amount)
            {
                if (Placeable.Place(floor, restrictedArea.RandomPosition(rng), rng))
                {
                    amountPlaced += 1;
                }
            }
        }
Esempio n. 3
0
        public void TestMapAreaRemove()
        {
            var mapArea = new MapArea();

            mapArea.Add(GoRogue.Utility.Yield(Coord.Get(1, 1), Coord.Get(2, 2), Coord.Get(3, 2)));

            Assert.AreEqual(3, mapArea.Count);
            Assert.AreEqual(1, mapArea.Bounds.X);
            Assert.AreEqual(1, mapArea.Bounds.Y);
            Assert.AreEqual(3, mapArea.Bounds.MaxExtentX);
            Assert.AreEqual(2, mapArea.Bounds.MaxExtentY);

            mapArea.Remove(Coord.Get(3, 2));

            Assert.AreEqual(2, mapArea.Count);
            Assert.AreEqual(1, mapArea.Bounds.X);
            Assert.AreEqual(1, mapArea.Bounds.Y);
            Assert.AreEqual(2, mapArea.Bounds.MaxExtentX);
            Assert.AreEqual(2, mapArea.Bounds.MaxExtentY);
        }