public ConsoleManager(IInputDevice inputDevice, int sleepTimeout) { this.inputDevice = inputDevice; this.sleepTimeout = sleepTimeout; this.inputDevice.LeftArrowKeyPressed += new EventHandler(this.inputDevice_LeftArrowKeyPressed); this.inputDevice.RightArrowKeyPressed += new EventHandler(this.inputDevice_RightArrowKeyPressed); this.inputDevice.UpArrowKeyPressed += new EventHandler(this.inputDevice_UpArrowKeyPressed); this.inputDevice.DownArrowKeyPressed += new EventHandler(this.inputDevice_DownArrowKeyPressed); InitMaze(); pacman = new Pacman(new Location(15, 18), '>', ConsoleColor.Yellow); pacman.ScoreUpdated += new ScoreUpdatedEventHandler(this.pacman_ScoreUpdated); Draw(pacman); IMovingStrategy strategy = new BfsStrategy(); // Shadow, the red guy Ghost blinky = new Ghost(new Location(8, 18), ConsoleColor.Red, strategy); // Bashful, the blue guy Ghost inky = new Ghost(new Location(11, 16), ConsoleColor.Cyan, strategy); // Speedy, the pink guy Ghost pinky = new Ghost(new Location(11, 18), ConsoleColor.Magenta, strategy); // Pokey, the slow guy Ghost clyde = new Ghost(new Location(11, 20), ConsoleColor.Green, strategy); ghosts = new Ghost[4]; ghosts[0] = blinky; ghosts[1] = inky; ghosts[2] = pinky; ghosts[3] = clyde; foreach (Ghost ghost in ghosts) { ghost.EndOfRouteReached += new EventHandler(this.ghost_EndOfRouteReached); ghost.CalcRoute(routeTargets[targetSelector.Next(routeTargets.Length)], maze); } }
public ConsoleManager(IInputDevice inputDevice, int sleepTimeout) { this.inputDevice = inputDevice; this.sleepTimeout = sleepTimeout; this.inputDevice.LeftArrowKeyPressed += new EventHandler(this.inputDevice_LeftArrowKeyPressed); this.inputDevice.RightArrowKeyPressed += new EventHandler(this.inputDevice_RightArrowKeyPressed); this.inputDevice.UpArrowKeyPressed += new EventHandler(this.inputDevice_UpArrowKeyPressed); this.inputDevice.DownArrowKeyPressed += new EventHandler(this.inputDevice_DownArrowKeyPressed); InitMaze(); pacman = new Pacman(new Location(15, 18), '>', ConsoleColor.Yellow); pacman.ScoreUpdated += new ScoreUpdatedEventHandler(this.pacman_ScoreUpdated); Draw(pacman); IMovingStrategy strategy = new BfsStrategy(); // Shadow, the red guy Ghost blinky = new Ghost(new Location(8, 18), ConsoleColor.Red, strategy); // Bashful, the blue guy Ghost inky = new Ghost(new Location(11, 16), ConsoleColor.Cyan, strategy); // Speedy, the pink guy Ghost pinky = new Ghost(new Location(11, 18), ConsoleColor.Magenta, strategy); // Pokey, the slow guy Ghost clyde = new Ghost(new Location(11, 20), ConsoleColor.Green, strategy); ghosts = new Ghost[4]; ghosts[0] = blinky; ghosts[1] = inky; ghosts[2] = pinky; ghosts[3] = clyde; foreach (Ghost ghost in ghosts) { ghost.EndOfRouteReached += new EventHandler(this.ghost_EndOfRouteReached); ghost.CalcRoute(routeTargets[targetSelector.Next(routeTargets.Length)], maze); } }