Exemple #1
0
        private void setRoomInDetailedMap(Boolean[,] internalDetailedMapStruct, RoomNode room, int rowIndex, int colIndex)
        {
            int row   = rowIndex;
            int col   = colIndex;
            int index = 0;

            for (; col < colIndex + room.Width; col++)
            {
                if (!room.IsDoorIndex(index))
                {
                    internalDetailedMapStruct[row, col] = false;
                    internalDetailedMapStruct[row + room.Height - 1, col] = false;
                }
                index++;
            }
            col--;
            index = 0;
            for (; row < rowIndex + room.Height - 1; row++)
            {
                if (!room.IsDoorIndex(index))
                {
                    internalDetailedMapStruct[row, col] = false;
                    internalDetailedMapStruct[row, col - room.Width + 1] = false;
                }
                index++;
            }
        }
Exemple #2
0
        private void GenerateDetailMap(Node[,] MapStruct, Boolean[,] detailedMapStruct)
        {
            this.initializeDetailedMap(detailedMapStruct);
            for (int row = 0; row < this.numNodesV; row++)
            {
                for (int col = 0; col < this.numNodesH; col++)
                {
                    Node tempNode = MapStruct[row, col];
                    int  rowIndex = row * tempNode.Height;
                    int  colIndex = col * tempNode.Width;

                    if (tempNode is RoomNode)
                    {
                        RoomNode room = (RoomNode)tempNode;
                        this.setRoomInDetailedMap(detailedMapStruct, room, rowIndex, colIndex);
                    }
                    else if (tempNode is WallNode)
                    {
                        WallNode wall = (WallNode)tempNode;
                        this.setWallInDetailedMap(detailedMapStruct, wall, rowIndex, colIndex);
                    }
                    if (tempNode is EmptyNode)
                    {
                        EmptyNode empty = (EmptyNode)tempNode;
                    }
                }
            }
        }
Exemple #3
0
 public Room(Game game, RoomNode roomNode, Vector3 position)
     : base(game)
 {
     this.position = position;
     this.game     = game;
     this.room     = roomNode;
     this.Initialize();
 }
Exemple #4
0
 public Room(Game game, RoomNode roomNode, Vector3 position)
     : base(game)
 {
     this.position = position;
     this.game = game;
     this.room = roomNode;
     this.Initialize();
 }
Exemple #5
0
        public void GenerateRandomMap()
        {
            this.rooms        = new ArrayList();
            this.walls        = new ArrayList();
            this.empties      = new ArrayList();
            this.numOfEmpties = 0;
            this.numOfRooms   = 0;
            this.numOfWalls   = 0;
            //Random randomGenerator = new Random(randomSeed);
            for (int row = 0; row < this.numNodesV; row++)
            {
                for (int col = 0; col < this.numNodesH; col++)
                {
                    if ((row == 0 && col == 0) || (row == this.numNodesV - 1 && col == this.numNodesH - 1))
                    {
                        this.internalMapStruct[row, col]  = new EmptyNode();
                        this.optimizedMapStruct[row, col] = new EmptyNode();
                        this.numOfEmpties++;
                        continue;
                    }

                    int randomType = this.randomGenerator.Next(3);
                    if (randomType == 0)
                    {
                        RoomNode tempRoom            = new RoomNode(this.randomGenerator);
                        KeyValuePair <int, int> item = new KeyValuePair <int, int>(row, col);
                        this.rooms.Add(item);
                        this.numOfRooms++;
                        this.internalMapStruct[row, col]  = tempRoom;
                        this.optimizedMapStruct[row, col] = tempRoom;
                    }
                    else if (randomType == 1)
                    {
                        WallNode tempWall            = new WallNode(this.randomGenerator);
                        KeyValuePair <int, int> item = new KeyValuePair <int, int>(row, col);
                        this.walls.Add(item);
                        this.numOfWalls++;
                        this.internalMapStruct[row, col]  = tempWall;
                        this.optimizedMapStruct[row, col] = tempWall;
                    }
                    else
                    {
                        EmptyNode tempEmpty          = new EmptyNode();
                        KeyValuePair <int, int> item = new KeyValuePair <int, int>(row, col);
                        this.empties.Add(item);
                        this.numOfEmpties++;
                        this.internalMapStruct[row, col]  = tempEmpty;
                        this.optimizedMapStruct[row, col] = tempEmpty;
                    }
                }
            }
            this.GenerateDetailMap(this.internalMapStruct, this.detailedInternalMapStruct);
            this.GenerateDetailMap(this.optimizedMapStruct, this.detailedOptimizedInternalMapStruct);
        }
Exemple #6
0
        public void printMaps()
        {
            for (int row = 0; row < this.numGridsV; row++)
            {
                for (int col = 0; col < this.numGridsH; col++)
                {
                    if (this.detailedInternalMapStruct[row, col])
                    {
                        Console.Write("  ");
                    }
                    else
                    {
                        Console.Write("* ");
                    }
                    //Console.Write("{0} ", this.detailedInternalMapStruct[row, col]);
                }
                Console.WriteLine("");
            }

            for (int row = 0; row < this.numNodesV; row++)
            {
                for (int col = 0; col < this.numNodesH; col++)
                {
                    Node tempNode = this.internalMapStruct[row, col];

                    if (tempNode is RoomNode)
                    {
                        RoomNode room = (RoomNode)tempNode;
                        Console.Write("R ");
                    }
                    else if (tempNode is WallNode)
                    {
                        WallNode wall = (WallNode)tempNode;
                        Console.Write("W ");
                    }
                    if (tempNode is EmptyNode)
                    {
                        EmptyNode empty = (EmptyNode)tempNode;
                        Console.Write("E ");
                    }
                }
                Console.WriteLine("");
            }
        }
        private void setRoomInDetailedMap(Boolean[,] internalDetailedMapStruct, RoomNode room, int rowIndex, int colIndex)
        {
            int row = rowIndex;
            int col = colIndex;
            int index = 0;

            for (; col < colIndex + room.Width; col++)
            {
                if (!room.IsDoorIndex(index))
                {
                    internalDetailedMapStruct[row, col] = false;
                    internalDetailedMapStruct[row + room.Height - 1, col] = false;
                }
                index++;
            }
            col--;
            index = 0;
            for (; row < rowIndex + room.Height - 1; row++)
            {
                if (!room.IsDoorIndex(index))
                {
                    internalDetailedMapStruct[row, col] = false;
                    internalDetailedMapStruct[row, col - room.Width + 1] = false;
                }
                index++;
            }
        }
        public void GenerateRandomMap()
        {
            this.rooms = new ArrayList();
            this.walls = new ArrayList();
            this.empties = new ArrayList();
            this.numOfEmpties = 0;
            this.numOfRooms = 0;
            this.numOfWalls = 0;
            //Random randomGenerator = new Random(randomSeed);
            for (int row = 0; row < this.numNodesV; row++)
            {
                for (int col = 0; col < this.numNodesH; col++)
                {
                    if ( (row == 0 && col == 0) || (row == this.numNodesV - 1 && col == this.numNodesH - 1))
                    {
                        this.internalMapStruct[row, col] = new EmptyNode();
                        this.optimizedMapStruct[row, col] = new EmptyNode();
                        this.numOfEmpties++;
                        continue;
                    }

                    int randomType = this.randomGenerator.Next(3);
                    if (randomType == 0)
                    {
                        RoomNode tempRoom = new RoomNode(this.randomGenerator);
                        KeyValuePair<int, int> item = new KeyValuePair<int, int>(row, col);
                        this.rooms.Add(item);
                        this.numOfRooms++;
                        this.internalMapStruct[row, col] = tempRoom;
                        this.optimizedMapStruct[row, col] = tempRoom;

                    }
                    else if (randomType == 1)
                    {
                        WallNode tempWall = new WallNode(this.randomGenerator);
                        KeyValuePair<int, int> item = new KeyValuePair<int, int>(row, col);
                        this.walls.Add(item);
                        this.numOfWalls++;
                        this.internalMapStruct[row, col] = tempWall;
                        this.optimizedMapStruct[row, col] = tempWall;
                    }
                    else
                    {
                        EmptyNode tempEmpty = new EmptyNode();
                        KeyValuePair<int, int> item = new KeyValuePair<int, int>(row, col);
                        this.empties.Add(item);
                        this.numOfEmpties++;
                        this.internalMapStruct[row, col] = tempEmpty;
                        this.optimizedMapStruct[row, col] = tempEmpty;
                    }
                }
            }
            this.GenerateDetailMap(this.internalMapStruct, this.detailedInternalMapStruct);
            this.GenerateDetailMap(this.optimizedMapStruct, this.detailedOptimizedInternalMapStruct);
        }