Exemplo 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]);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void createCave(Game _game, Vector2 Position, Vector2 _size, RoomDoorPositionsInfo DoorPositions, RoomAmbiance ambient)
        {
            CaveGenerator cavegen = new CaveGenerator();
            _solidGrid = cavegen.GenerateCave(_size, DoorPositions);

            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)
                    {

                        bool solid = false;
                        foreach (var coord in Globals.GetMoore(x, y))
                        {
                            if (_solidGrid[coord.Item1, coord.Item2] == false) solid = true;
                        }
                        if (solid == true)
                        {
                            var solidblock = new SolidSmallBlock01(_game, new Vector2(Position.X + (x * Globals.SmallGridSize.X),
                                                                              Position.Y + (y * Globals.SmallGridSize.Y)), ambient.RoomColour
                                                                              , MaterialsStats.Rock01);
                            DestructibleWalls.Add(solidblock);
                        }
                        else
                        {
                            var wallblock = new SmallBlock01(_game, new Vector2(Position.X + (x * Globals.SmallGridSize.X),
                                                                              Position.Y + (y * Globals.SmallGridSize.Y)), ambient.RoomColour);
                            _interiorSpriteList.Add(wallblock);
                        }
                    }
                }
            }
        }