public List <TileV> LoadBooks(List <TileV> tiles, TileVBuilder builder) { StreamReader reader = new StreamReader(_bofname); if (reader != null) { string line = reader.ReadLine(); int pageno, x, y, special; string storytitle; string[] array; Storybook book; Storypage page; List <Storypage> pages; TileV tile; while (line != null) { array = line.Split('|'); pageno = Convert.ToInt32(array[0]); special = Convert.ToInt32(array[1]); array = reader.ReadLine().Split('|'); x = Convert.ToInt32(array[0]); y = Convert.ToInt32(array[1]); storytitle = reader.ReadLine(); pages = new List <Storypage>(); for (int i = 0; i < pageno; i++) { array = reader.ReadLine().Split('|'); page = new Storypage(array[0], array[1]); pages.Add(page); } book = new Storybook(storytitle, pages); if (special == 1) { pageno = Convert.ToInt32(reader.ReadLine()); for (int j = 0; j < pageno; j++) { line = reader.ReadLine(); array = line.Split('|'); if (HasBranch(array[1])) { book.AddChoice(array[0], FindBranch(array[1])); } } } tile = builder.FindTileAt(tiles, x, y); if (tile != null) { if (!tile.Blocked) { tile.Storybook = book; } } line = reader.ReadLine(); } reader.Close(); } return(tiles); }
public List <TileV> AddObjectFromFile(List <TileV> tiles) { StreamReader reader = new StreamReader(_filename); if (reader != null) { TileVBuilder builder = new TileVBuilder(); GameObject obj = null; int objno = Convert.ToInt32(reader.ReadLine()); string line; List <string> array; for (int i = 0; i < objno; i++) { line = reader.ReadLine(); array = line.Split('|').ToList(); int type = Convert.ToInt32(array[0]); int x = Convert.ToInt32(array[1]); int y = Convert.ToInt32(array[2]); for (int j = 0; j < 3; j++) { array.RemoveAt(0); } TileV tile = builder.FindTileAt(tiles, x, y); switch (type) { case 0: obj = GetGameObject(array); break; case 1: int m = Convert.ToInt32(array[0]); int n = Convert.ToInt32(array[1]); for (int j = 0; j < 2; j++) { array.RemoveAt(0); } obj = GetActionObject(array, reader); TileV atile = builder.FindTileAt(tiles, m, n); if (obj != null && atile != null) { atile.LinkedTo = obj as ActionObject; } break; } if (obj != null && tile != null) { tile.Object = obj; } } reader.Close(); } return(tiles); }