本文整理汇总了C#中Map.InsertRoom方法的典型用法代码示例。如果您正苦于以下问题:C# Map.InsertRoom方法的具体用法?C# Map.InsertRoom怎么用?C# Map.InsertRoom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map.InsertRoom方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertToDungeon_DungeonIsRoom_IfMapIsSingleRoom
public void ConvertToDungeon_DungeonIsRoom_IfMapIsSingleRoom()
{
var converter = new MapConverter();
var map = new Map(5, 5);
map.InsertRoom(new Room(5, 5), new Point(0, 0));
var dungeon = converter.ConvertToDungeon(map);
Assert.That(
dungeon.Where(c => c.Location.X != 0
&& c.Location.X != dungeon.Width - 1
&& c.Location.Y != 0
&& c.Location.Y != dungeon.Height - 1),
Has.All.With.Property(nameof(Cell.Type)).EqualTo(XType.Empty));
}
示例2: InsertRoom_ThrowsIfRoomOutsideMap
public void InsertRoom_ThrowsIfRoomOutsideMap(int x, int y, int w, int h)
{
_map = new Map(5, 5);
Assert.That(() => _map.InsertRoom(new Room(w, h), new Point(x, y)),
Throws.TypeOf<ArgumentOutOfRangeException>());
}
示例3: InsertRoom_WithSize1Cell_CellIsCorridorWithDoors
public void InsertRoom_WithSize1Cell_CellIsCorridorWithDoors()
{
var map = new Map(2, 2);
foreach (var cell in map)
{
foreach (var side in cell.Sides.Keys.ToList())
{
cell.Sides[side] = Side.Empty;
}
}
var room = new Room(1, 1);
map.InsertRoom(room, new Point(0, 0));
var mapCellSides = map[0, 0].Sides;
Assert.That(mapCellSides[Dir.W], Is.EqualTo(Side.Wall), "W");
Assert.That(mapCellSides[Dir.E], Is.EqualTo(Side.Door), "E");
Assert.That(mapCellSides[Dir.S], Is.EqualTo(Side.Door), "S");
Assert.That(mapCellSides[Dir.N], Is.EqualTo(Side.Wall), "N");
}
示例4: InsertRoom_AdjacentCellSidesHaveCorrectSides
public void InsertRoom_AdjacentCellSidesHaveCorrectSides()
{
var map = new Map(3, 3);
foreach (var cell in map)
{
foreach (var side in cell.Sides.Keys.ToList())
{
cell.Sides[side] = Side.Empty;
}
}
var room = new Room(2, 2);
map.InsertRoom(room, new Point(0, 0));
Assert.That(map[2, 0].Sides[Dir.W], Is.EqualTo(Side.Door), "[2, 0] W");
Assert.That(map[2, 0].Sides.Where(s => s.Key != Dir.W).Select(s => s.Value),
Has.All.EqualTo(Side.Empty), "[2, 0] *");
Assert.That(map[2, 1].Sides[Dir.W], Is.EqualTo(Side.Door), "[2, 1] W");
Assert.That(map[2, 1].Sides.Where(s => s.Key != Dir.W).Select(s => s.Value),
Has.All.EqualTo(Side.Empty), "[2, 1] *");
Assert.That(map[1, 2].Sides[Dir.N], Is.EqualTo(Side.Door), "[1, 2] N");
Assert.That(map[1, 2].Sides.Where(s => s.Key != Dir.N).Select(s => s.Value),
Has.All.EqualTo(Side.Empty), "[1, 2] *");
Assert.That(map[0, 2].Sides[Dir.N], Is.EqualTo(Side.Door), "[0, 2] N");
Assert.That(map[0, 2].Sides.Where(s => s.Key != Dir.N).Select(s => s.Value),
Has.All.EqualTo(Side.Empty), "[0, 2] *");
var newRoom = new Room(2, 2);
newRoom[0, 1].Sides[Dir.S] = Side.Door;
newRoom[1, 0].Sides[Dir.E] = Side.Door;
newRoom[1, 1].Sides[Dir.S] = Side.Door;
newRoom[1, 1].Sides[Dir.E] = Side.Door;
foreach (var cell in newRoom)
{
Assert.That(cell.Sides, Is.EquivalentTo(map[cell].Sides),
"Failed cell: " + cell.Location);
}
}