/// <summary> /// Update menu/title screen (buttons) /// </summary> /// <param name="gameTime"></param> public void Update(GameTime gameTime) { this.fadeInOut -= 0.05f; if (this.fadeInOut < 0) { this.fadeInOut = 0f; } #region Titlescreen if (mode == MenuMode.Titlescreen) { if (startPressed == false) { startPressAlpha += startPressAlphaDelta; if (startPressAlpha > 1f || startPressAlpha < 0f) startPressAlphaDelta = -startPressAlphaDelta; //Wait for a player to press start if (deviceOkP1 == false) { for (PlayerIndex index = PlayerIndex.One; index <= PlayerIndex.Four; index++) { if (GamePad.GetState(index).Buttons.Start == ButtonState.Pressed) { //It will become Player 1 player1device = new Device(DeviceType.Gamepad, (int)index); deviceOkP1 = true; break; } } } else { if (TGPAContext.Instance.Player1 == null) { if (deviceOkP1) { //Ask for sign in if (Device.DeviceHasProfile(player1device) == false) { if (Guide.IsVisible == false) { signInRequested = true; Guide.ShowSignIn(1, false); } else { if (signInRequested) { signInRequested = false; deviceOkP1 = false; player1device = null; } } } else { TGPAContext.Instance.Player1 = new Player(PlayerIndex.One, player1device); #if XBOX TGPAContext.Instance.Player1.Name = TGPAContext.Instance.Player1.XboxProfile.Gamertag; #endif } } } else { //Assign eventually a new controller for P1 if (deviceOkP1) { TGPAContext.Instance.Player1.Device = player1device; } startPressed = true; } } } else { if (TGPAContext.Instance.Player1 == null) throw new Exception("No player WTF"); if (TGPAContext.Instance.InputManager.PlayerPressButtonBack(TGPAContext.Instance.Player1)) { TGPAContext.Instance.CurrentGameState = GameState.Credits; } else { //Buy from title screen if (TGPAContext.Instance.IsTrialMode) { if (TGPAContext.Instance.InputManager.PlayerPressYButton(TGPAContext.Instance.Player1)) { if (Guide.IsVisible == false) { //Player need rights SignedInGamer xboxProfile = Device.DeviceProfile(TGPAContext.Instance.Player1.Device); if (xboxProfile.Privileges.AllowPurchaseContent) { Guide.ShowMarketplace((PlayerIndex)TGPAContext.Instance.Player1.Device.Index); } else { Guide.BeginShowMessageBox(LocalizedStrings.GetString("BuyFailTitle"), LocalizedStrings.GetString("BuyFailContent"), new List<string> { "OK" }, 0, MessageBoxIcon.Warning, null, null); } } } } } KeyboardState keyboard = Keyboard.GetState(); //Mouse and menus Rectangle startRect = new Rectangle( StartButton.X, StartButton.Y, StartButton.X + StartButton.Width, StartButton.Y + StartButton.Height); Rectangle optionsRect = new Rectangle( OptionsButton.X, OptionsButton.Y, OptionsButton.X + OptionsButton.Width, OptionsButton.Y + OptionsButton.Height); Rectangle exitRect = new Rectangle( QuitButton.X, QuitButton.Y, QuitButton.X + QuitButton.Width, QuitButton.Y + QuitButton.Height); //PC Management #region Mouse input if (TGPAContext.Instance.Player1.IsPlayingOnWindows() && TGPAContext.Instance.IsActive) { if (buttonGoDst.Contains(TGPAContext.Instance.MousePoint)) { Focus = MenuButtons.Play; if (TGPAContext.Instance.InputManager.PlayerPressButtonConfirm(TGPAContext.Instance.Player1)) TGPAContext.Instance.CurrentGameState = GameState.LevelSelectionScreen; } else if (buttonOptionsDst.Contains(TGPAContext.Instance.MousePoint)) { Focus = MenuButtons.Options; if (TGPAContext.Instance.InputManager.PlayerPressButtonConfirm(TGPAContext.Instance.Player1)) { changeModeAfterAlphaBlending(MenuMode.Options); InitializeOptionsValues(false); } } else if (buttonExitDst.Contains(TGPAContext.Instance.MousePoint)) { Focus = MenuButtons.Exit; if ((InputManager.IsClic(previousMouseState, Mouse.GetState())) || (TGPAContext.Instance.InputManager.PlayerPressButtonConfirm(TGPAContext.Instance.Player1))) TGPAContext.Instance.CurrentGameState = GameState.Exit; } else { Focus = MenuButtons.None; } } #endregion switch (focus) { case MenuButtons.Play: if ((TGPAContext.Instance.InputManager.PlayerPressButtonConfirm(TGPAContext.Instance.Player1))) TGPAContext.Instance.CurrentGameState = GameState.LevelSelectionScreen; if (TGPAContext.Instance.InputManager.PlayerPressDown(TGPAContext.Instance.Player1)) focus = MenuButtons.Options; if (TGPAContext.Instance.InputManager.PlayerPressUp(TGPAContext.Instance.Player1)) focus = MenuButtons.Exit; break; case MenuButtons.Options: if ((TGPAContext.Instance.InputManager.PlayerPressButtonConfirm(TGPAContext.Instance.Player1))) { changeModeAfterAlphaBlending(MenuMode.Options); InitializeOptionsValues(false); } if (TGPAContext.Instance.InputManager.PlayerPressDown(TGPAContext.Instance.Player1)) focus = MenuButtons.Exit; if (TGPAContext.Instance.InputManager.PlayerPressUp(TGPAContext.Instance.Player1)) focus = MenuButtons.Play; break; case MenuButtons.Exit: if ((TGPAContext.Instance.InputManager.PlayerPressButtonConfirm(TGPAContext.Instance.Player1))) TGPAContext.Instance.CurrentGameState = GameState.Exit; if (TGPAContext.Instance.InputManager.PlayerPressDown(TGPAContext.Instance.Player1)) focus = MenuButtons.Play; if (TGPAContext.Instance.InputManager.PlayerPressUp(TGPAContext.Instance.Player1)) focus = MenuButtons.Options; break; #if XBOX case MenuButtons.None: focus = MenuButtons.Play; break; #endif } previousMouseState = Mouse.GetState(); } } #endregion #region Option screen else if (mode == MenuMode.Options) { this.optionsSection.Update(gameTime); //Set focus if (TGPAContext.Instance.Player1.IsPlayingOnWindows() == false) { #region Pad Management TGPAControl control = null; if (TGPAContext.Instance.InputManager.PlayerPressDown(TGPAContext.Instance.Player1)) { if (optionsSection.CurrentLine + 1 < optionsSection.Lines) { control = optionsSection.GetControl(optionsSection.CurrentLine + 1, optionsSection.CurrentColumn); } if (control == null) { control = optionsSection.GetControl(0, optionsSection.CurrentColumn); } if (control != null) { optionsSection.UnsetFocus(); optionsSection.SetFocus(control); } } else if (TGPAContext.Instance.InputManager.PlayerPressUp(TGPAContext.Instance.Player1)) { if (optionsSection.CurrentLine - 1 < optionsSection.Lines) { control = optionsSection.GetControl(optionsSection.CurrentLine - 1, optionsSection.CurrentColumn); } if (control == null) { control = optionsSection.GetControl(optionsSection.Lines - 1, optionsSection.CurrentColumn); } if (control != null) { optionsSection.UnsetFocus(); optionsSection.SetFocus(control); } } #endregion } #if WINDOWS else { bool leave = false; for (int i = 0; i < optionsSection.Lines; i++) { for (int j = 0; j < optionsSection.Columns; j++) { TGPAControl control = optionsSection.GetControl(i, j); if (control != null) { if (control.DstRect.Intersects(TGPAContext.Instance.MouseDst)) { if (control != optionsSection.FocusedControl) { optionsSection.UnsetFocus(); optionsSection.SetFocus(control); } leave = true; break; } } if (leave) break; //As beautiful as a GOTO } if (leave) break; } } if (TGPAContext.Instance.MouseDst.Intersects(buttonOptionsBackDst)) { buttonOptionsBackSrc.Y = 50; bool exit = TGPAContext.Instance.InputManager.PlayerPressButtonConfirm(TGPAContext.Instance.Player1); if (exit) { changeModeAfterAlphaBlending(MenuMode.Titlescreen); TGPAContext.Instance.Saver.Save(); } } else { buttonOptionsBackSrc.Y = 0; } #endif if (TGPAContext.Instance.InputManager.PlayerPressButtonBack(TGPAContext.Instance.Player1)) { changeModeAfterAlphaBlending(MenuMode.Titlescreen); TGPAContext.Instance.Saver.Save(); } } #endregion #region Animation stuffTimer += gameTime.ElapsedGameTime.Milliseconds; //Update stuff List<FlyingStuff> fsToDelete = new List<FlyingStuff>(); foreach (FlyingStuff fs in flyingStuff) { fs.Update(gameTime); if (fs.KillMe) { fsToDelete.Add(fs); } } foreach (FlyingStuff deadfs in fsToDelete) { flyingStuff.Remove(deadfs); } if (stuffTimer - stuffCooldown > 0f) { flyingStuff.Add(new FlyingStuff()); stuffTimer = 0f; stuffCooldown = RandomMachine.GetRandomFloat(750, 6000); } for (int i = 0; i < 2; i++) { Vector2 loc = new Vector2(610, 625); loc.X += RandomMachine.GetRandomInt(-35, 35); loc.Y += RandomMachine.GetRandomInt(-35, 35); loc.Y = (loc.Y / 768) * TGPAContext.Instance.ScreenHeight; Smoke s = new Smoke(loc, RandomMachine.GetRandomVector2(30f, 150f, -40f, -120f), 0.03f, 0.04f, 0.14f, 1, 1f, RandomMachine.GetRandomInt(0, 4)); pmanager.AddParticle(s, true); } //anim elapsed += gameTime.ElapsedGameTime.Milliseconds; if (elapsed > time) { anim = (anim == 0) ? 1 : 0; foreSrc.Y = anim * 440; elapsed = 0; time = 200 + (float)(RandomMachine.GetRandomFloat(-100, 300)); } pmanager.UpdateParticles((float)gameTime.ElapsedGameTime.TotalSeconds); #endregion this.magicAlpha -= magicAlphaDelta; if (this.magicAlpha < 0) { this.magicAlpha = 0f; this.magicAlphaDelta = -magicAlphaDelta; //Change mode if (nextMode != mode) { mode = nextMode; } } if (this.magicAlpha > 1) { this.magicAlpha = 1f; } }
public override void Update(GameTime gameTime) { if (this.Lives >= 0) { int direction = flips == SpriteEffects.FlipHorizontally ? -1 : 1; if (DeathTime > 0.0f) { DeathTime -= gameTime.ElapsedGameTime.TotalSeconds; } frame++; base.Update(gameTime); UpdateRumbles(gameTime); //Reactor fire effects if (DeathTime <= 0) { Vector2 tloc = location; tloc.Y += DstRect.Height - 40; if (direction < 0) { tloc.X += (dRect.Width - 40); } else { tloc.X += 40; } switch (Index) { case PlayerIndex.One: if (TGPAContext.Instance.Cheatcodes.IsKawaii) { HeartWave kawai = new HeartWave(tloc, RandomMachine.GetRandomVector2(-300f * direction, -150f * direction, -40f, 40f), 1f, RandomMachine.GetRandomInt(0, 4)); TGPAContext.Instance.ParticleManager.AddParticle(kawai, true); } else { //Fire from engine Smoke s = new Smoke(tloc, RandomMachine.GetRandomVector2(-300f * direction, -150f * direction, -20f, 20f), 1, 1, 1, 1, 1f, RandomMachine.GetRandomInt(0, 4)); TGPAContext.Instance.ParticleManager.AddParticle(s, true); } break; case PlayerIndex.Two: //Girly hearts !!! HeartWave kawai2 = new HeartWave(tloc, RandomMachine.GetRandomVector2(-300f * direction, -150f * direction, -40f, 40f), 1f, RandomMachine.GetRandomInt(0, 4)); TGPAContext.Instance.ParticleManager.AddParticle(kawai2, true); break; } } } }