Beispiel #1
0
 public DoorPlacer(Map map, MapSettingsData mapSettingsData, Transform mapHolder
                   , RoomController[,] roomControllersMatrix)
 {
     _map                   = map;
     _mapSettingsData       = mapSettingsData;
     _mapHolder             = mapHolder;
     _roomControllersMatrix = roomControllersMatrix;
 }
        public void Initialize(MapSettingsData data, Vector3 offset, Transform mapHolder)
        {
            _mapSettingsData = data;
            _offset          = offset;
            _mapHolder       = mapHolder;

            map = new Map(data.mapSize.width, data.mapSize.height);
            _roomControllersMatrix = new RoomController[data.mapSize.width, data.mapSize.height];
        }
Beispiel #3
0
    private void CreateRivers(MapSettingsData data)
    {
        System.Random prng             = new System.Random(data.noiseSetting.seed);
        var           terrainOnlyHexes = Hexes.ToList().Where(h => h.Elevation > 0);

        for (int i = 0; i < data.riverCount; i++)
        {
            int riverLength = prng.Next((int)data.riverLengthMinMax[0], (int)data.riverLengthMinMax[1]);

            // Start the river
            HexObject currentHex = terrainOnlyHexes.ToArray()[prng.Next(0, terrainOnlyHexes.Count())];
            // Get neighbour to connect to
            HexObject nextLowestNeighbour = Instance.FindHexObject(Hex.Neighbours(currentHex.Hex).OrderBy(n => Instance.FindHexObject(n.cubeCoords).Elevation).FirstOrDefault().cubeCoords);

            for (int l = 0; l < riverLength; l++)
            {
                if (currentHex.Elevation == 0)
                {
                    break;
                }

                if (currentHex == nextLowestNeighbour)
                {
                    continue;
                }

                currentHex.SetOutgoingRiver(Hex.Direction(currentHex.Hex, nextLowestNeighbour.Hex));
                if (nextLowestNeighbour == null)
                {
                    break;
                }

                currentHex = nextLowestNeighbour;
                if (currentHex == null)
                {
                    break;
                }

                try
                {
                    var neighbours      = Hex.Neighbours(currentHex.Hex);
                    var hexObjectToFind = neighbours.OrderBy(n => Instance.FindHexObject(n.cubeCoords).Elevation).FirstOrDefault();
                    nextLowestNeighbour = Instance.FindHexObject(hexObjectToFind.cubeCoords);
                }
                catch
                {
                    continue;
                }
            }
        }
    }
Beispiel #4
0
 private void Construct(MapSettingsData data)
 {
     mapSettingsData = data;
 }
 private void Construct(MapSettingsData map)
 {
     mapSettingsData = map;
 }
 public CorridorCreator(MapSettingsData mapSettingsData)
 {
     this.mapSettingsData = mapSettingsData;
 }