public void EvaluteShift3()
        {
            var strikeModel = new StrikeModel { Velocity = 1, Delay = 1 };

            var kick = new LinearWithTimeDelayBallKickPhysics(strikeModel);

            var shift = kick.EvaluteShift(1);

            Assert.AreEqual(2, shift.X);
            Assert.AreEqual(0, shift.Y);
        }
        public void EvaluteTimeDelay6()
        {
            var strikeModel = new StrikeModel { Velocity = 0, Delay = 0 };

            var kick = new LinearWithTimeDelayBallKickPhysics(strikeModel);

            var time = kick.EvaluteElapsedTime(new Vector2(1, 0));

            Assert.IsTrue(double.IsInfinity(time));
        }
        public void EvaluteTimeDelay5()
        {
            var strikeModel = new StrikeModel { Velocity = 2, Delay = 1 };

            var kick = new LinearWithTimeDelayBallKickPhysics(strikeModel);

            var time = kick.EvaluteElapsedTime(new Vector2(10, 0));

            Assert.AreEqual(4, time);
        }
        public bool Loop()
        {
            const bool looping = false;

            //var model = _currentStrike.Model;

            var user = _users.FirstOrDefault(t => t.UserInfo.UserType == UserTypeEnum.User);

            if (user == null) throw new NullReferenceException("user");

            // Внести задержку перед ударом соперника
            Thread.Sleep(1500);

            var history = GameObjects["history"] as ExperimentHistory;

            var ballKick = new LinearWithTimeDelayBallKickPhysics(_currentStrike.Model);

            var competitor = CompetitorFactory.CreateCompetitor(_currentStrike, _ball, _hole, user, history, ballKick);
            var kickResult = competitor.KickBall();

            var strike = Strike.CreateStrike(_ball, _hole, _currentStrike, kickResult);

            GameObjects["strike"] = strike;

            _currentUser.Strikes.Add(strike);

            return looping;
        }
        private Strike ImitateUserKickedBall()
        {
            var physics = new LinearWithTimeDelayBallKickPhysics(_currentStrike.Model);

            var testPlayer = TestPlayerFactory.CreatePlayer(_ball, _hole, _currentStrike.InTestMode.PlayerModel, physics);

            var ballKickResult = testPlayer.KickBall();

            return Strike.CreateStrike(_ball, _hole, _currentStrike, ballKickResult);
        }
        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;
        }