示例#1
0
        public ConsoleColor GetDoorColor(RoomPosition roomPosition, Direction direction)
        {
            BaseRoom room          = RoomPositions[roomPosition];
            BaseRoom adjoiningRoom = GetAdjoiningRoom(roomPosition, direction);
            char     doorChar      = room.DoorCharacter(direction);

            if (DoorsAreMerged(roomPosition, direction))
            {
                // We need to get the merged color
                return(GetMergedColor(room, adjoiningRoom));
            }

            if (ColoredDoorChars.Contains(doorChar))
            {
                return(room.Color);
            }

            // If the adjoining door is a color door we get that
            if (adjoiningRoom != null)
            {
                char adjoiningDoorChar = adjoiningRoom.DoorCharacter(GetOppisiteDirection(direction));
                if (ColoredDoorChars.Contains(adjoiningDoorChar))
                {
                    return(adjoiningRoom.Color);
                }
            }

            return(Types.WALL_AND_DOOR_COLOR);
        }
示例#2
0
        public bool DoorsAreMerged(RoomPosition currentPosition, Direction direction)
        {
            BaseRoom adjoiningRoom = GetAdjoiningRoom(currentPosition, direction);

            if (adjoiningRoom == null)
            {
                return(false);
            }

            bool currentIsMergable   = ColoredDoorChars.Contains(RoomPositions[currentPosition].DoorCharacter(direction));
            bool adjoiningIsMergable = ColoredDoorChars.Contains(adjoiningRoom.DoorCharacter(GetOppisiteDirection(direction)));

            return(currentIsMergable && adjoiningIsMergable);
        }
示例#3
0
        // public char GetDoorCharacter(BaseRoom room, Direction direction)
        // {
        //   return room.DoorCharacter(direction);
        // }

        public char GetDoorChar(RoomPosition roomPosition, Direction direction)
        {
            BaseRoom currentRoom   = RoomPositions[roomPosition];
            BaseRoom adjoiningRoom = GetAdjoiningRoom(roomPosition, direction);

            char curRoomChar = currentRoom.DoorCharacter(direction);

            if (adjoiningRoom == null)
            {
                return(curRoomChar);
            }

            char adjRoomChar = adjoiningRoom.DoorCharacter(GetOppisiteDirection(direction));

            if (ColoredDoorChars.Contains(adjRoomChar))
            {
                return(adjRoomChar);
            }

            return(curRoomChar);
        }