public void GivenNpcAndEmptyFieldToLeftOfNpc_WhenMoveNpcLeft_ThenMovesNpcDownInTheMap() { //Arrange _testMap[1, 0] = new MapElementContainer(1, 0, new EmptyField()); // Act _npcToLeftMover.MoveNpcLeft(_testNpc); // Assert Check.That(_testMap[1, 1].MapElement).IsInstanceOf <EmptyField>(); Check.That(_testMap[1, 0].MapElement).IsInstanceOf <NonPlayableCharacter>(); }
public void MoveNpc(NonPlayableCharacter npc) { while (npc.IsAlive) { Thread.Sleep(npc.Speed); switch (npc.MoveDirection) { case MoveDirection.Up: if (!_npcToUpMover.MoveNpcUp(npc)) { if (_npcToLeftMover.MoveNpcLeft(npc)) { npc.MoveDirection = MoveDirection.Left; } else { npc.MoveDirection = _npcToRightMover.MoveNpcRight(npc) ? MoveDirection.Right : MoveDirection.Down; } } break; case MoveDirection.Down: if (!_npcToDownMover.MoveNpcDown(npc)) { if (_npcToRightMover.MoveNpcRight(npc)) { npc.MoveDirection = MoveDirection.Right; } else { npc.MoveDirection = _npcToUpMover.MoveNpcUp(npc) ? MoveDirection.Up : MoveDirection.Left; } } break; case MoveDirection.Right: if (!_npcToRightMover.MoveNpcRight(npc)) { if (_npcToDownMover.MoveNpcDown(npc)) { npc.MoveDirection = MoveDirection.Down; } else { npc.MoveDirection = _npcToUpMover.MoveNpcUp(npc) ? MoveDirection.Up : MoveDirection.Left; } } break; case MoveDirection.Left: if (!_npcToLeftMover.MoveNpcLeft(npc)) { if (_npcToUpMover.MoveNpcUp(npc)) { npc.MoveDirection = MoveDirection.Up; } else { npc.MoveDirection = _npcToDownMover.MoveNpcDown(npc) ? MoveDirection.Down : MoveDirection.Right; } } break; default: throw new ArgumentOutOfRangeException(); } NotifyUiDrawerMoveHappened(); } _npcDeleter.DeleteKilledNpc(npc); NotifyUiDrawerMoveHappened(); }