protected override void Update(GameTime gameTime) { MouseState mouse = Mouse.GetState(); KeyboardState kstatee = Keyboard.GetState(); switch (CurrentGameState) { case GameState.Video: //if (vidPlayer.State == MediaState.Stopped) CurrentGameState = GameState.MainMenu; break; case GameState.MainMenu: if (buttonSP.isClicked == true) { spPlayer = new Player(Content, "Player1" ); CurrentGameState = GameState.SinglePlayer; screenwidth = spPlayer.level.Width * 32; screenheight = (spPlayer.level.Height + 1) * 32; graphics.PreferredBackBufferWidth = screenwidth; graphics.PreferredBackBufferHeight = screenheight; graphics.ApplyChanges(); } if (buttonMP.isClicked == true) { CurrentGameState = GameState.Multiplayer; splitbar = Content.Load<Texture2D>("Game/SplitBalken"); spPlayer = new Player(Content, "Player1"); //spPlayer nur zwecks Abmessungen screenwidth = spPlayer.level.Width * 32 * 2 +2 ; screenheight = (spPlayer.level.Height + 1) * 32; graphics.PreferredBackBufferWidth = screenwidth; graphics.PreferredBackBufferHeight = screenheight; graphics.ApplyChanges(); GraphicsDevice.Viewport = new Viewport(0, 0, screenwidth, screenheight); graphics.ApplyChanges(); mainViewport = GraphicsDevice.Viewport; leftViewport = mainViewport; rightViewport = mainViewport; leftViewport.Width = (leftViewport.Width / 2 ) -1; rightViewport.Width = (rightViewport.Width / 2)-1 ; rightViewport.X = leftViewport.Width +2; graphics.ApplyChanges(); } if (buttonHS.isClicked == true) { highscore = new HighScore(Content.Load<Texture2D>("MainMenu/Back"), graphics.GraphicsDevice); screenwidth = 300; screenheight = 300; graphics.PreferredBackBufferWidth = screenwidth; graphics.PreferredBackBufferHeight = screenheight; graphics.ApplyChanges(); CurrentGameState = GameState.HighScore; } if (buttonEX.isClicked == true) CurrentGameState = GameState.Exiting; buttonSP.Update(mouse); buttonMP.Update(mouse); buttonHS.Update(mouse); buttonEX.Update(mouse); break; case GameState.SinglePlayer: if (SignedInGamer.SignedInGamers[0].Gamertag != null && SignedInGamer.SignedInGamers[0].Gamertag != spPlayer.Name) spPlayer.Name = SignedInGamer.SignedInGamers[0].Gamertag; if (spPlayer.Lives <= 0 && spPlayer.Lives != -1) { spPlayer.Lost(); spPlayer.Lives = -1; } if(spPlayer.Lives > 0) spPlayer.Update(gameTime, true); break; case GameState.Multiplayer: if (!Guide.IsVisible) { foreach (SignedInGamer signedInGamer in SignedInGamer.SignedInGamers) { Player player = signedInGamer.Tag as Player; if (networkSession != null) { if (networkSession.SessionState == NetworkSessionState.Lobby) { HandleLobbyInput(); } else { if(player.Lives>0) HandleGameplayInput(player, gameTime); } } else if (availableSessions != null) { HandleAvailableSessionsInput(); } else { HandleTitleScreenInput(); } } } break; case GameState.HighScore: if (highscore.highscorebutton.isClicked == true) { SetMainMenuOptions(); } highscore.Update(mouse); break; case GameState.Exiting: this.Exit(); break; } if (kstatee.IsKeyDown(Keys.Escape)) { if (CurrentGameState == GameState.MainMenu) CurrentGameState = GameState.Exiting; else { SetMainMenuOptions(); } } base.Update(gameTime); }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); IsMouseVisible = true; spritefont = Content.Load<SpriteFont>("Arial"); spritefont2 = Content.Load<SpriteFont>("Arial2"); buttonSP = new MenuButton(Content.Load<Texture2D>("MainMenu/SPButton"), graphics.GraphicsDevice); buttonMP = new MenuButton(Content.Load<Texture2D>("MainMenu/MPButton"), graphics.GraphicsDevice); buttonHS = new MenuButton(Content.Load<Texture2D>("MainMenu/HSButton"), graphics.GraphicsDevice); buttonEX = new MenuButton(Content.Load<Texture2D>("MainMenu/EXButton"), graphics.GraphicsDevice); buttonSP.SetPosition(new Vector2(60, 120)); buttonMP.SetPosition(new Vector2(60, 180)); buttonHS.SetPosition(new Vector2(60, 240)); buttonEX.SetPosition(new Vector2(60, 300)); menubackground = Content.Load<Texture2D>("MainMenu/MenuBG"); menurec = new Rectangle(0, 0, screenwidth, screenheight); title = Content.Load<Texture2D>("MainMenu/Ueberschrift"); titlerec = new Rectangle(60, 20, title.Width, title.Height); hsbackground = Content.Load<Texture2D>("MainMenu/HSBG"); highscore = new HighScore(Content.Load<Texture2D>("MainMenu/Back"), graphics.GraphicsDevice); //spPlayer = new Player(Content, SignedInGamer.SignedInGamers[0].DisplayName); //spPlayer = new Player(Content, "Philo"); //vid = Content.Load<Video>("Intro"); //vidRect = new Rectangle(0, 0, screenwith, screenheight); //if(CurrentGameState == GameState.Video) //vidPlayer.Play(vid); }