Exemplo n.º 1
0
        public void TeleportationRemovesWater()
        {
            var entity = World.Global.SpawnEntity(entityFactory, Zero);
            var water  = World.Global.SpawnEntity(Water.Factory, Zero + Right);

            entity.Move(Right);

            entity.GetTransform().ResetPositionInGrid(Zero + Down);
            entity.BePushed(Push.Default(), Right);
            Assert.False(entity.HasPinnedEntityModifier());
        }
Exemplo n.º 2
0
        public void BeingPushed_WhileSliding()
        {
            // Let's add some ice below to set things up
            // _ _ _ _        _ _ _ _
            // i i i _        i i i _         i are ice floor
            // _ _ _ _    ->  i _ _ _         e is the entity
            // _ _ _ _        e _ _ _
            //
            var ice1   = World.Global.SpawnEntity(IceFloor.Factory, new IntVector2(0, 2));
            var entity = World.Global.SpawnEntity(entityFactory, new IntVector2(0, 3));

            // We let the entity move up
            entity.Move(IntVector2.Up);

            // _ _ _ _
            // i i i _
            // e _ _ _
            // _ _ _ _

            // As a result, it gets the sliding modifier
            Assert.AreEqual(new IntVector2(0, 2), entity.GetTransform().position);
            Assert.True(entity.HasSlidingEntityModifier());

            // If we then push it to the right, it gets pushed successfully and loses the effect

            // _ _ _ _
            // i i i _
            // i e _ _
            // _ _ _ _

            entity.BePushed(Push.Default(), IntVector2.Right); // < 1, 2 >
            Assert.AreEqual(new IntVector2(1, 2), entity.GetTransform().position);
            Assert.False(entity.HasSlidingEntityModifier());

            // Now we take the entity back to the initial position
            // Moving back to the left should not apply the effect since there is nowhere to slide

            // _ _ _ _
            // i i i _
            // e _ _ _
            // _ _ _ _

            entity.Move(IntVector2.Left); // < 0, 2 >
            Assert.AreEqual(new IntVector2(0, 2), entity.GetTransform().position);
            Assert.False(entity.HasSlidingEntityModifier());

            // _ _ _ _
            // i i i _
            // i _ _ _
            // e _ _ _

            entity.Move(IntVector2.Down); // < 0, 3 >
            Assert.AreEqual(new IntVector2(0, 3), entity.GetTransform().position);
            Assert.False(entity.HasSlidingEntityModifier());

            // Now we move up again
            entity.Move(IntVector2.Up);   // < 0, 2 >
            Assert.AreEqual(new IntVector2(0, 2), entity.GetTransform().position);
            Assert.True(entity.HasSlidingEntityModifier());

            // This time we skip an action.
            // The action is null but it will be modified by the effect.
            entity.GetActing().Activate();
            Assert.AreEqual(new IntVector2(0, 1), entity.GetTransform().position);
            Assert.True(entity.HasSlidingEntityModifier());

            // Now we get pushed to the right
            // The effect is still applied, but the direction of sliding is different
            entity.BePushed(Push.Default(), IntVector2.Right);
            Assert.AreEqual(new IntVector2(1, 1), entity.GetTransform().position);
            Assert.True(entity.HasSlidingEntityModifier());
            Assert.AreEqual(IntVector2.Right, entity.GetSlidingEntityModifier().directionOfSliding);

            // Say we try moving up through the acting now, but we should keep moving right
            entity.GetActing().ActivateWith(Moving.Action.Compile(IntVector2.Up));
            Assert.AreEqual(new IntVector2(2, 1), entity.GetTransform().position);
            Assert.True(entity.HasSlidingEntityModifier());
        }