/// <summary> /// Handles the input for the conversation box /// </summary> /// <param name="inputHelper">input helper</param> public override void HandleInput(InputHelper inputHelper) { base.HandleInput(inputHelper); // Moves the conversation index forward appropiately if (inputHelper.KeyPressed(Keys.Space) || inputHelper.ButtonPressed(1, Buttons.A)) { if (convIndex < textLines.Count - 1) { if (PreviousLineWasChoice) { if (marker.Position.Y == upperChoicePos.Y) { convIndex++; compensation = 2; } else if (marker.Position.Y == upperChoicePos.Y + choiceSeperation && convIndex < textLines.Count - 2) { convIndex += 2; compensation = 1; } else if (marker.Position.Y == bottomChoiceHeight && convIndex < textLines.Count - 3) { convIndex += 3; } } else if (!PreviousLineWasChoice) { convIndex++; } displayedText.Clear(); PreviousLineWasChoice = false; if (textLines[convIndex].StartsWith("#")) //a # signifies that there is a choice in the text file { marker.Visible = true; PreviousLineWasChoice = true; for (int i = 0; i < 3; i++) { TextGameObject currentText = new TextGameObject("Assets/Fonts/ConversationFont", 0, "currentlydisplayedtext") { Position = new Vector2(100, i * choiceSeperation + 80), Text = textLines[convIndex] }; displayedText.Add(currentText); if (convIndex < textLines.Count - 1 && i < 2) { convIndex += 1; } } } else { marker.Visible = false; TextGameObject currentText = new TextGameObject("Assets/Fonts/ConversationFont", 0, "currentlydisplayedtext") { Text = textLines[convIndex], Position = new Vector2(100, 114) }; displayedText.Add(currentText); } if (compensation > 0 && convIndex < textLines.Count - compensation) { convIndex += compensation; compensation = 0; } } else { convIndex = 0; // stops the conversation box from displaying itself and switches back to the playing state (GameEnvironment.GameStateManager.CurrentGameState as ConversationState).GoToNextConversation(); } } // Moves the marker up or down depending on the key that was pressed if (inputHelper.KeyPressed(Keys.Down) || inputHelper.ButtonPressed(1, Buttons.DPadDown)) { if (marker.Position.Y < bottomChoiceHeight) { marker.Position += new Vector2(0, choiceSeperation); } } if (inputHelper.KeyPressed(Keys.Up) || inputHelper.ButtonPressed(1, Buttons.DPadUp)) { if (marker.Position.Y > upperChoicePos.Y) { marker.Position -= new Vector2(0, choiceSeperation); } } }
public void Clear() { gameObjectList.Clear(); Assert.AreEqual(gameObjectList.Count, 0); }