public static Game.Game AddKeyboard(this Game.Game game) { var keyboard = new Keyboard(game); game.Subscribe(GameNotification.PreTick, keyboard.CheckForKeyPress); return(game); }
public static Game.Game AddBots(this Game.Game game, string[] args) { if (args.Length > 0) { if (args[0].Equals("--pipename")) { var pipename = args[1]; var transport = new NamedPipesTransport(pipename); var botConnector = new BotConnector(transport, game); botConnector.Initialise(); game.Subscribe(GameNotification.PreTick, botConnector.RequestNextMoveFromBot); } if (args[0].Equals("--hostname")) { var hostNameAndPortal = args[1]; var parts = hostNameAndPortal.Split(':'); var transport = new SocketsTransport(parts[0], int.Parse(parts[1])); var botConnector = new BotConnector(transport, game); botConnector.Initialise(); game.Subscribe(GameNotification.PreTick, botConnector.RequestNextMoveFromBot); } if (args[0].Equals("--process")) { var pathToExe = args[1]; var transport = new StdInOutTransport(pathToExe); var botConnector = new BotConnector(transport, game); botConnector.Initialise(); game.Subscribe(GameNotification.PreTick, botConnector.RequestNextMoveFromBot); } } return(game); }
internal static Game.Game AddSounds(this Game.Game game, SoundSet soundSet) { game.Subscribe(GameNotification.Beginning, soundSet.Beginning) .Subscribe(GameNotification.EatCoin, soundSet.Chomp) .Subscribe(GameNotification.Respawning, soundSet.Death) .Subscribe(GameNotification.EatFruit, soundSet.EatFruit) .Subscribe(GameNotification.EatGhost, soundSet.EatGhost) .Subscribe(GameNotification.ExtraPac, soundSet.ExtraPac) .Subscribe(GameNotification.Intermission, soundSet.Intermission); return(game); }