private void SpawnDwarfs(IAdventureLocation playerLocation) { var spawnPoints = Locations.Values.Where(l => l.IsSpawnPoint && l.SpawnType == MonsterGroup.Dwarves); var altSpawnPoint = Locations.Values.Where(l => l.IsAlternateSpawnPoint && l.SpawnType == MonsterGroup.Dwarves).FirstOrDefault(); foreach (var spawnPoint in spawnPoints) { Monsters.Add(new WanderingMonster(spawnPoint, MonsterGroup.Dwarves)); } if (altSpawnPoint != null) { // Do not spawn a dwarf on top of the player! foreach (var monster in Monsters) { if (monster.CurrentLocation.LocationId.Equals(playerLocation.LocationId)) { monster.CurrentLocation = altSpawnPoint; monster.PrevLocation = altSpawnPoint; break; } } } }
private void RemoveTroll(IAdventurePlayer player, IAdventureItem troll, IAdventureLocation swOfChasm, IAdventureLocation neOfChasm) { var removeTroll1 = new RemoveFromLocation(troll, swOfChasm); var removeTroll2 = new RemoveFromLocation(troll, neOfChasm); removeTroll1.Do(player, troll); removeTroll2.Do(player, troll); AllowPassage(player); }
public bool TryGetLocation(Location locationId, out IAdventureLocation place) { var location = Locations.Where(l => l.Value.LocationId.Equals(locationId)).ToList(); place = null; if (location.Count == 0) { return(false); } place = location[0].Value; return(true); }
public WanderingMonster(IAdventureLocation location, MonsterGroup group) { CurrentLocation = location; PrevLocation = location; Group = group; }
public RemoveFromLocation(IAdventureItem itemToRemove, IAdventureLocation location) { _itemToRemove = itemToRemove; _location = location; }
public AddToLocation(IAdventureItem itemToAddToLocation, IAdventureLocation location) { _itemToAddToLocation = itemToAddToLocation; _location = location; }