private void InitializeBoard(List <string> aStrings) { myTiles = new Tile[aStrings.Count][]; TeleportTile[] teleportTiles = new TeleportTile[10]; for (int i = 0; i < aStrings.Count; i++) { myTiles[i] = new Tile[aStrings[i].Length]; for (int j = 0; j < aStrings[i].Length; j++) { BlankTile current; switch (aStrings[i][j]) { case 'w': myTiles[i][j] = new WallTile(j, i); break; case ' ': myTiles[i][j] = new BlankTile(j, i); break; case 'm': myTiles[i][j] = new MapBorderTile(j, i); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': int serialnumber = int.Parse(aStrings[i][j].ToString()); myTiles[i][j] = new TeleportTile(j, i); if (teleportTiles[serialnumber] != null) { teleportTiles[serialnumber].Link(myTiles[i][j] as TeleportTile); } else { teleportTiles[serialnumber] = myTiles[i][j] as TeleportTile; } break; case 'f': myTiles[i][j] = new BlankTile(j, i); current = myTiles[i][j] as BlankTile; current.AddItem(myItemFactory.GetItem(ItemType.Pellet, myTiles[i][j].Position)); break; case 'c': myTiles[i][j] = new BlankTile(j, i); current = myTiles[i][j] as BlankTile; current.AddItem(myItemFactory.GetItem(ItemType.Cherry, myTiles[i][j].Position)); break; case 'k': myTiles[i][j] = new BlankTile(j, i); current = myTiles[i][j] as BlankTile; current.AddItem(myItemFactory.GetItem(ItemType.Key, myTiles[i][j].Position)); break; case 'p': myTiles[i][j] = new BlankTile(j, i); Player.SetSpawnPosition(myTiles[i][j].Position); break; case 'r': myTiles[i][j] = new BlankTile(j, i); myGhosts.Add(myGhostFactory.GetGhost(GhostType.Red, Player, this, myTiles[i][j].Position)); myGhosts[myGhosts.Count - 1].SetSpawnPosition(myTiles[i][j].Position); break; case 'v': myTiles[i][j] = new BlankTile(j, i); myGhosts.Add(myGhostFactory.GetGhost(GhostType.Violet, Player, this, myTiles[i][j].Position)); myGhosts[myGhosts.Count - 1].SetSpawnPosition(myTiles[i][j].Position); break; case 'b': myTiles[i][j] = new BlankTile(j, i); myGhosts.Add(myGhostFactory.GetGhost(GhostType.Blue, Player, this, myTiles[i][j].Position)); myGhosts[myGhosts.Count - 1].SetSpawnPosition(myTiles[i][j].Position); break; case 'o': myTiles[i][j] = new BlankTile(j, i); myGhosts.Add(myGhostFactory.GetGhost(GhostType.Orange, Player, this, myTiles[i][j].Position)); myGhosts[myGhosts.Count - 1].SetSpawnPosition(myTiles[i][j].Position); break; } } } }
public void Link(TeleportTile aTeleportTile) { myTeleportTile = aTeleportTile; aTeleportTile.myTeleportTile = this; }