public void KickBall() { const int discrTimeStep = 200; const int elapsedMilliseconds = 220; var physicsMock = new Moq.Mock<IBallKickPhysics>(); physicsMock.Setup(t => t.EvaluteShift(Moq.It.IsAny<double>())).Returns(new Vector2() {X = 10, Y = 0}); var player = new Player(discrTimeStep, elapsedMilliseconds, physicsMock.Object); var result = player.KickBall(); Assert.AreEqual(0.2, result.ElapsedTime); }
public bool Loop() { var looping = true; if (_inTestMode) { var strike = ImitateUserKickedBall(); GameObjects["strike"] = strike; _currentUser.Strikes.Add(strike); looping = false; } else { // Удар игрока if (_firstLoop) { _timerBeforeSpaceDown.Start(); _firstLoop = false; } if (_timer.IsSelecting) { if (!_stopwatch.IsRunning) { _stopwatch.Start(); } _timerBeforeSpaceDown.Stop(); } else { if (_timer.IsSelected) { _stopwatch.Stop(); var discreteStep = _currentGame.DiscreteTimeStepMeasuring; var elapsedMilliseconds = _stopwatch.ElapsedMilliseconds; var phisics = new LinearWithTimeDelayBallKickPhysics(_currentStrike.Model); var player = new Player(discreteStep, elapsedMilliseconds, phisics); var kickResult = player.KickBall(); var strike = Strike.CreateStrike(_ball, _hole, _currentStrike, kickResult, TimeSpan.FromMilliseconds(_timerBeforeSpaceDown.ElapsedMilliseconds)); GameObjects["strike"] = strike; _currentUser.Strikes.Add(strike); looping = false; } } } return looping; }