protected override void Initialize() { this.settings = new GameSettings(); GameSettingsComponent settingsComponent = new GameSettingsComponent(this, settings, graphics); this.Components.Add(settingsComponent); LoadingScreenComponent loading = new LoadingScreenComponent(this, settings); this.Components.Add(loading); MenuItemsComponent menuItems = new MenuItemsComponent( this, settings, new Vector2(this.viewport.Width * 0.45f, this.viewport.Height * 0.75f), Color.Blue, Color.Yellow, 72 ); menuItems.AddItem("Hrát", "new-game"); menuItems.AddItem("Nastavení", "settings"); menuItems.AddItem("O høe", "about"); menuItems.AddItem("Odejít", "exit"); MenuItemsComponent settingScreenItems = new MenuItemsComponent( this, settings, new Vector2(this.viewport.Width * 0.45f, this.viewport.Height * 0.75f), Color.Blue, Color.Yellow, 72 ); settingScreenItems.AddItem("Postava", "player-sprite"); settingScreenItems.AddItem("Hudba", "music-enabled"); settingScreenItems.AddItem("Zpìt do menu", "back"); ScrollingBackgroundComponent scrollingBackground = new ScrollingBackgroundComponent(this, settings); this.Components.Add(scrollingBackground); GameSettingsScreenComponent settingsScreenComponent = new GameSettingsScreenComponent(this, settings, settingScreenItems); this.Components.Add(settingsScreenComponent); AboutScreenComponent aboutScreenComponent = new AboutScreenComponent(this, settings); this.Components.Add(aboutScreenComponent); MenuComponent menu = new MenuComponent(this, settings, menuItems); this.Components.Add(menu); LevelComponent level = new LevelComponent(this, settings, scrollingBackground); this.Components.Add(level); this.loadingScreen = new GameWindow(this, loading); this.menuWindow = new GameWindow(this, menu, menuItems, settingsComponent, scrollingBackground); this.ingameWindow = new GameWindow(this, level, settingsComponent, scrollingBackground); this.settingsScreen = new GameWindow(this, settingsScreenComponent, settingScreenItems, settingsComponent, scrollingBackground); this.aboutScreen = new GameWindow(this, settingsComponent, scrollingBackground, aboutScreenComponent); foreach (GameComponent component in this.Components) { this.SwitchComponent(component, false); } // BASE GRAPHICS STUFF this.IsMouseVisible = false; //this.graphics.IsFullScreen = true; this.graphics.PreferredBackBufferHeight = 720; this.graphics.PreferredBackBufferWidth = 1280; this.graphics.ApplyChanges(); this.SwitchWindows(loadingScreen); base.Initialize(); }
/// <summary> /// Initializes all the gameScenes. /// Sets the menuScene as the active scene. /// </summary> private void Initialize() { // creating background components PlanetBackgroundComponent planetBackground = new PlanetBackgroundComponent(game); PlanetExplodeBackgroundComponent planetExplodeBackground = new PlanetExplodeBackgroundComponent(game); PlanetRingsBackgroundCompnent planetRingsBackground = new PlanetRingsBackgroundCompnent(game); // creating window components TopTenComponent topTen = new TopTenComponent(game); GameWonComponent gameWon = new GameWonComponent(game); GameOverComponent gameOver = new GameOverComponent(game); PlayerSettingsComponent playerSettings = new PlayerSettingsComponent(game); MenuItemsComponent menuItems = new MenuItemsComponent(game, new Vector2(700, 250), Color.Red, Color.Yellow); // Listing menu options. Room to grow if we want more options. menuItems.AddItem("Play"); menuItems.AddItem("Top Scores"); menuItems.AddItem("Player Settings"); menuItems.AddItem("Quit"); MenuComponent menu = new MenuComponent(game, menuItems); // Assigns music soundManager.SetDeepSpaceMusic(game.Content.Load <Song>(@"Sounds\DeepSpace")); soundManager.SetMegalovaniaMusic(game.Content.Load <Song>(@"Sounds\Megalovania")); soundManager.SetSolarSystemMusic(game.Content.Load <Song>(@"Sounds\Solar System")); soundManager.SetMenuBGMusic(game.Content.Load <Song>(@"Sounds\MenuBG")); // Assigns sound effects soundManager.SetGunShotSound(game.Content.Load <SoundEffect>(@"Sounds\gunShot")); soundManager.SetExplosionSound(game.Content.Load <SoundEffect>(@"Sounds\explosion")); soundManager.SetExplosion1Sound(game.Content.Load <SoundEffect>(@"Sounds\explosion1")); soundManager.SetExplosion2Sound(game.Content.Load <SoundEffect>(@"Sounds\explosion2")); soundManager.SetExplosionAggressiveSound(game.Content.Load <SoundEffect>(@"Sounds\explosion_aggresive")); soundManager.SetExplosionTinySound(game.Content.Load <SoundEffect>(@"Sounds\explosion_tiny")); soundManager.SetExplosionUnderwaterSound(game.Content.Load <SoundEffect>(@"Sounds\explosion_underwater")); soundManager.SetLaserShotSound(game.Content.Load <SoundEffect>(@"Sounds\laserShot")); soundManager.SetLaserShot1Sound(game.Content.Load <SoundEffect>(@"Sounds\laserShot1")); soundManager.SetLosingSound(game.Content.Load <SoundEffect>(@"Sounds\losing1")); soundManager.SetWinningSound(game.Content.Load <SoundEffect>(@"Sounds\medievalWin")); soundManager.SetPickUpItemSound(game.Content.Load <SoundEffect>(@"Sounds\pickUpItem")); soundManager.SetStartUpSound(game.Content.Load <SoundEffect>(@"Sounds\startUpSound")); // Assigns fancy font. FontOriginTech = game.Content.Load <SpriteFont>(@"Fonts\font_origin_tech"); FontOriginTechSmall = game.Content.Load <SpriteFont>(@"Fonts\font_origin_tech_small"); FontOriginTechTiny = game.Content.Load <SpriteFont>(@"Fonts\font_origin_tech_tiny"); // Putting together the GameScenes, each using a background component and a window component. MenuScene = new GameScene(game, planetBackground, menu); TopTenScene = new GameScene(game, planetBackground, topTen); GameWonScene = new GameScene(game, planetRingsBackground, gameWon); GameOverScene = new GameScene(game, planetExplodeBackground, gameOver); PlayerSettingsScene = new GameScene(game, planetRingsBackground, playerSettings); MenuScene = new GameScene(game, planetBackground, menu, menuItems); // disabling components foreach (GameComponent component in game.Components) { ChangeComponentState(component, false); } ChangeMusic(this.sound.MenuBG); }