示例#1
0
 public void Merge(BlockGroup group, Translation lastTranslation)
 {
     if (group.Overlaps(core))
     {
         group.Translate(lastTranslation.Negate());
         core.Merge(group);
     }
 }
        [Test] public void ShouldReturnFalseWhenNoBlocksOverlap()
        {
            Block      apple  = CreateBlock(1, 2);
            Block      orange = CreateBlock(1, 1);
            BlockGroup fruit  = CreateBlockGroup(apple, orange);

            Block      tomato     = CreateBlock(2, 2);
            Block      carrot     = CreateBlock(2, 3);
            BlockGroup vegetables = CreateBlockGroup(tomato, carrot);

            Assert.That(fruit.Overlaps(vegetables), Is.False);
        }
        [Test] public void ShouldReturnTrueWhenAtLeastOneBlockOverlaps()
        {
            Block      apple  = CreateBlock(1, 2);
            Block      orange = CreateBlock(1, 1);
            BlockGroup fruit  = CreateBlockGroup(apple, orange);

            Block      tomato     = CreateBlock(2, 2);
            Block      carrot     = CreateBlock(1, 2);
            BlockGroup vegetables = CreateBlockGroup(tomato, carrot);

            Assert.That(fruit.Overlaps(vegetables), Is.True);
        }