private async Task CheckEnemiesMovement(bool result, double[] positions) { await GameBoardHelper.StartStaTask(() => { _gameBoard = GameBoardHelper.GenerateEmptyGameBoard(_width, _height); IGameMovementChecker checker = GameBoardHelper.GetGameMovementChecker(_gameBoard); ISettingsProvider provider = new TestSettingsProvider(); IGraph graph = new Graph(_gameBoard); var player = new Mock <Player>(); player.Object.X = positions[0]; player.Object.Y = positions[1]; var alg = new AStarEnemyMovementAlgorithm(graph, player.Object, (int)_width, (int)_height); var e1 = new Enemy(); e1.X = positions[2]; e1.Y = positions[3]; e1.MovementAlgorithm = alg; var e2 = new Enemy(); e2.X = positions[4]; e2.Y = positions[5]; e2.MovementAlgorithm = alg; _gameBoard.Children.Add(e1); _gameBoard.Children.Add(e2); IEnemyMovementManager manager = new TimeEnemyMovementManager(new [] { e1, e2 }, checker, provider); manager.MoveEnemies(); bool res = checker.CheckCollision(e1, e2); Assert.Equal(result, res); }); }
private async Task CheckMovementTest(double playerX, double playerY, Direction direction, bool result) { await GameBoardHelper.StartStaTask(() => { _gameBoard = GameBoardHelper.GenerateEmptyGameBoard(_width, _height); var checker = GameBoardHelper.GetGameMovementChecker(_gameBoard); Player player = new Player() { X = playerX, Y = playerY }; bool res = checker.CheckMovement(player, direction); Assert.Equal(result, res); }); }
private async Task CheckStaticColisionBetweenPlayerAndBlocks(double playerX, double playerY, double blockX, double blockY, bool result) { await GameBoardHelper.StartStaTask(() => { _gameBoard = GameBoardHelper.GenerateEmptyGameBoard(_width, _height); var checker = GameBoardHelper.GetGameMovementChecker(_gameBoard); Player player = new Player() { X = playerX, Y = playerY }; Block block = _gameBoard.Elements.FirstOrDefault(b => Math.Abs(b.X - blockX) < 1 && Math.Abs(b.Y - blockY) < 1) as Block; bool res = checker.CheckCollision(player, block); Assert.Equal(result, res); }); }
private void ControlKeyChange(Key pressed, string pressedKey, bool result) { GameBoardHelper.StartStaTask(() => { var accessor = new TestHaveControlKeys(); OptionsViewModel vm = new OptionsViewModel(accessor, new KeysValidator()); accessor.LoadControlKeys(); vm.ChangeKey(pressedKey); var args = new KeyEventArgs(Keyboard.PrimaryDevice, new Mock <PresentationSource>().Object, 0, pressed); vm.OnKeyDown(args); Assert.Equal(result, !vm.HasErrors); Key k = GetKeyByName(accessor, pressedKey); Assert.NotEqual(k, Key.None); if (result) { Assert.Equal(k, pressed); } }); }
private async Task CheckIsNextElementTest(double playerX, double playerY, Direction direction, double enemyX, double enemyY, bool result) { await GameBoardHelper.StartStaTask(() => { _gameBoard = GameBoardHelper.GenerateEmptyGameBoard(_width, _height); var checker = GameBoardHelper.GetGameMovementChecker(_gameBoard); Player player = new Player() { X = playerX, Y = playerY }; Enemy enemy = new Enemy() { X = enemyX, Y = enemyY }; _gameBoard.Children.Add(enemy); bool res = checker.IsElementNextTo <MovableElement>(player, direction); Assert.Equal(result, res); }); }