protected override void Initialize() { StaticClassSerializer.Load(typeof(PlayerData), "data.bin"); // Manage inputs like keyboard or gamepad Components.Add(new InputHandler(this)); // Display FPS at the top left screen's corner Components.Add(new FrameRateCounter(this)); _stateManager = new GameStateManager(this); Components.Add(_stateManager); // Screens TitleScreen = new TitleScreen(this, _stateManager); DebugScreen = new DebugScreen(this, _stateManager); PatternTestScreen = new PatternTestScreen(this, _stateManager); GameConfigurationScreen = new GameConfigurationScreen(this, _stateManager); GameplayScreen = new GameplayScreen(this, _stateManager); LeaderboardScreen = new LeaderboardScreen(this, _stateManager); ImprovementScreen = new ImprovementScreen(this, _stateManager); GameOverScreen = new GameOverScreen(this, _stateManager); OptionsScreen = new OptionsScreen(this, _stateManager); KeyboardInputsScreen = new KeyboardInputsScreen(this, _stateManager); GamepadInputsScreen = new GamepadInputsScreen(this, _stateManager); _stateManager.ChangeState(TitleScreen); ParticleManager = new ParticleManager <ParticleState>(1024 * 20, ParticleState.UpdateParticle); base.Initialize(); }
public void LoadContent(IContentLoader provider) { Select = provider.Load <SoundEffect>(@"Audio/SE/select"); Choose = provider.Load <SoundEffect>(@"Audio/SE/choose"); _stateManager = new GameStateManager(); // Screens TitleScreen = new TitleScreen(viewport, _stateManager, Select, Choose, InputHandler); contentBasedParts.Add(TitleScreen); GameConfigurationScreen = new GameConfigurationScreen(viewport, _stateManager); GameplayScreen = new GameplayScreen(viewport, _stateManager, Camera); // .DisposeWith(instanceDisposer); GameplayScreen.Initialize(); contentBasedParts.Add(GameplayScreen); LeaderboardScreen = new LeaderboardScreen(viewport, _stateManager); ImprovementScreen = new ImprovementScreen(viewport, _stateManager, Select, Choose); GameOverScreen = new GameOverScreen(viewport, _stateManager); OptionsScreen = new OptionsScreen(viewport, _stateManager, pixel, Select); KeyboardInputsScreen = new KeyboardInputsScreen(viewport, _stateManager); GamepadInputsScreen = new GamepadInputsScreen(viewport, _stateManager); _stateManager.AddScreens(GameOverScreen, OptionsScreen, TitleScreen, GameplayScreen, ImprovementScreen); _stateManager.ComponentAdded += (s, arg) => { updatableParts.Add(arg); drawableParts.Add(arg); }; _stateManager.ComponentRemoved += (s, arg) => { updatableParts.Remove(arg); drawableParts.Remove(arg); }; _stateManager.ChangeState(GameStateManager.State.TitleScreen); foreach (var item in contentBasedParts) { item.LoadContent(provider); } foreach (var item in ContentBasedParts) { item.LoadContent(provider); } }
public DnK() { Graphics = new GraphicsDeviceManager(this) { PreferredBackBufferWidth = Config.Resolution.X, PreferredBackBufferHeight = Config.Resolution.Y }; ScreenRectangle = new Rectangle(0, 0, Config.Resolution.X, Config.Resolution.Y); IsMouseVisible = true; Graphics.IsFullScreen = Config.FullScreen; Graphics.SynchronizeWithVerticalRetrace = true; // Pass through the FPS capping (60 FPS) if (!Config.FpsCapping) { IsFixedTimeStep = false; Graphics.SynchronizeWithVerticalRetrace = false; } Graphics.ApplyChanges(); Content.RootDirectory = "Content"; Components.Add(new InputHandler(this)); _stateManager = new GameStateManager(this); Components.Add(_stateManager); // Screens TitleScreen = new TitleScreen(this, _stateManager); GameConfigurationScreen = new GameConfigurationScreen(this, _stateManager); GameplayScreen = new GameplayScreen(this, _stateManager); LeaderboardScreen = new LeaderboardScreen(this, _stateManager); ImprovementScreen = new ImprovementScreen(this, _stateManager); GameOverScreen = new GameOverScreen(this, _stateManager); OptionsScreen = new OptionsScreen(this, _stateManager); KeyboardInputsScreen = new KeyboardInputsScreen(this, _stateManager); GamepadInputsScreen = new GamepadInputsScreen(this, _stateManager); _stateManager.ChangeState(TitleScreen); // FPS Components.Add(new FrameRateCounter(this)); }
public void Run() { using (GameConfigurationScreen gameConfigurationScreen = new GameConfigurationScreen(_gameConfiguration)) { gameConfigurationScreen.ShowDialog(); } Lobby lobby = new Lobby(_gameConfiguration); using (LobbyScreen lobbyScreen = new LobbyScreen(lobby)) { lobbyScreen.ShowDialog(); } Game game = new Game(_gameConfiguration.ServerConnection); _gameScreen = new GameScreen(game); Application.Run(_gameScreen); }