/// <summary> /// Lets the game respond to player input. Unlike the Update method, /// this will only be called when the gameplay screen is active. /// </summary> public override void HandleInput() { if (InputManager.IsActionTriggered(InputManager.Action.MainMenu)) { ScreenManager.AddScreen(new MainMenuScreen()); return; } if (InputManager.IsActionTriggered(InputManager.Action.ExitGame)) { // add a confirmation message box const string message = "Are you sure you want to exit? All unsaved progress will be lost."; MessageBoxScreen confirmExitMessageBox = new MessageBoxScreen(message); confirmExitMessageBox.Accepted += ConfirmExitMessageBoxAccepted; ScreenManager.AddScreen(confirmExitMessageBox); return; } if (!CombatEngine.IsActive && InputManager.IsActionTriggered(InputManager.Action.CharacterManagement)) { ScreenManager.AddScreen(new StatisticsScreen(Session.Party.Players[0])); return; } }
/// <summary> /// Respond to the triggering of the X button (and related key). /// </summary> protected override void ButtonXPressed(ContentEntry <Gear> entry) { // check the parameter if ((entry == null) || (entry.Content == null)) { return; } // check whether the gear could be dropped if (!entry.Content.IsDroppable) { return; } // add a message box confirming the drop MessageBoxScreen dropEquipmentConfirmationScreen = new MessageBoxScreen("Are you sure you want to drop the " + entry.Content.Name + "?"); dropEquipmentConfirmationScreen.Accepted += new EventHandler <EventArgs>(delegate(object sender, EventArgs args) { Session.Party.RemoveFromInventory(entry.Content, 1); }); ScreenManager.AddScreen(dropEquipmentConfirmationScreen); }
/// <summary> /// When the user cancels the main menu, /// or when the Exit Game menu entry is selected. /// </summary> protected override void OnCancel() { // add a confirmation message box string message = String.Empty; if (Session.IsActive) { message = "Are you sure you want to exit? All unsaved progress will be lost."; } else { message = "Are you sure you want to exit?"; } MessageBoxScreen confirmExitMessageBox = new MessageBoxScreen(message); confirmExitMessageBox.Accepted += ConfirmExitMessageBoxAccepted; ScreenManager.AddScreen(confirmExitMessageBox); }
/// <summary> /// Lets the game respond to player input. Unlike the Update method, /// this will only be called when the gameplay screen is active. /// </summary> public override void HandleInput() { bool exitClicked = false; if (InputManager.ExitRect != null) exitClicked = InputManager.IsButtonClicked(InputManager.ExitRect); if (InputManager.IsActionTriggered(InputManager.Action.MainMenu) || exitClicked) { ScreenManager.AddScreen(new MainMenuScreen()); return; } if (InputManager.IsActionTriggered(InputManager.Action.ExitGame)) { // add a confirmation message box const string message = "Are you sure you want to exit? All unsaved progress will be lost."; MessageBoxScreen confirmExitMessageBox = new MessageBoxScreen(message); confirmExitMessageBox.Accepted += ConfirmExitMessageBoxAccepted; ScreenManager.AddScreen(confirmExitMessageBox); return; } if ((!CombatEngine.IsActive) && (InputManager.IsActionTriggered(InputManager.Action.CharacterManagement) || ( InputManager.IsButtonClicked(InputManager.StatsRect)))) { ScreenManager.AddScreen(new StatisticsScreen(Session.Party.Players[0])); return; } }
/// <summary> /// Respond to user input. /// </summary> public override void HandleInput() { // handle exiting the screen if (InputManager.IsActionTriggered(InputManager.Action.Back)) { ExitScreen(); return; } // handle selecting a save game if (InputManager.IsActionTriggered(InputManager.Action.Ok) && (Session.SaveGameDescriptions != null)) { switch (mode) { case SaveLoadScreenMode.Load: if ((currentSlot >= 0) && (currentSlot < Session.SaveGameDescriptions.Count) && (Session.SaveGameDescriptions[currentSlot] != null)) { if (Session.IsActive) { MessageBoxScreen messageBoxScreen = new MessageBoxScreen( "Are you sure you want to load this game?"); messageBoxScreen.Accepted += ConfirmLoadMessageBoxAccepted; ScreenManager.AddScreen(messageBoxScreen); } else { ConfirmLoadMessageBoxAccepted(null, EventArgs.Empty); } } break; case SaveLoadScreenMode.Save: if ((currentSlot >= 0) && (currentSlot <= Session.SaveGameDescriptions.Count)) { if (currentSlot == Session.SaveGameDescriptions.Count) { ConfirmSaveMessageBoxAccepted(null, EventArgs.Empty); } else { MessageBoxScreen messageBoxScreen = new MessageBoxScreen( "Are you sure you want to overwrite this save game?"); messageBoxScreen.Accepted += ConfirmSaveMessageBoxAccepted; ScreenManager.AddScreen(messageBoxScreen); } } break; } } // handle deletion else if (InputManager.IsActionTriggered(InputManager.Action.DropUnEquip) && (Session.SaveGameDescriptions != null)) { if ((currentSlot >= 0) && (currentSlot < Session.SaveGameDescriptions.Count) && (Session.SaveGameDescriptions[currentSlot] != null)) { MessageBoxScreen messageBoxScreen = new MessageBoxScreen( "Are you sure you want to delete this save game?"); messageBoxScreen.Accepted += ConfirmDeleteMessageBoxAccepted; ScreenManager.AddScreen(messageBoxScreen); } } // handle cursor-down else if (InputManager.IsActionTriggered(InputManager.Action.CursorDown) && (Session.SaveGameDescriptions != null)) { int maximumSlot = Session.SaveGameDescriptions.Count; if (mode == SaveLoadScreenMode.Save) { maximumSlot = Math.Min(maximumSlot + 1, Session.MaximumSaveGameDescriptions); } if (currentSlot < maximumSlot - 1) { currentSlot++; } } // handle cursor-up else if (InputManager.IsActionTriggered(InputManager.Action.CursorUp) && (Session.SaveGameDescriptions != null)) { if (currentSlot >= 1) { currentSlot--; } } }
/// <summary> /// Respond to user input. /// </summary> public override void HandleInput() { bool backClicked = false; bool selectClicked = false; bool deleteClicked = false; foreach (var item in ItemPositionMapping) { if (InputManager.IsButtonClicked(item.Key)) { currentSlot = item.Value; break; } } if (InputManager.IsButtonClicked(new Rectangle ((int)(backPosition.X ), (int)backPosition.Y, (int)(backTexture.Width * ScaledVector2.DrawFactor), (int)(backTexture.Height * ScaledVector2.DrawFactor)))) { backClicked = true; } if (InputManager.IsButtonClicked(new Rectangle ((int)selectPosition.X, (int)selectPosition.Y, (int)(selectTexture.Width * ScaledVector2.DrawFactor), (int)(selectTexture.Height * ScaledVector2.DrawFactor)))) { selectClicked = true; } if (InputManager.IsButtonClicked(new Rectangle ((int)deletePosition.X , (int)deletePosition.Y, (int)(deleteTexture.Width * ScaledVector2.DrawFactor), (int)(deleteTexture.Height * ScaledVector2.DrawFactor)))) { deleteClicked = true; } // handle exiting the screen if (InputManager.IsActionTriggered(InputManager.Action.Back) || backClicked) { ExitScreen(); return; } // handle selecting a save game if (selectClicked && (Session.SaveGameDescriptions != null)) { switch (mode) { case SaveLoadScreenMode.Load: if ((currentSlot >= 0) && (currentSlot < Session.SaveGameDescriptions.Count) && (Session.SaveGameDescriptions[currentSlot] != null)) { if (Session.IsActive) { MessageBoxScreen messageBoxScreen = new MessageBoxScreen( "Are you sure you want to load this game?"); messageBoxScreen.Accepted += ConfirmLoadMessageBoxAccepted; ScreenManager.AddScreen(messageBoxScreen); } else { ConfirmLoadMessageBoxAccepted(null, EventArgs.Empty); } } break; case SaveLoadScreenMode.Save: if ((currentSlot >= 0) && (currentSlot <= Session.SaveGameDescriptions.Count)) { if (currentSlot == Session.SaveGameDescriptions.Count) { ConfirmSaveMessageBoxAccepted(null, EventArgs.Empty); } else { MessageBoxScreen messageBoxScreen = new MessageBoxScreen( "Are you sure you want to overwrite this save game?"); messageBoxScreen.Accepted += ConfirmSaveMessageBoxAccepted; ScreenManager.AddScreen(messageBoxScreen); } } break; } } // handle deletion else if (InputManager.IsActionTriggered(InputManager.Action.DropUnEquip) || deleteClicked && (Session.SaveGameDescriptions != null)) { if ((currentSlot >= 0) && (currentSlot < Session.SaveGameDescriptions.Count) && (Session.SaveGameDescriptions[currentSlot] != null)) { MessageBoxScreen messageBoxScreen = new MessageBoxScreen( "Are you sure you want to delete this save game?"); messageBoxScreen.Accepted += ConfirmDeleteMessageBoxAccepted; ScreenManager.AddScreen(messageBoxScreen); } } // handle cursor-down else if (InputManager.IsActionTriggered(InputManager.Action.CursorDown) && (Session.SaveGameDescriptions != null)) { int maximumSlot = Session.SaveGameDescriptions.Count; if (mode == SaveLoadScreenMode.Save) { maximumSlot = Math.Min(maximumSlot + 1, Session.MaximumSaveGameDescriptions); } if (currentSlot < maximumSlot - 1) { currentSlot++; } } // handle cursor-up else if (InputManager.IsActionTriggered(InputManager.Action.CursorUp) && (Session.SaveGameDescriptions != null)) { if (currentSlot >= 1) { currentSlot--; } } }
/// <summary> /// Respond to user input. /// </summary> public override void HandleInput() { bool backClicked = false; bool selectClicked = false; bool deleteClicked = false; foreach (var item in ItemPositionMapping) { if (InputManager.IsButtonClicked(item.Key)) { currentSlot = item.Value; break; } } if (InputManager.IsButtonClicked(new Rectangle ((int)(backPosition.X), (int)backPosition.Y, (int)(backTexture.Width * ScaledVector2.DrawFactor), (int)(backTexture.Height * ScaledVector2.DrawFactor)))) { backClicked = true; } if (InputManager.IsButtonClicked(new Rectangle ((int)selectPosition.X, (int)selectPosition.Y, (int)(selectTexture.Width * ScaledVector2.DrawFactor), (int)(selectTexture.Height * ScaledVector2.DrawFactor)))) { selectClicked = true; } if (InputManager.IsButtonClicked(new Rectangle ((int)deletePosition.X, (int)deletePosition.Y, (int)(deleteTexture.Width * ScaledVector2.DrawFactor), (int)(deleteTexture.Height * ScaledVector2.DrawFactor)))) { deleteClicked = true; } // handle exiting the screen if (InputManager.IsActionTriggered(InputManager.Action.Back) || backClicked) { ExitScreen(); return; } // handle selecting a save game if (selectClicked && (Session.SaveGameDescriptions != null)) { switch (mode) { case SaveLoadScreenMode.Load: if ((currentSlot >= 0) && (currentSlot < Session.SaveGameDescriptions.Count) && (Session.SaveGameDescriptions[currentSlot] != null)) { if (Session.IsActive) { MessageBoxScreen messageBoxScreen = new MessageBoxScreen( "Are you sure you want to load this game?"); messageBoxScreen.Accepted += ConfirmLoadMessageBoxAccepted; ScreenManager.AddScreen(messageBoxScreen); } else { ConfirmLoadMessageBoxAccepted(null, EventArgs.Empty); } } break; case SaveLoadScreenMode.Save: if ((currentSlot >= 0) && (currentSlot <= Session.SaveGameDescriptions.Count)) { if (currentSlot == Session.SaveGameDescriptions.Count) { ConfirmSaveMessageBoxAccepted(null, EventArgs.Empty); } else { MessageBoxScreen messageBoxScreen = new MessageBoxScreen( "Are you sure you want to overwrite this save game?"); messageBoxScreen.Accepted += ConfirmSaveMessageBoxAccepted; ScreenManager.AddScreen(messageBoxScreen); } } break; } } // handle deletion else if (InputManager.IsActionTriggered(InputManager.Action.DropUnEquip) || deleteClicked && (Session.SaveGameDescriptions != null)) { if ((currentSlot >= 0) && (currentSlot < Session.SaveGameDescriptions.Count) && (Session.SaveGameDescriptions[currentSlot] != null)) { MessageBoxScreen messageBoxScreen = new MessageBoxScreen( "Are you sure you want to delete this save game?"); messageBoxScreen.Accepted += ConfirmDeleteMessageBoxAccepted; ScreenManager.AddScreen(messageBoxScreen); } } // handle cursor-down else if (InputManager.IsActionTriggered(InputManager.Action.CursorDown) && (Session.SaveGameDescriptions != null)) { int maximumSlot = Session.SaveGameDescriptions.Count; if (mode == SaveLoadScreenMode.Save) { maximumSlot = Math.Min(maximumSlot + 1, Session.MaximumSaveGameDescriptions); } if (currentSlot < maximumSlot - 1) { currentSlot++; } } // handle cursor-up else if (InputManager.IsActionTriggered(InputManager.Action.CursorUp) && (Session.SaveGameDescriptions != null)) { if (currentSlot >= 1) { currentSlot--; } } }
/// <summary> /// Respond to user input. /// </summary> public override void HandleInput() { bool okClicked = IsTextureClicked(selectTexture, selectPosition); bool backClicked = IsTextureClicked(backTexture, backPosition); // handle exiting the screen if (InputManager.IsActionTriggered(InputManager.Action.Back) || backClicked) { ExitScreen(); return; } bool lineClicked = false; if (InputManager.MouseMoved()) { if ((Session.SaveGameDescriptions != null)) { for (int i = 0; i < ((mode == SaveLoadScreenMode.Load) ? Session.SaveGameDescriptions.Count : Session.SaveGameDescriptions.Count+1); i++) { Rectangle rect = new Rectangle(295,(int)(180f + i * (Fonts.GearInfoFont.LineSpacing + 30f)),600,(int)(i * Fonts.GearInfoFont.LineSpacing + 40f)); if (InputManager.IsButtonClicked(rect)) { lineClicked=true; } if (InputManager.IsButtonHovered(rect)) { currentSlot = i; break; } } } } // handle selecting a save game if ((InputManager.IsActionTriggered(InputManager.Action.Ok) || okClicked || lineClicked) && (Session.SaveGameDescriptions != null)) { switch (mode) { case SaveLoadScreenMode.Load: if ((currentSlot >= 0) && (currentSlot < Session.SaveGameDescriptions.Count) && (Session.SaveGameDescriptions[currentSlot] != null)) { if (Session.IsActive) { MessageBoxScreen messageBoxScreen = new MessageBoxScreen( "Are you sure you want to load this game?"); messageBoxScreen.Accepted += ConfirmLoadMessageBoxAccepted; ScreenManager.AddScreen(messageBoxScreen); } else { ConfirmLoadMessageBoxAccepted(null, EventArgs.Empty); } } break; case SaveLoadScreenMode.Save: if ((currentSlot >= 0) && (currentSlot <= Session.SaveGameDescriptions.Count)) { if (currentSlot == Session.SaveGameDescriptions.Count) { ConfirmSaveMessageBoxAccepted(null, EventArgs.Empty); } else { MessageBoxScreen messageBoxScreen = new MessageBoxScreen( "Are you sure you want to overwrite this save game?"); messageBoxScreen.Accepted += ConfirmSaveMessageBoxAccepted; ScreenManager.AddScreen(messageBoxScreen); } } break; } } // handle deletion else if (InputManager.IsActionTriggered(InputManager.Action.DropUnEquip) && (Session.SaveGameDescriptions != null)) { if ((currentSlot >= 0) && (currentSlot < Session.SaveGameDescriptions.Count) && (Session.SaveGameDescriptions[currentSlot] != null)) { MessageBoxScreen messageBoxScreen = new MessageBoxScreen( "Are you sure you want to delete this save game?"); messageBoxScreen.Accepted += ConfirmDeleteMessageBoxAccepted; ScreenManager.AddScreen(messageBoxScreen); } } // handle cursor-down else if (InputManager.IsActionTriggered(InputManager.Action.CursorDown) && (Session.SaveGameDescriptions != null)) { int maximumSlot = Session.SaveGameDescriptions.Count; if (mode == SaveLoadScreenMode.Save) { maximumSlot = Math.Min(maximumSlot + 1, Session.MaximumSaveGameDescriptions); } if (currentSlot < maximumSlot - 1) { currentSlot++; } } // handle cursor-up else if (InputManager.IsActionTriggered(InputManager.Action.CursorUp) && (Session.SaveGameDescriptions != null)) { if (currentSlot >= 1) { currentSlot--; } } }
/// <summary> /// Lets the game respond to player input. Unlike the Update method, /// this will only be called when the gameplay screen is active. /// </summary> public override void HandleInput() { if (InputManager.IsActionTriggered(InputManager.Action.MainMenu)) { ScreenManager.AddScreen(new MainMenuScreen()); return; } if (InputManager.IsActionTriggered(InputManager.Action.ExitGame)) { // add a confirmation message box const string message = ""; MessageBoxScreen confirmExitMessageBox = new MessageBoxScreen(message); confirmExitMessageBox.Accepted += ConfirmExitMessageBoxAccepted; ScreenManager.AddScreen(confirmExitMessageBox); return; } if (!CombatEngine.IsActive && InputManager.IsActionTriggered(InputManager.Action.CharacterManagement)) { ScreenManager.AddScreen(new StatisticsScreen(Session.Party.Players[0])); return; } }