private void TryToSpawnMelon(BlankTile aTile) { int randomNumber = myRandom.Next(100); if (randomNumber == 1) { aTile.AddTemporaryItem(myItemFactory.GetItem(ItemType.Melon, aTile.Position)); } }
private bool AllPelletsEaten() { foreach (Tile[] tiles in myTiles) { foreach (Tile tile in tiles) { if (tile is BlankTile) { BlankTile current = tile as BlankTile; if (current.HasPellet == true) { return(false); } } } } return(true); }
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; } } } }