Пример #1
0
        private void connectivity()
        {
            /*
             * 1. The cells of neighboring rooms will be noted and a list of
             *    possible door locations will be created.
             *
             * Doors should be standardized on lower room ID first, higher second.
             *
             * 2. A separate list will be generated noting what rooms are
             *    accessible to each other room.
             *
             * I think the accessible room list is only necessary for game flow.
             *
             * On the other hand, I could use it to easily keep track of which
             * sets of doors need to have a door chosen from.
             *
             * I think a double dictionary would work well to keep a list of doors to choose from.
             * room -> connected room -> doors
             */

            Console.Write("Generating all possible door locations... ");
            foreach (Square gridSquare in board.grid)
            {
                foreach (Square adjGridSquare in gridSquare.adjSquares)
                {
                    if (adjGridSquare.roomID != gridSquare.roomID)
                    {
                        if (adjGridSquare.roomID < gridSquare.roomID)
                        {
                            Door tempDoor = new Door(adjGridSquare, gridSquare);
                            board.addDoor(tempDoor);
                        }
                        else if (adjGridSquare.roomID > gridSquare.roomID)
                        {
                            Door tempDoor = new Door(gridSquare, adjGridSquare);
                            board.addDoor(tempDoor);
                        }
                    }
                }
            }
            Console.WriteLine("Complete");
        }
Пример #2
0
        public void addDoor(Door newDoor)
        {
            bool addIt = true;

            foreach (Door mapDoors in this.possibleDoors)
            {
                if ((newDoor.squareA == mapDoors.squareA && newDoor.squareB == mapDoors.squareB)
                    || (newDoor.squareA == mapDoors.squareB && newDoor.squareB == mapDoors.squareA))
                {
                    addIt = false;
                }
            }

            if (addIt)
            {
                this.possibleDoors.Add(newDoor);
            }
        }