Example #1
0
            private Item findItem(Room room)
            {
                if (visited.Contains(room))
                    return null;

                visited.Add(room);

                if (room.name.Equals(this.room, StringComparison.OrdinalIgnoreCase))
                {
                    if (item.Equals("NorthDoor", StringComparison.OrdinalIgnoreCase))
                        return room.north.door;
                    else if (item.Equals("SouthDoor", StringComparison.OrdinalIgnoreCase))
                        return room.south.door;
                    else if (item.Equals("WestDoor", StringComparison.OrdinalIgnoreCase))
                        return room.west.door;
                    else if (item.Equals("EastDoor", StringComparison.OrdinalIgnoreCase))
                        return room.east.door;

                    return room.getItem(item);
                }
                else
                {
                    foreach (Wall w in room.getWalls())
                    {
                        if (w.door != null)
                        {
                            Item i = findItem(w.door.room);
                            if (i != null)
                                return i;
                        }
                    }
                }

                return null;
            }
Example #2
0
        private static void buildWalls(Player player, Room room, Node node)
        {
            foreach (Node n in node.children)
            {
                Direction d;

                try
                {
                    d = (Direction)Enum.Parse(typeof(Direction), n.name, true);
                }
                catch
                {
                    continue;
                }

                buildWall(player, room.getWall(d), n);
            }
        }
Example #3
0
        public Wall(Room room, string name)
        {
            parentRoom = room;
            this.name = name;
            try
            {
                direction = DirectionUtils.parse(name);
            }
            catch { }

            items = new List<Item>();
        }
Example #4
0
        private static Room buildRoom(Player player, Node node)
        {
            Room room = new Room(node.name);

            foreach (Node n in node.children)
            {
                if (n is Pair && n.name.Equals("Description", StringComparison.OrdinalIgnoreCase))
                    room.description = ((Pair)n).value;
                else if (n.name.Equals("Items", StringComparison.OrdinalIgnoreCase))
                    room.Items = buildItems(player, null, n);
            }

            buildWalls(player, room, node);

            return room;
        }