Beispiel #1
0
    public void TestAdjacentRooms()
    {
        LevelLayout layout = new LevelLayout();

        // Checking at !, rooms at X
        //
        // 4       X
        // 3     X ! X
        // 2   X
        // 1
        // 0 1 2 3 4 5

        layout.AddRoom(new Vector2Int(4, 4));
        layout.AddRoom(new Vector2Int(3, 3));
        layout.AddRoom(new Vector2Int(5, 3));
        layout.AddRoom(new Vector2Int(2, 2));

        IRoom[] results = layout.GetAdjacent(new Vector2Int(4, 3));

        Assert.AreEqual(
            results[(int)Direction.Up].Position,
            new Vector2Int(4, 4)
            );

        Assert.AreEqual(
            results[(int)Direction.Left].Position,
            new Vector2Int(3, 3)
            );

        Assert.AreEqual(
            results[(int)Direction.Right].Position,
            new Vector2Int(5, 3)
            );

        Assert.IsNull(
            results[(int)Direction.Down]
            );
    }