public World() { worldTime = new DateTime(); rooms = new List<Room>(); rooms.Add(new Room("The Void", "You are standing in the middle of nothing.")); mobs = new ConcurrentBag<NPC>(); NPC test = new NPC("mob", "A slimy sticky stinky mob", new Stats(50, 100), this); rooms.First().addNPC(test); mobs.Add(test); test = new NPC("bob", "A slimy sticky stinky bob", new Stats(50, 100), this); rooms.First().addNPC(test); mobs.Add(test); test = new NPC("sob", "A slimy sticky stinky sob", new Stats(50, 100), this); rooms.First().addNPC(test); mobs.Add(test); test = new NPC("cob", "A slimy sticky stinky cob", new Stats(50, 100), this); rooms.First().addNPC(test); mobs.Add(test); Merchant merch = new Merchant(); merch.name = "merchant"; merch.description = "a merchant of souls"; merch.world = this; merch.stats = new Stats(10000, 10000); Item i = new Item("health", "a potion of restore health", 1, "none", 1); merch.items.addToInventory(i); rooms.First().addNPC(merch); mobs.Add(merch); rooms.First().addItem(new Item("leggings", "a worn pair of leather leggings", 2, "legs", 2)); }
public bool walk(int direction, NPC npc) { StringBuilder buffer = new StringBuilder(); if (npc.room.hasExit(direction)) { buffer.AppendFormat("\r\n{0} exits the room to the {1}.\r\n", npc.description, Direction.directionToName(direction)); npc.room.sendToRoom(buffer.ToString()); npc.room.removeNPC(npc); npc.room.exits[direction].addNPC(npc); buffer.Clear(); buffer.AppendFormat("\r\n{0} has entered the room from the {1}.\r\n", npc.description, Direction.directionToName(Direction.oppositeExit(direction))); npc.room.sendToRoom(buffer.ToString()); return true; } else { return false; } }
public void addNPC(NPC npc) { npc.room = this; characters.Add(npc); npcs.Add(npc); }
public void removeNPC(NPC npc) { characters.Remove(npc); npcs.Remove(npc); }