/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); GameFont = Content.Load<SpriteFont>("GameFont"); Fleet = Content.Load<Texture2D>("plane_white"); BG = Content.Load<Texture2D>(String.Format("Backgrounds\\bg{0}",rnd.Next(1,7))); MainMenuBorders = Content.Load<Texture2D>("Menues\\menu"); Planet = new Texture2D[3]; for (int i = 1; i <= 3; i++) { Planet[i-1] = Content.Load<Texture2D>(String.Format("Planets\\new_p{0}",i)); } Logo = Content.Load<Texture2D>("logo"); Tutorial = Content.Load<Texture2D>("Tutorials\\tutorial1"); Shadow = Content.Load<Texture2D>("Planets\\shadow"); MuteUnchecked = Content.Load<Texture2D>("Menues\\mute_music_unchecked"); //MuteEffectsUnchecked = Content.Load<Texture2D>("Menues\\mute_effects_unchecked"); MuteChecked = Content.Load<Texture2D>("Menues\\Click\\mute_music_checked"); //MuteEffectsChecked = Content.Load<Texture2D>("Menues\\Click\\mute_effects_checked"); Silhoute = Content.Load<Texture2D>("selected3"); Defeat = Content.Load<Texture2D>("defeat"); Victory = Content.Load<Texture2D>("victory"); Color[] Black = new Color[800 * (Logo.Height+20)]; for (int i = 0; i < Black.Length; i++) { Black[i] = Color.Black; } BlackBoarder = new Texture2D(GraphicsDevice, 800, Logo.Height + 20); BlackBoarder.SetData(Black); if (SoundTracksEnabled) { MediaPlayer.MediaStateChanged += new EventHandler<EventArgs>(MediaPlayer_MediaStateChanged); Soundtrack = Content.Load<Song>(String.Format("Sound\\SoundTrack{0}", rnd.Next(1, 4))); MediaPlayer.Play(Soundtrack); } #region Buttons Create Button button_continue = new Button(Content.Load<Texture2D>("Menues\\bt_continue"), Content.Load<Texture2D>("Menues\\Click\\bt_continue_red"), new Vector2(400,130)); button_continue.OnClick += ContinuePress; Button button_newgame = new Button(Content.Load<Texture2D>("Menues\\bt_newgame"), Content.Load<Texture2D>("Menues\\Click\\bt_newgame_red"), new Vector2(400, 200)); button_newgame.OnClick += NewGamePress; Button button_options = new Button(Content.Load<Texture2D>("Menues\\bt_options"), Content.Load<Texture2D>("Menues\\Click\\bt_options_red"), new Vector2(400, 270)); button_options.OnClick = GoToOptionsPress; Button button_credits = new Button(Content.Load<Texture2D>("Menues\\bt_credits"), Content.Load<Texture2D>("Menues\\Click\\bt_credits_red"), new Vector2(400, 340)); button_credits.OnClick = CreditsPress; Button button_pause_continue = new Button(Content.Load<Texture2D>("Menues\\bt_continue"), Content.Load<Texture2D>("Menues\\Click\\bt_continue_red"), new Vector2(400, 130)); button_pause_continue.OnClick += UnpausePress; Menu.Buttons.Add(button_continue); Menu.Buttons.Add(button_newgame); Menu.Buttons.Add(button_options); Menu.Buttons.Add(button_credits); PauseMenu.Buttons.Add(button_pause_continue); LevelSelection = new MenuManager(); for (int i = 1; i <= 7; i++) { string file=String.Format("LevelButtons\\lvl{0}", i); Texture2D Texture = Content.Load<Texture2D>(file); Button button = new Button(Texture,Texture,new Vector2(i*105f -26.25f,110)); button.Scale = 0.90f; button.Tag = i; button.OnClick = LevelSelectionButtonClick; LevelSelection.Buttons.Add(button); } for (int i = 1; i <= 7; i++) { string file = String.Format("LevelButtons\\lvl{0}", i + 7); Texture2D Texture = Content.Load<Texture2D>(file); Button button = new Button(Texture, Texture, new Vector2(i * 105f-26.25f, 210)); button.Scale = 0.90f; button.Tag = i+7; button.OnClick = LevelSelectionButtonClick; LevelSelection.Buttons.Add(button); } for (int i = 1; i <= 6; i++) { string file = String.Format("LevelButtons\\lvl{0}", i + 14); Texture2D Texture = Content.Load<Texture2D>(file); Button button = new Button(Texture, Texture, new Vector2(i * 105f + 26.25f, 310)); button.Scale = 0.90f; button.Tag = i + 14; button.OnClick = LevelSelectionButtonClick; LevelSelection.Buttons.Add(button); } string f = String.Format("LevelButtons\\lvl{0}", 21); Texture2D t = Content.Load<Texture2D>(f); Button b = new Button(t, t, new Vector2(400, 420)); b.Scale = 1f; b.Tag = 21; b.OnClick = LevelSelectionButtonClick; LevelSelection.Buttons.Add(b); LevelSelection.Overlay = Content.Load<Texture2D>("lvl_completed"); LevelSelection.OverlayOrigin = new Vector2(58, 58); OptionsMenu = new MenuManager(); Button muteMusic = new Button(MuteUnchecked, MuteUnchecked, new Vector2(400, 130)); muteMusic.OnClick = MuteMusic; muteMusic.Tag = 0; //Button muteEffects = new Button(MuteEffectsUnchecked, MuteEffectsUnchecked, new Vector2(400, 170)); //muteEffects.OnClick = MuteEffects; //muteEffects.Tag = 0; //OptionsMenu.Buttons.Add(muteEffects); OptionsMenu.Buttons.Add(muteMusic); #endregion // TODO: use this.Content to load your game content here }
/// <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 Manager = new GameManger(); Menu = new MenuManager(); PauseMenu = new MenuManager(); SelectionState = SelectionState.Selection; GameState = GameState.MainMenu; Ai = new EasyAI(); SoundTracksEnabled = MediaPlayer.GameHasControl; base.Initialize(); }