public PuzzleGameState() { Puzzles = new List <Puzzle>(); for (int i = 0; i < 30; i++) { Puzzles.Add(new Puzzle { Locked = true, PuzzleNumber = i + 1, BoardInfo = PuzzleBoardInfo.Deserialize("13;3;7;3|3|2|0;5|3|2|0;5|3|2|0;7|1|1|3") }); } Puzzles[0].Locked = false; }
public static string Serialize(PuzzleBoardInfo board) { var sb = new StringBuilder(); sb.Append(string.Format("{0};{1};", board.Goal.GoalIndex(), board.NumberOfMoves)); foreach (PuzzleBoardInfoSquare puzzleBoardInfoSquare in board.Squares) { sb.Append(puzzleBoardInfoSquare.Serialize() + ";"); } return(sb.ToString()); }
public static PuzzleBoardInfo Deserialize(string board) { var p = new PuzzleBoardInfo(null /*todo*/); string[] sps = board.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); p.Goal = new Goal(); p.Goal.SetGoalIndex(int.Parse(sps[0])); p.NumberOfMoves = int.Parse(sps[1]); p.Squares = new List <PuzzleBoardInfoSquare>(); for (int i = 3; i < sps.Length; i++) { p.Squares.Add(PuzzleBoardInfoSquare.Deserialize(sps[i])); } return(p); }