本文整理汇总了C#中IRoom.GetObjectsInRoom方法的典型用法代码示例。如果您正苦于以下问题:C# IRoom.GetObjectsInRoom方法的具体用法?C# IRoom.GetObjectsInRoom怎么用?C# IRoom.GetObjectsInRoom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRoom
的用法示例。
在下文中一共展示了IRoom.GetObjectsInRoom方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DisplayPlayersInRoom
//called from the LOOK command
private static string DisplayPlayersInRoom(IRoom room, ObjectId ignoreId) {
StringBuilder sb = new StringBuilder();
if (!room.IsDark) {
foreach (var id in room.GetObjectsInRoom(RoomObjects.Players)) {
if (!id.Equals(ignoreId)) {
IUser otherUser = Server.GetAUser(id);
if (otherUser != null && otherUser.CurrentState == UserState.TALKING) {
if (otherUser.Player.ActionState != CharacterActionState.Hiding && otherUser.Player.ActionState != CharacterActionState.Sneaking){ //(string.IsNullOrEmpty(PassesHideCheck(otherUser, ignoreId, out spot))) { //player should do a spot check this should not be a given
sb.AppendLine(otherUser.Player.FirstName + " is " + otherUser.Player.StanceState.ToString().ToLower() + " here.");
}
}
}
}
Dictionary<string, int> npcGroups = new Dictionary<string, int>();
foreach (var id in room.GetObjectsInRoom(RoomObjects.Npcs)) {
var npc = Character.NPCUtils.GetAnNPCByID(id);
if (!npcGroups.ContainsKey(npc.FirstName + "$" + npc.LastName + "$" + npc.StanceState)) {
npcGroups.Add(npc.FirstName + "$" + npc.LastName + "$" + npc.StanceState, 1);
}
else {
npcGroups[npc.FirstName + "$" + npc.LastName + "$" + npc.StanceState] += 1;
}
}
foreach (KeyValuePair<string, int> pair in npcGroups) {
string[] temp = pair.Key.Split('$');
sb.AppendLine(temp[0] + " is " + temp[2].Replace("_", " ").ToLower() + " here. " + (pair.Value > 1 ? ("[x" + pair.Value + "]") : ""));
}
}
else {
int count = 0;
foreach (var id in room.GetObjectsInRoom(RoomObjects.Players)) {
if (!id.Equals(ignoreId)) {
IUser otherUser = Server.GetAUser(id);
if (otherUser != null && otherUser.CurrentState == UserState.TALKING) {
if (otherUser.Player.ActionState != CharacterActionState.Hiding && otherUser.Player.ActionState != CharacterActionState.Sneaking) { //player should do a spot check this should not be a given
count++;
}
}
}
}
count += room.GetObjectsInRoom(RoomObjects.Npcs).Count;
if (count == 1) {
sb.AppendLine("A presence is here.");
}
else if (count > 1) {
sb.AppendLine("Several presences are here.");
}
}
return sb.ToString();
}
示例2: FindAnNpc
private static string FindAnNpc(List<string> commands, IRoom room, out bool foundIt) {
foundIt = false;
string message = null;
var npcList = room.GetObjectsInRoom(RoomObjects.Npcs);
var npcCollection = MongoUtils.MongoData.GetCollection<NPC>("Characters", "NPCCharacters");
IMongoQuery query = null;
foreach (var id in npcList) {
query = Query.EQ("_id", id);
var result = MongoUtils.MongoData.RetrieveObject<NPC>(npcCollection, n => n.Id.Equals(id));
string tempName = result.FirstName + " " + result.LastName;
if (commands[2].ToLower().Contains(result.FirstName.ToLower()) || commands[2].ToLower().Contains(result.LastName.ToLower())) {
string[] position = commands[0].Split('.'); //we are spearating based on using the decimal operator after the name of the npc/item
if (position.Count() > 1) {
//ok so the player specified a specific NPC in the room list to examine and not just the first to match
int pos;
int.TryParse(position[position.Count() - 1], out pos);
if (pos != 0) {
var idToParse = GetObjectInPosition(pos, commands[2], room.Id);
result = MongoUtils.MongoData.RetrieveObject<NPC>(npcCollection, n => n.Id.Equals(idToParse));
}
}
if (result != null) {
message = result.Description;
foundIt = true;
break;
}
}
}
return message;
}
示例3: FindLightInEquipment
private static IIluminate FindLightInEquipment(List<string> commands, IUser player, IRoom room) {
IItem lightItem = null;
if (commands.Count > 0) {
string itemName = GetItemName(commands, "").ToString();
//let's see if player has a lightsource equipped
foreach (IItem item in player.Player.Equipment.GetEquipment().Values) {
if (item.WornOn == Wearable.WIELD_LEFT || item.WornOn == Wearable.WIELD_RIGHT) {
IIluminate temp = item as IIluminate;
if (temp != null && temp.isLightable) {
lightItem = item;
break;
}
}
}
}
else { //let's be smart and figure out what lightSource he wants activated, first come first serve otherwise
foreach (IItem item in player.Player.Equipment.GetEquipment().Values) {
IIluminate lightsource = item as IIluminate;
if (lightsource != null && lightsource.isLightable) {
lightItem = item;
break;
}
}
if (lightItem == null) { //not in players equipment let's check the room
foreach (var itemId in room.GetObjectsInRoom(RoomObjects.Items)) {
lightItem = Items.Items.GetByID(itemId).Result;
IIluminate lightsource = lightItem as IIluminate;
if (lightsource != null && lightsource.isLightable) {
break;
}
//if it's a container and it's open see if it has a lightsource inside
if (lightItem.ItemType.ContainsKey(ItemsType.CONTAINER)) {
IContainer containerItem = lightItem as IContainer;
if (containerItem.Opened) {
foreach (var id in containerItem.GetContents()) {
lightItem = Items.Items.GetByID(itemId).Result;
lightsource = lightItem as IIluminate;
if (lightsource != null && lightsource.isLightable) {
break;
}
}
}
}
}
}
}
return (lightItem as IIluminate);
}
示例4: DisplayItemsInRoom
private static string DisplayItemsInRoom(IRoom room) {
StringBuilder sb = new StringBuilder();
List<ObjectId> itemsInRoom = room.GetObjectsInRoom(RoomObjects.Items);
Dictionary<string, int> itemGroups = new Dictionary<string, int>();
if (!room.IsDark) {
foreach (var id in itemsInRoom) {
IItem item = Items.Items.GetByID(id).Result;
if (item != null) {
if (item.ItemType.ContainsKey(ItemsType.CONTAINER)) {
IContainer containerItem = item as IContainer;
if (!itemGroups.ContainsKey(item.Name + "$" + (containerItem.IsOpenable == true ? (containerItem.Opened ? "[Opened]" : "[Closed]") : "[container]"))) {
itemGroups.Add(item.Name + "$" + (containerItem.IsOpenable == true ? (containerItem.Opened ? "[Opened]" : "[Closed]") : "[container]"), 1);
}
else {
itemGroups[item.Name + "$" + (containerItem.IsOpenable == true ? (containerItem.Opened ? "[Opened]" : "[Closed]") : "[container]")] += 1;
}
}
else if (item.ItemType.ContainsKey(ItemsType.DRINKABLE) || item.ItemType.ContainsKey(ItemsType.EDIBLE)) {
if (!itemGroups.ContainsKey(item.Name)) {
itemGroups.Add(item.Name, 1);
}
else {
itemGroups[item.Name] += 1;
}
}
else {
if (!itemGroups.ContainsKey(item.Name + "$" + item.CurrentCondition)) {
itemGroups.Add(item.Name + "$" + item.CurrentCondition, 1);
}
else {
itemGroups[item.Name + "$" + item.CurrentCondition] += 1;
}
}
}
}
foreach (KeyValuePair<string, int> pair in itemGroups) {
string[] temp = pair.Key.Split('$');
sb.Append(temp[0] + " is laying here");
if (temp.Count() > 1 && !string.Equals(temp[1], "NONE", StringComparison.InvariantCultureIgnoreCase)) {
if (temp[1].Contains("[Opened]") || temp[1].Contains("[Closed]") || temp[1].Contains("[container]")) {
sb.AppendLine(". " + (temp[1] == "[container]" ? "" : temp[1]) + (pair.Value > 1 ? (" [x" + pair.Value + "]") : ""));
}
else {
sb.AppendLine(" in " + temp[1].Replace("_", " ").ToLower() + " condition." + (pair.Value > 1 ? ("[x" + pair.Value + "]") : ""));
}
}
else {
sb.AppendLine(".");
}
}
}
else {
int count = 0;
foreach (var id in itemsInRoom) {
IItem item = Items.Items.GetByID(id).Result;
if (item != null) {
count++;
}
}
if (count == 1) {
sb.AppendLine("Something is laying here.");
}
else if (count > 1) {
sb.AppendLine("Somethings are laying here.");
}
}
return sb.ToString();
}
示例5: FindAPlayer
private static string FindAPlayer(List<string> commands, IRoom room, out bool foundIt) {
foundIt = false;
string message = null;
var chars = room.GetObjectsInRoom(RoomObjects.Players);
foreach (var id in chars) {
Character.Character playerChar = Server.GetAUser(id).Player as Character.Character;
string tempName = playerChar.FirstName + " " + playerChar.LastName;
if (commands[2].ToLower().Contains(playerChar.FirstName.ToLower()) || commands[2].ToLower().Contains(playerChar.LastName.ToLower())) {
message = playerChar.Examine();
foundIt = true;
break;
}
}
return message;
}
示例6: FindAnItem
private static string FindAnItem(List<string> commands, IUser player, IRoom room, out bool foundIt) {
foundIt = false;
string message = null;
var itemsInRoom = room.GetObjectsInRoom(RoomObjects.Items);
foreach (var id in itemsInRoom) {
IItem item = Items.ItemFactory.CreateItem(id).Result;
if (commands[2].ToLower().Contains(item.Name.ToLower())) {
message = item.Examine();
foundIt = true;
break;
}
}
if (!foundIt) { //not in room check inventory
List<IItem> inventory = player.Player.Inventory.GetInventoryAsItemList();
foreach (IItem item in inventory) {
if (commands[2].ToLower().Contains(item.Name.ToLower())) {
message = item.Examine();
foundIt = true;
break;
}
}
}
if (!foundIt) { //check equipment
Dictionary<Wearable, IItem> equipment = player.Player.Equipment.GetEquipment();
foreach (IItem item in equipment.Values) {
if (commands[2].ToLower().Contains(item.Name.ToLower())) {
message = item.Examine();
foundIt = true;
break;
}
}
}
return message;
}