Exemplo n.º 1
0
        public void Cancel_ShouldNotRiseMovePathComplete(int moveCompleteCalledCount)
        {
            // Arrange
            List <IntVector2> path = new List <IntVector2>();

            path.Add(new IntVector2(0, 0));
            path.Add(new IntVector2(1, 1));
            path.Add(new IntVector2(2, 1));
            path.Add(new IntVector2(3, 1));

            int actualMoveCompleteCalledCount = 0;

            Mock.Arrange(() => _occupatedPossitionsMap.IsVacantPosition(Arg.IsAny <IntVector2>()))
            .Returns(true);

            _moveStepByStepController = CreateMoveStepByStepController();
            _moveStepByStepController.MovePathComplete += () => actualMoveCompleteCalledCount++;

            // Act
            _moveStepByStepController.MoveTo(path);
            _moveStepByStepController.Cancel();
            for (int i = 0; i < moveCompleteCalledCount; i++)
            {
                _unitGameObjectController.MoveTo(new IntVector2(0, 0));
            }

            // Assert
            Assert.Equal(1, actualMoveCompleteCalledCount);
        }
Exemplo n.º 2
0
 private void MoveNextStep()
 {
     IntVector2 nextPosition;
     if (_path.Count > 0)
     {
         nextPosition = GetNextPossition();
         if (IsPositionOccupated(nextPosition)) return;
         _unitGameObjectController.MoveTo(nextPosition);
     }
     else
     {
         Cancel();
         MovePathComplete?.Invoke();
     }
 }
Exemplo n.º 3
0
        //[tested method]_[expected input]_[expected behavior]
        public void MoveTo_AnyPosition_ShouldCallWalkAnimation()
        {
            // Arrange
            bool playWalkAnimationCalled = false;
            bool moveTileCompleteCalled  = false;

            _unitAnimationController.PlayWalkAnimationEvent += () => playWalkAnimationCalled = true;
            _unitGameObjectController.MoveTileComplete      += () => moveTileCompleteCalled = true;

            // Act
            _unitGameObjectController.MoveTo(new IntVector2());

            // Assert
            Assert.True(playWalkAnimationCalled);
            Assert.True(moveTileCompleteCalled);
        }