//----------------------------------------------------------------------------- // Overridden methods //----------------------------------------------------------------------------- public override void OnBegin() { timer = 1; state = TextReaderState.WritingLine; windowLinesLeft = linesPerWindow; wordIndex = 0; }
//----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- // Constructs a text reader with the specified message public RoomStateTextReader(Message message, int linesPerWindow = 2) { this.updateRoom = false; this.animateRoom = true; this.message = message; this.wrappedString = GameData.FONT_LARGE.WrapString(message.Text, 128); this.timer = 0; this.arrowTimer = 0; this.linesPerWindow = linesPerWindow; this.windowLinesLeft = this.linesPerWindow; this.windowLine = 0; this.currentLine = 0; this.currentChar = 0; this.state = TextReaderState.WritingLine; }
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; } } }
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; } } }
public override void Update() { if (timer > 0 && (state != TextReaderState.WritingLine || (!Controls.A.IsPressed() && !Controls.B.IsPressed()))) { timer -= 1; } else { switch (state) { case TextReaderState.WritingLine: 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++; } 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; } } }