public Monster(string name, Location location) { this.name = name; this.location = location; }
public void Goto(Location location, bool doCombatCheck) { Clear(); player.Goto(location); Monster monster = null; bool inCombat = false; if (location == stats) { AddToDisplay(String.Format("Health: {0}/{1} Attack: {2} Defence: {3}", player.health, player.maxHealth, player.attack, player.defence)); AddToDisplay(String.Format("Level {0} Experience: {1}/{2}", player.level, player.experience, player.nextLevelExperience)); } else { for (int i = 0; i < location.enterText.Count; i++) { AddToDisplay((location.enterText[i])); } } StringBuilder locations = new StringBuilder(); for (int i = 0; i < location.locations.Count; i++) { locations.Append(String.Format("{0}. {1} ", i + 1, location.locations[i].name)); } AddToDisplay(locations.ToString()); AddToDisplay("\n"); if (location.hasCombat && doCombatCheck) { if (random.Next(0, 2) == 1) { Thread.Sleep(400); Clear(); monster = GetMonster(location); inCombat = true; } } if (location == innRoom) player.health = player.maxHealth; try { if (!inCombat) Goto(location.locations[Convert.ToInt32(ReadLine("Where would you like to go? ")) - 1], true); else { DoCombat(monster); } } catch (Exception) { PrintLine("You have typed in an incorrect destination."); Thread.Sleep(1500); Goto(location, false); } }
public void Goto(Location location) { this.location = location; }
public Monster GetMonster(Location currentLocation) { List<Monster> viableMonsters = new List<Monster>(); foreach (Monster m in monsterTypes) { if (m.location == currentLocation || m.location == null) { viableMonsters.Add((Monster)m.Clone()); } } Monster monster = viableMonsters[random.Next(0, viableMonsters.Count)]; monster.level = random.Next(player.level - 5, player.level + 5); if (monster.level < 1) monster.level = 1; monster.calculateStats(); return monster; }