public void Reset(GameEngine gameEngine, MainCharacter mainCharacter, ContentManager content) { // Commmon to all Modes MainCharacter = mainCharacter; Content = content; Background = new Background(content, NotebookPath); MouseState = Mouse.GetState(); PrevMouseState = MouseState; GState = NotebookState.Stats; Arial = content.Load <SpriteFont>("Fonts/Arial"); JustBreathe = content.Load <SpriteFont>("Fonts/JustBreathe20"); JustBreathe25 = content.Load <SpriteFont>("Fonts/JustBreathe25"); // Load Characters (convert to method) String path = Path.Combine(Content.RootDirectory, "characters.txt"); String CharJSON = File.ReadAllText(path); AllChars = JsonSerializer.Deserialize <AllCharacters>(CharJSON); // Load Case (convert to method) String CasePath = Path.Combine(Content.RootDirectory, "case" + MainCharacter.CurrentCase + ".txt"); String CaseJSON = File.ReadAllText(CasePath); Case = JsonSerializer.Deserialize <Case>(CaseJSON); // Load Testimonies (convert to method) path = Path.Combine(Content.RootDirectory, "testimonies.txt"); String TestimonyJSON = File.ReadAllText(path); TestimonyList = JsonSerializer.Deserialize <TestimonyList>(TestimonyJSON); // Always start by viewing stats. Point WindowSize = Game1.GetWindowSize(); // Fixed Visual Elements ReturnIcon = Content.Load <Texture2D>("return-icon"); ReturnIconRect = new Rectangle(WindowSize.X - 100, 20, 70, 70); int TabOffset = WindowSize.X / 10 - 8; PeopleTab = new ClickableTexture(Content.Load <Texture2D>("tab_people"), new Vector2(TabOffset, TabOffset)); StatsTab = new ClickableTexture(Content.Load <Texture2D>("tab_stats"), new Vector2(TabOffset, PeopleTab.Rect.Y + PeopleTab.Rect.Height)); TestimonyTab = new ClickableTexture(Content.Load <Texture2D>("tab_testimony"), new Vector2(TabOffset, StatsTab.Rect.Y + StatsTab.Rect.Height)); OptionsTab = new ClickableTexture(Content.Load <Texture2D>("tab_options"), new Vector2(TabOffset, TestimonyTab.Rect.Y + TestimonyTab.Rect.Height)); // Variable Visual Elements MainOptionsList = null; TopicOptionsList = null; QuitButton = null; SaveButton = null; // Text Spacing TextOffset = new Vector2(0.0f, JustBreathe.MeasureString("A").Y + 0.5f); Indent = new Vector2(Arial.MeasureString("A").X, 0.0f); // Represents bounds of open notebook OpenNotebookRect = new Rectangle((int)(0.12f * WindowSize.X), (int)(0.15f * WindowSize.Y + TextOffset.Y), (int)(0.75f * WindowSize.X), (int)(0.71f * WindowSize.Y)); }
private void MouseClicked(MouseState mouseState) { Point MouseClick = new Point(mouseState.X, mouseState.Y); Rectangle MouseClickRect = new Rectangle(MouseClick, new Point(10, 10)); switch (GState) { case NotebookState.SelectedTestimony: if (ConfirmContradictMenu.IsConfirming(MouseClickRect)) { GState = NotebookState.Returning; } if (ConfirmContradictMenu.IsCancelling(MouseClickRect)) { GState = NotebookState.Testimonies; } break; case NotebookState.ClickedQuitGame: if (ConfirmQuitMenu.IsConfirming(MouseClickRect)) { GState = NotebookState.ConfirmedQuitGame; } if (ConfirmQuitMenu.IsCancelling(MouseClickRect)) { GState = NotebookState.Options; // replace with whichever state exposes the quit button } break; default: if (MouseClickRect.Intersects(StatsTab.Rect)) { GState = NotebookState.Stats; MainOptionsList = null; TopicOptionsList = null; } if (MouseClickRect.Intersects(PeopleTab.Rect)) { GState = NotebookState.Profiles; MainOptionsList = null; TopicOptionsList = null; } if (MouseClickRect.Intersects(OptionsTab.Rect)) { GState = NotebookState.Options; MainOptionsList = null; TopicOptionsList = null; } if (MouseClickRect.Intersects(TestimonyTab.Rect)) { GState = NotebookState.Testimonies; MainOptionsList = null; TopicOptionsList = null; } if (MouseClickRect.Intersects(ReturnIconRect)) { GState = NotebookState.Returning; } if (MainOptionsList?.SelectedOption == "savequit") { if (QuitButton != null && MouseClickRect.Intersects(QuitButton.Rect)) { GState = NotebookState.ClickedQuitGame; string Query = "Are you sure you want to quit the game?"; ConfirmQuitMenu = new ConfirmMenu(Query, Content, Arial); } if (SaveButton != null && MouseClickRect.Intersects(SaveButton.Rect)) { SaveGame(); } } if (SeekingTestimony && SelectTestimonyButton != null) { if (MouseClickRect.Intersects(SelectTestimonyButton.Rect)) { GState = NotebookState.SelectedTestimony; string Query = "Are you sure you want to contradict?"; ConfirmContradictMenu = new ConfirmMenu(Query, Content, Arial); } } break; } }