コード例 #1
0
ファイル: Movement.cs プロジェクト: jandar78/Novus
		private static void UnlockDoor(IUser player, IDoor door) {
			IMessage message = new Message();
			message.InstigatorID = player.UserID.ToString();
			message.InstigatorType = player.Player.IsNPC == false ? ObjectType.Player : ObjectType.Npc;

            if (!player.Player.InCombat) {
                IRoom room = Room.GetRoom(player.Player.Location);
                bool hasKey = false;
                if (!room.IsDark) {
                    if (door.Lockable) {
                        if (door.RequiresKey) {
                            //let's see if the player has the key in his inventory or a skeleton key (opens any door)
                            List<IItem> inventory = player.Player.Inventory.GetInventoryAsItemList();
                            List<IItem> keyList = inventory.Where(i => i.ItemType.ContainsKey(ItemsType.KEY)).ToList();
                            IKey key = null;
                            foreach (IItem keys in keyList) {
                                key = keys as IKey;
                                if (key.DoorID == door.Id || key.SkeletonKey) {
                                    hasKey = true;
                                    break;
                                }
                            }
                        }
                        if (!door.Open && !door.Destroyed && ((door.RequiresKey && hasKey) || !door.RequiresKey)) {
                            door.Locked = false;
                            door.UpdateDoorStatus();
                            //I may end up putting these strings in the general collection and then each method just supplies the verb
                            message.Self = String.Format("You unlock {0} {1}.", GetArticle(door.Description[0]), door.Description);
                            message.Room = String.Format("{0} unlocks {1} {2}.", player.Player.FirstName, GetArticle(door.Description[0]), door.Description);
                        }
                        else if (door.Destroyed) {
                            message.Self ="Why would you want to unlock something that is in pieces?";
                        }
                        else if (!hasKey) {
                            message.Self ="You don't have the key to unlock this door.";
                        }
                        else {
                            message.Self ="It can't be unlocked, the door is open.";
                        }
                    }
                    else {
                        message.Self = "It can't be unlocked.";
                    }
                }
                else {
                    message.Self = "You can't see anything! Let alone what you are trying to unlock.";
                }
				if (player.Player.IsNPC) {
					player.MessageHandler(message);
				}
				else {
					player.MessageHandler(message.Self);
				}
                
                room.InformPlayersInRoom(message, new List<ObjectId>() { player.UserID });
                
            }
            else {
                player.MessageHandler("You are in the middle of combat there are more pressing matters at hand than unlocking something.");
            }
		}
コード例 #2
0
ファイル: Movement.cs プロジェクト: jandar78/Novus
        private static void CloseDoor(IUser player, IDoor door) {
			IMessage message = new Message();
			IRoom room = Room.GetRoom(player.Player.Location);
			message.InstigatorID = player.UserID.ToString();
			message.InstigatorType = player.Player.IsNPC == false ? ObjectType.Player : ObjectType.Npc;

			if (!player.Player.InCombat) {
                if (!room.IsDark) {
                    if (door.Openable) {
                        if (door.Open && !door.Destroyed) {
                            door.Open = false;
                            door.UpdateDoorStatus();
                            //I may end up putting these strings in the general collection and then each method just supplies the verb
                            message.Self = String.Format("You close {0} {1}.", GetArticle(door.Description[0]), door.Description);
                            message.Room = String.Format("{0} closes {1} {2}.", player.Player.FirstName, GetArticle(door.Description[0]), door.Description);
                        }
                        else if (door.Destroyed) {
                            message.Self = "You can't close it because it is in pieces!";
                        }
                        else {
                            message.Self = "It's already closed.";
                        }
                    }
                    else {
                        message.Self = "It can't be closed.";
                    }
                }
                else {
                    message.Self = "You can't see anything! Let alone what you are trying to close.";
                }
            }
            else {
                message.Self = "You are in the middle of combat, there are more pressing matters at hand than closing something.";
            }

			if (player.Player.IsNPC) {
				player.MessageHandler(message);
			}
			else {
				player.MessageHandler(message.Self);
			}
			room.InformPlayersInRoom(message, new List<ObjectId>() { player.UserID });
		}
コード例 #3
0
ファイル: Movement.cs プロジェクト: jandar78/Novus
		private static void OpenDoor(IUser player, IDoor door) {
			IMessage message = new Message();
			message.InstigatorID = player.UserID.ToString();
			message.InstigatorType = player.Player.IsNPC == false ? ObjectType.Player : ObjectType.Npc;
			IRoom room = Room.GetRoom(player.Player.Location);

			if (!player.Player.InCombat) {
                if (!room.IsDark) {
                    if (door.Openable) {
                        if (!door.Open && !door.Locked && !door.Destroyed) {
                            door.Open = true;
                            door.UpdateDoorStatus();
                            message.Self = String.Format("You open {0} {1}.", GetArticle(door.Description[0]), door.Description);
                            message.Room = String.Format("{0} opens {1} {2}.", player.Player.FirstName, GetArticle(door.Description[0]), door.Description);
                        }
                        else if (door.Open && !door.Destroyed) {
                            message.Self = "It's already open.";
                        }
                        else if (door.Locked && !door.Destroyed) {
                            message.Self ="You can't open it because it is locked.";
                        }
                        else if (door.Destroyed) {
                            message.Self = "It's more than open it's in pieces!";
                        }
                    }
                    else {
                        message.Self ="It can't be opened.";
                    }
                }
                else {
                    message.Self ="You can't see anything! Let alone what you are trying to open.";
                }
            }
            else {
                player.MessageHandler("You are in the middle of combat, there are more pressing matters at hand than opening something.");
            }

			if (player.Player.IsNPC) {
				player.MessageHandler(message);
			}
			else {
				player.MessageHandler(message.Self);
			}
			room.InformPlayersInRoom(message, new List<ObjectId>() { player.UserID });
		}
コード例 #4
0
ファイル: Movement.cs プロジェクト: jandar78/Novus
 private static void CloseADoor(IDoor door) {
     door.Open = false;
     door.UpdateDoorStatus();
 }
コード例 #5
0
ファイル: Movement.cs プロジェクト: jandar78/Novus
 private static void OpenADoor(IDoor door) {
     door.Open = true;
     door.UpdateDoorStatus();
 }