Exemplo n.º 1
0
 public static void ConnectRoom(IRoom room1, Direction room1ExitDirection, IRoom room2, DoorInfo doorInfo = null)
 {
     AddExitToRoom(room1, room1ExitDirection, room2, doorInfo);
     AddExitToRoom(room2, ReverseDirection(room1ExitDirection), room1, doorInfo);
 }
Exemplo n.º 2
0
        private static void AddExitToRoom(IRoom room1, Direction room1ExitDirection, IRoom room2, DoorInfo doorInfo)
        {
            IExit exit = new Exit();

            exit.Room = room2.Id;
            exit.Zone = room2.Zone;
            switch (room1ExitDirection)
            {
            case Direction.North:
                if (room1.North != null)
                {
                    throw new Exception("Exit already assigned");
                }
                room1.North = exit;
                break;

            case Direction.East:
                if (room1.East != null)
                {
                    throw new Exception("Exit already assigned");
                }
                room1.East = exit;
                break;

            case Direction.South:
                if (room1.South != null)
                {
                    throw new Exception("Exit already assigned");
                }
                room1.South = exit;
                break;

            case Direction.West:
                if (room1.West != null)
                {
                    throw new Exception("Exit already assigned");
                }
                room1.West = exit;
                break;

            case Direction.Up:
                if (room1.Up != null)
                {
                    throw new Exception("Exit already assigned");
                }
                room1.Up = exit;
                break;

            case Direction.Down:
                if (room1.Down != null)
                {
                    throw new Exception("Exit already assigned");
                }
                room1.Down = exit;
                break;
            }

            if (doorInfo != null)
            {
                exit.Door      = new Door();
                exit.Door.Zone = room1.Zone;    //needed to pass verification
                exit.Door.Id   = room1.Id;      //needed to pass verification
                exit.Door.KeyWords.Add(doorInfo.Name);
                exit.Door.ExamineDescription  = doorInfo.Description;
                exit.Door.LongDescription     = doorInfo.Description;
                exit.Door.ShortDescription    = doorInfo.Name;
                exit.Door.SentenceDescription = doorInfo.Name;
                exit.Door.OpenMessage         = doorInfo.OpenMessage;
                exit.Door.Linked = doorInfo.Linked;
                if (doorInfo.Linked)
                {
                    exit.Door.LinkedRoomId = new BaseObjectId()
                    {
                        Id = room2.Id, Zone = room2.Zone
                    };
                    exit.Door.LinkedRoomDirection = ReverseDirection(room1ExitDirection);
                }
            }
        }
Exemplo n.º 3
0
        public static void ConnectZone(IRoom room, Direction roomExitDirection, int zoneId, int roomId, DoorInfo doorInfo = null)
        {
            IRoom dummyRoom = new Room();

            dummyRoom.Zone = zoneId;
            dummyRoom.Id   = roomId;
            ConnectRoom(room, roomExitDirection, dummyRoom, doorInfo);
        }