public override void Update() { if (timer > 0 && (state != TextReaderState.WritingLine || (!Controls.A.IsPressed() && !Controls.B.IsPressed()))) { timer -= 1; } else { switch (state) { case TextReaderState.WritingLine: char c = wrappedString.Lines[currentLine][currentChar].Char; bool isLetter = (c != ' '); if (AudioSystem.IsSoundPlaying(GameData.SOUND_TEXT_CONTINUE)) { wordIndex = 0; } else { if (isLetter && (wordIndex % 2) == 0) { AudioSystem.PlaySound(GameData.SOUND_TEXT_LETTER); } if (isLetter) { wordIndex++; } } currentChar++; if (Controls.A.IsPressed() || Controls.B.IsPressed()) { currentChar = wrappedString.Lines[currentLine].Length; } if (currentChar >= wrappedString.Lines[currentLine].Length) { windowLinesLeft--; if (currentLine + 1 == wrappedString.NumLines) { state = TextReaderState.Finished; } else if (wrappedString.Lines[currentLine].EndsWith(FormatCodes.ParagraphCharacter)) { state = TextReaderState.PressToEndParagraph; arrowTimer = 0; } else if (windowLinesLeft == 0) { state = TextReaderState.PressToContinue; arrowTimer = 0; } else if (windowLine + 1 < linesPerWindow) { windowLine++; currentLine++; currentChar = 0; } else { currentLine++; currentChar = 0; state = TextReaderState.PushingLine; timer = 4; } } else { timer = 1; } break; case TextReaderState.PushingLine: state = TextReaderState.WritingLine; break; case TextReaderState.PressToContinue: arrowTimer++; if (arrowTimer == 32) { arrowTimer = 0; } if (Controls.A.IsPressed() || Controls.B.IsPressed()) { state = TextReaderState.PushingLine; timer = 4; windowLinesLeft = linesPerWindow; currentChar = 0; currentLine++; AudioSystem.PlaySound(GameData.SOUND_TEXT_CONTINUE); } break; case TextReaderState.PressToEndParagraph: arrowTimer++; if (arrowTimer == 32) { arrowTimer = 0; } if (Controls.A.IsPressed() || Controls.B.IsPressed()) { state = TextReaderState.WritingLine; windowLinesLeft = linesPerWindow; currentChar = 0; windowLine = 0; currentLine++; } break; case TextReaderState.Finished: // TODO: Switch to any key if (Controls.A.IsPressed() || Controls.B.IsPressed() || Controls.Start.IsPressed() || Controls.Select.IsPressed()) { End(); } break; } } }