Esempio n. 1
0
        public Cave(Game _game, BigRoom room)
        {
            CaveGenerator cavegen = new CaveGenerator();
            _solidGrid = cavegen.GenerateCave(room._size, room.DoorPositions);
            var CaveBlockArray = new CaveBlock[_solidGrid.GetLength(0), _solidGrid.GetLength(1)];

            for (int x = 1; x < _solidGrid.GetLength(0) - 1; x++)
            {
                for (int y = 1; y < _solidGrid.GetLength(1) - 1; y++)
                {
                    if (_solidGrid[x, y] == true)
                    {
                        room.RoomOccupiedGrid[x - 1, y - 1] = true;
                        bool solid = false;
                        foreach (var coord in Globals.GetVonNeumann(new Coord(x,y)))
                        {
                            if (_solidGrid[coord.X, coord.Y] == false) solid = true;
                        }
                        if (solid == true)
                        {
                            CaveBlockArray[x, y] = new CaveBlock(_game, new Vector2(room.Position.X + (x * Globals.SmallGridSize.X),
                                                                              room.Position.Y + (y * Globals.SmallGridSize.Y)), room.RoomAmbient.RoomColour
                                                                              , MaterialsStats.Rock01, true,room.RoomAmbient.RoomTileset,room.RoomAmbient.GlowColour);
                        }
                        else
                        {
                            CaveBlockArray[x, y] = new CaveBlock(_game, new Vector2(room.Position.X + (x * Globals.SmallGridSize.X),
                                                                              room.Position.Y + (y * Globals.SmallGridSize.Y)), room.RoomAmbient.RoomColour
                                                                              , MaterialsStats.Rock01, false, room.RoomAmbient.RoomTileset, room.RoomAmbient.GlowColour);

                        }
                        DestructibleWalls.Add(CaveBlockArray[x, y]);
                    }
                }
            }
            for (int x = 1; x < CaveBlockArray.GetLength(0) - 1; x++)
            {
                for (int y = 1; y < CaveBlockArray.GetLength(1) - 1; y++)
                {
                    if (CaveBlockArray[x, y] != null)
                    {
                        foreach (var coord in Globals.GetVonNeumann(new Coord(x,y)))
                        {
                            if (CaveBlockArray[coord.X, coord.Y] != null)
                            {
                                CaveBlockArray[x, y].AddNeighbour(CaveBlockArray[coord.X, coord.Y]);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 public void AddNeighbour(CaveBlock neighbour)
 {
     NeighbourList.Add(neighbour);
 }