Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        private ConsoleParams Lookup(char c, int row, int col, RoomPosition pos)
        {
            BaseRoom     room      = RoomPositions[pos];
            char         doorChar  = RoomChar(room, row, col);
            ConsoleColor doorColor = ColoredDoorChars.Contains(doorChar) ? room.Color : Types.WALL_AND_DOOR_COLOR;

            return(new ConsoleParams(doorChar.ToString(), doorColor, Types.BACKGROUND_COLOR));
        }
Ejemplo n.º 3
0
        private ConsoleParams HorizontalOverlap(char c, int row, int col, RoomPosition pos)
        {
            // If we are here we know that we are looking south
            // to check the overlap so we use Direction.South
            BaseRoom     room     = RoomPositions[pos];
            ConsoleColor color    = GetDoorColor(pos, Direction.South);
            char         doorChar = GetDoorChar(pos, Direction.South);

            return(new ConsoleParams(doorChar.ToString(), color, Types.ROOM_COLOR));
        }
Ejemplo n.º 4
0
        public ConsoleColor GetMergedColor(BaseRoom room1, BaseRoom room2)
        {
            if (room1.Color == room2.Color)
            {
                return(room1.Color);
            }

            ColorPair colorPair = new ColorPair(room1.Color, room2.Color);

            return(MergedColorDictionary[colorPair]);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        private void _setup()
        {
            DeligateMap = new Dictionary <char, ConsoleParamsDelegate>()
            {
                { ' ', Copy },
                { '┏', Copy },
                { '━', Copy },
                { '┳', Copy },
                { '┓', Copy },
                { '┣', Copy },
                { '┫', Copy },
                { '╋', Copy },
                { '┗', Copy },
                { '┻', Copy },
                { '┛', Copy },
                { '-', Lookup },
                { '|', Lookup },
                { 'h', HorizontalOverlap },
                { 'v', VerticalOverlap },
                { 't', Space },
                { 'T', RoomDesignator }
            };

            ColorState = Types.ColorState.CMYK;

            // Add rooms to the

            BaseRoom A = new BaseRoom(RoomIdentifier.A, RoomTemplates, RoomColors);
            BaseRoom B = new BaseRoom(RoomIdentifier.B, RoomTemplates, RoomColors);
            BaseRoom C = new BaseRoom(RoomIdentifier.C, RoomTemplates, RoomColors);
            BaseRoom D = new BaseRoom(RoomIdentifier.D, RoomTemplates, RoomColors);

            Calculator Calculator = new Calculator();

            C.Items.Add(Calculator);

            RoomPositions.Add(RoomPosition.One, B);
            RoomPositions.Add(RoomPosition.Two, C);
            RoomPositions.Add(RoomPosition.Three, A);
            RoomPositions.Add(RoomPosition.Four, D);
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        public ConsoleColor GetBackgroundColor(RoomPosition pos)
        {
            BaseRoom room = RoomPositions[pos];

            return(FullyMerged() ? room.Color : Types.BACKGROUND_COLOR);
        }
Ejemplo n.º 9
0
        public MoveResults MovePlayer(Direction direction)
        {
            MoveResults result = MoveResults(direction);

            if (result.Success)
            {
                if (FullyMerged() || Lock.Locked)
                {
                    CurrentRoomPosition = GetAdjoiningRoomPosition(CurrentRoomPosition, direction);
                }
                else
                {
                    switch (Level)
                    {
                    case Types.Level.One:
                        switch (direction)
                        {
                        case Direction.East:
                        case Direction.West:
                            RotateRooms(CurrentRoomPosition, direction);
                            break;

                        case Direction.North:
                        case Direction.South:
                            FlipRooms(direction);
                            break;
                        }
                        break;

                    case Types.Level.Two:
                        switch (direction)
                        {
                        case Direction.North:
                        case Direction.South:
                            RotateRooms(CurrentRoomPosition, direction);
                            break;

                        case Direction.East:
                        case Direction.West:
                            FlipRooms(direction);
                            break;
                        }
                        break;
                    }

                    if (FullyMerged())
                    {
                        AddCards();
                    }
                }
            }

            if (result.Success)
            {
                BaseRoom room = RoomPositions[CurrentRoomPosition];
                result.PrintInstructions.NewLine("You enter the ", ConsoleColor.DarkGreen)
                .Add(RoomInfo[room.Id].Name, room.Color)
                .Add(" room.", ConsoleColor.DarkGreen);
            }

            PrintInstructions mergedMessage = MergedDescription();

            mergedMessage.AddInstructions(result.PrintInstructions);

            result.PrintInstructions = mergedMessage;

            return(result);
        }
Ejemplo n.º 10
0
 public char RoomChar(BaseRoom room, int row, int col)
 {
     return(room.Template[row][col]);
 }