public static MemoScene ParseScene(IReadOnlyList <string> lines) { var scene = new MemoScene(); Debug.Assert(lines.Count == 4); Debug.Assert(lines.All(l => l.Length >= 4)); for (var row = 0; row < 4; row++) { for (var col = 0; col < 4; col++) { var c = lines[row][col]; Debug.Assert(AllValidCharset.Contains(c)); foreach (var charset in AllNumberCharsets) { var index = charset.IndexOf(c); if (index >= 0) { scene[row, col] = new MemoNote { Type = MemoNote.NoteType.Click, Ordinal = index + 1 }; break; } } } } for (var row = 0; row < 4; row++) { for (var col = 0; col < 4; col++) { var direction = GetDirection(lines[row][col]); if (direction != MemoNote.Direction.Undefined) { SetHoldNote(scene, row, col, direction); } } } return(scene); }
private static void SetHoldNote(MemoScene scene, int row, int col, MemoNote.Direction direction) { var rowOffset = RowOffset[direction]; var colOffset = ColOffset[direction]; for (var span = 1;; span++) { row += rowOffset; col += colOffset; if (scene[row, col].Type == MemoNote.NoteType.Click) { scene[row, col] = new MemoNote { Type = MemoNote.NoteType.Hold, Ordinal = scene[row, col].Ordinal, HoldSpan = span, HoldDirection = direction }; break; } } }
public static char NoteToChar(MemoNote note) { return(NoteCharset[note.Ordinal]); }