Ejemplo n.º 1
0
    public void TestFixedGameStepGreaterThanFixedTime()
    {
        GameFixedUpdate gameFixedUpdate = new GameFixedUpdate();

        gameFixedUpdate.FixedStepTime = 0.05f;

        gameFixedUpdate.Init();

        gameFixedUpdate.Update(0.051f);

        Assert.That(gameFixedUpdate.CurrentGameFrame, Is.EqualTo(1));
    }
        public void TestNoFixedUpdateIfNotEnoughTime()
        {
            var gameLogic = new TestGameStep.GameStepEngineMock();

            GameFixedUpdate gameUpdate = new GameFixedUpdate();

            gameUpdate.FixedStepTime = 0.1f;
            gameUpdate.SetGameLogic(gameLogic);

            gameUpdate.Update(0.09f);

            Assert.That(gameLogic.UpdateTimes, Is.EqualTo(0));
        }
        public void TestDoubleTimeIncreasesTwoFixedUpdates()
        {
            var gameLogic = new TestGameStep.GameStepEngineMock();

            GameFixedUpdate gameUpdate = new GameFixedUpdate();

            gameUpdate.FixedStepTime = 0.1f;
            gameUpdate.SetGameLogic(gameLogic);

            gameUpdate.Update(0.1f * 2);

            Assert.That(gameLogic.lastFrame, Is.EqualTo(1));
            Assert.That(gameLogic.lastDt, Is.EqualTo(0.1f).Within(0.001f));
        }
Ejemplo n.º 4
0
    public void TestFixedGameStepEngineCalled()
    {
        GameFixedUpdate    gameFixedUpdate = new GameFixedUpdate();
        GameStepEngineMock gameStepEngine  = new GameStepEngineMock();

        gameFixedUpdate.SetGameLogic(gameStepEngine);

        gameFixedUpdate.FixedStepTime = 0.05f;

        gameFixedUpdate.Init();

        gameFixedUpdate.Update(0.078f);

        Assert.That(gameStepEngine.lastDt, Is.EqualTo(0.05f));
        Assert.That(gameStepEngine.lastFrame, Is.EqualTo(0));
    }
Ejemplo n.º 5
0
    public void TestFixedGameStepTwoUpdates()
    {
        GameFixedUpdate gameFixedUpdate = new GameFixedUpdate();

        gameFixedUpdate.FixedStepTime = 0.05f;

        gameFixedUpdate.Init();

        gameFixedUpdate.Update(0.01f);

        Assert.That(gameFixedUpdate.CurrentGameFrame, Is.EqualTo(0));

        gameFixedUpdate.Update(0.045f);

        Assert.That(gameFixedUpdate.CurrentGameFrame, Is.EqualTo(1));
    }
        public void TestFramesStartsZeroIndexed()
        {
            var gameLogic = new TestGameStep.GameStepEngineMock();

            GameFixedUpdate gameUpdate = new GameFixedUpdate();

            gameUpdate.FixedStepTime = 0.1f;
            gameUpdate.SetGameLogic(gameLogic);

            gameUpdate.Update(0.1f);

            Assert.That(gameLogic.lastFrame, Is.EqualTo(0));

            gameUpdate.Update(0.1f);

            Assert.That(gameLogic.lastFrame, Is.EqualTo(1));
        }
Ejemplo n.º 7
0
        public ReplayController(GameFixedUpdate gameFixedUpdate, ChecksumProvider checksumProvider, ReplayView recorderView, Commands commands, Replay replay)
        {
            _recording = true;

            _checksumProvider = checksumProvider;

            _replay = replay;

//			_replay = new ReplayBase (checksumProvider);

            _gameFixedUpdate = gameFixedUpdate;
            _recorderView    = recorderView;
            _commands        = commands;

            if (_recorderView != null)
            {
                _recorderView.SetReplay(this);
            }

            _replayRecorder = new ReplayRecorder(_replay, _commands);
            _replayPlayer   = new ReplayPlayer(_replay, _commands);
        }
Ejemplo n.º 8
0
 private void FixedUpdate()
 {
     GameFixedUpdate?.Invoke();
 }