Ejemplo n.º 1
0
        public void Remote_Update_During_Animation()
        {
            // Arrange
            _timeStub.Ticks.Add(TimeSpan.TicksPerSecond); // Connected timestamp
            _randomGeneratorStub.AddValues(2);            // Player position

            var tuple          = _gameEngine.RemotePlayerConnected("a");
            var playerMetadata = tuple.Item1;

            playerMetadata.Player.Animation       = "a";
            playerMetadata.Player.AnimationTiming = 100;

            var player = ClonePlayer(playerMetadata);
            RemoteUpdatePlayerResult expected = RemoteUpdatePlayerResult.UpdateSelf;

            // Act
            var actual = _gameEngine.RemoteUpdatePlayer("a", player, out PlayerMetadata playerMetadataUpdate);

            // Assert
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 2
0
        public void Remote_Update(double clientDeltaY, double expectedY, RemoteUpdatePlayerResult expected)
        {
            // Arrange
            _timeStub.Ticks.Add(TimeSpan.TicksPerSecond);                                // Connected timestamp
            _timeStub.Ticks.Add(TimeSpan.TicksPerSecond + TimeSpan.TicksPerMillisecond); // Remote Update timestamp
            _randomGeneratorStub.AddValues(2);                                           // Player position

            var tuple          = _gameEngine.RemotePlayerConnected("a");
            var playerMetadata = tuple.Item1;

            var player = ClonePlayer(playerMetadata);

            player.Top = true;
            player.Y  -= clientDeltaY;
            var expectedX = player.X;

            // Act
            var actual = _gameEngine.RemoteUpdatePlayer("a", player, out PlayerMetadata playerMetadataUpdate);

            // Assert
            Assert.Equal(expected, actual);
            Assert.Equal(expectedX, playerMetadataUpdate.Player.X);
            Assert.Equal(expectedY, playerMetadataUpdate.Player.Y);
        }