/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here ui = new UserInterface(GraphicsDevice); Player = new InputActor(1, new MouseDevice(), new KeyboardDevice(PlayerIndex.One, Window.Handle)); //Kernel.Bind<InputActor>().ToConstant(player); Components.Add(Player); ui.Actors.Add(Player); var statLog = new StatisticTextLog(ui.Root, Content.Load <SpriteFont>("Consolas"), true); statLog.SetPoint(Points.TopLeft, 10, 10); frameTime = Statistic.Get("Misc.Time", "{0:00.00}ms"); fps = new FrequencyTracker("Misc.FPS"); var console = new CommandConsole(this, Content.Load <SpriteFont>("Consolas"), ui.Root); Kernel.Bind <CommandConsole>().ToConstant(console); screens = new ScreenManager(); screens.Push(Kernel.Get <MainMenu>()); base.Initialize(); }
private static Control CreateUserInterface(Game game) { UserInterface ui = new UserInterface(game.GraphicsDevice); ui.DrawOrder = int.MaxValue; game.Components.Add(ui); var player = new InputActor(1); player.Add(new KeyboardDevice(PlayerIndex.One)); game.Components.Add(player); ui.Actors.Add(player); return(ui.Root); }
public MainMenu(TestGame game, CommandConsole console, GraphicsDevice device, ContentManager content, IServiceProvider services) { this.game = game; this.player = game.Player; ui = new UserInterface(device); ui.Actors.Add(player); var tests = from type in Assembly.GetExecutingAssembly().GetTypes() where typeof(TestScreen).IsAssignableFrom(type) where !type.IsAbstract select type; this.menu = new Menu(ui.Root); menu.SetPoint(Points.BottomLeft, 50, -50); int index = 0; foreach (var test in tests) { index++; var testKernel = new StandardKernel(); testKernel.Bind <GraphicsDevice>().ToConstant(device); testKernel.Bind <ContentManager>().ToConstant(new ContentManager(services)); testKernel.Bind <Game>().ToConstant(game); testKernel.Bind <TestGame>().ToConstant(game); testKernel.Bind <CommandConsole>().ToConstant(console); testKernel.Bind <IServiceProvider>().ToConstant(game.Services); //testKernel.Bind<InputActor>().ToConstant(player); var instance = testKernel.Get(test) as TestScreen; var menuOption = new TextButton(menu, content.Load <SpriteFont>("Consolas"), instance.Name); menuOption.Highlight = Color.Red; menuOption.Gestures.Bind((gesture, time, input) => Manager.Push(instance), new MouseReleased(MouseButtons.Left), new KeyReleased(Keys.Enter)); } var quit = new TextButton(menu, content.Load <SpriteFont>("Consolas"), "Exit"); quit.Highlight = Color.Red; quit.Gestures.Bind((gesture, time, input) => game.Exit(), new MouseReleased(MouseButtons.Left), new KeyReleased(Keys.Enter)); menu.Arrange(Justification.Left); }
public MainMenu(TestGame game, CommandConsole console, GraphicsDevice device, ContentManager content, IServiceProvider services) { this.game = game; this.player = game.Player; ui = new UserInterface(device); ui.Actors.Add(player); var tests = from type in Assembly.GetExecutingAssembly().GetTypes() where typeof(TestScreen).IsAssignableFrom(type) where !type.IsAbstract select type; this.menu = new Menu(ui.Root); menu.SetPoint(Points.BottomLeft, 50, -50); int index = 0; foreach (var test in tests) { index++; var testKernel = new StandardKernel(); testKernel.Bind<GraphicsDevice>().ToConstant(device); testKernel.Bind<ContentManager>().ToConstant(new ContentManager(services)); testKernel.Bind<Game>().ToConstant(game); testKernel.Bind<TestGame>().ToConstant(game); testKernel.Bind<CommandConsole>().ToConstant(console); testKernel.Bind<IServiceProvider>().ToConstant(game.Services); //testKernel.Bind<InputActor>().ToConstant(player); var instance = testKernel.Get(test) as TestScreen; var menuOption = new TextButton(menu, content.Load<SpriteFont>("Consolas"), instance.Name); menuOption.Highlight = Color.Red; menuOption.Gestures.Bind((gesture, time, input) => Manager.Push(instance), new MouseReleased(MouseButtons.Left), new KeyReleased(Keys.Enter)); } var quit = new TextButton(menu, content.Load<SpriteFont>("Consolas"), "Exit"); quit.Highlight = Color.Red; quit.Gestures.Bind((gesture, time, input) => game.Exit(), new MouseReleased(MouseButtons.Left), new KeyReleased(Keys.Enter)); menu.Arrange(Justification.Left); }
public TestScreen(string name, IKernel kernel) { Name = name; Game = kernel.Get<TestGame>(); content = kernel.Get<ContentManager>(); content.RootDirectory = "Content"; UI = kernel.Get<UserInterface>(); UI.Root.Gestures.Bind((gesture, time, device) => Manager.Pop(), new KeyReleased(Keys.Escape)); actor = Game.Player; UI.Actors.Add(actor); var title = new Label(UI.Root, content.Load<SpriteFont>("Consolas")); title.Text = Name; title.Justification = Justification.Centre; title.SetPoint(Points.Top, Int2D.Zero); }
public TestScreen(string name, IKernel kernel) { Name = name; game = kernel.Get <TestGame>(); content = kernel.Get <ContentManager>(); content.RootDirectory = "Content"; UI = kernel.Get <UserInterface>(); UI.Root.Gestures.Bind((gesture, time, device) => Manager.Pop(), new KeyReleased(Keys.Escape)); actor = game.Player; UI.Actors.Add(actor); var title = new Label(UI.Root, content.Load <SpriteFont>("Consolas")); title.Text = Name; title.Justification = Justification.Centre; title.SetPoint(Points.Top, Int2D.Zero); }
private static Control CreateUserInterface(Game game) { UserInterface ui = new UserInterface(game.GraphicsDevice) { DrawOrder = int.MaxValue }; game.Components.Add(ui); var player = new InputActor(1) { new KeyboardDevice(PlayerIndex.One) }; game.Components.Add(player); ui.Actors.Add(player); return ui.Root; }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { _ui = new UserInterface(GraphicsDevice); Player = new InputActor(1, new MouseDevice(), new KeyboardDevice(PlayerIndex.One, Window.Handle)); //Kernel.Bind<InputActor>().ToConstant(player); Components.Add(Player); _ui.Actors.Add(Player); var statLog = new StatisticTextLog(_ui.Root, Content.Load<SpriteFont>("Consolas"), true); statLog.SetPoint(Points.TopLeft, 10, 10); _frameTime = Statistic.Create("Misc.Time", "{0:00.00}ms"); _fps = new FrequencyTracker("Misc.FPS"); var console = new CommandConsole(this, Content.Load<SpriteFont>("Consolas"), _ui.Root); Kernel.Bind<CommandConsole>().ToConstant(console); _screens = new ScreenManager(); _screens.Push(Kernel.Get<MainMenu>()); base.Initialize(); }