public void GHostCanNextStep() { Field field = new Field(); Pacman.GHost ghost = new Pacman.GHost(field); field.NewField[1, 1] = "&"; field.NewField[1, 2] = "-"; field.NewField[1, 3] = "|"; field.NewField[1, 4] = "_"; Assert.IsFalse(ghost.CanNextStep(new Coordinate(1, 1))); Assert.IsFalse(ghost.CanNextStep(new Coordinate(1, 2))); Assert.IsFalse(ghost.CanNextStep(new Coordinate(1, 3))); Assert.IsFalse(ghost.CanNextStep(new Coordinate(1, 4))); }
//Выход привидения на игровое поле public void StartGhost(GHost ghost, Coordinate pacmanCoord) { try { if (pacmanCoord.x < 0 || pacmanCoord.x > 24 || pacmanCoord.y < 0 || pacmanCoord.y > 24) { throw new Exception("PacmanCoord for method GamePacman.StartGhost IndexOutOfRangeException"); } if (ghost == null) { throw new Exception("Null reference ghost in GamePacman.StartGhost"); } } catch (Exception e) { Console.WriteLine(e.Message); System.Environment.Exit(0); } if (pacmanCoord.x != 7 && pacmanCoord.y != 12) { gameField.NewField[ghost.RealtimeCoordinate.x, ghost.RealtimeCoordinate.y] = " "; ghost.RealtimeCoordinate = new Coordinate(7, 12); ghost.previousValue = gameField.NewField[ghost.RealtimeCoordinate.x, ghost.RealtimeCoordinate.y]; gameField.NewField[ghost.RealtimeCoordinate.x, ghost.RealtimeCoordinate.y] = ghost.ghost_img; Console.Clear(); gameField.Print(score, lives); } else { ghost.RealtimeCoordinate = new Coordinate(7, 10); ghost.previousValue = gameField.NewField[ghost.RealtimeCoordinate.x, ghost.RealtimeCoordinate.y]; gameField.NewField[ghost.RealtimeCoordinate.x, ghost.RealtimeCoordinate.y] = ghost.ghost_img; } if (pacmanCoord.y <= 12) { ghost.INeedRoute(ghost.GoLeft); } else { ghost.INeedRoute(ghost.GoRight); } }