Пример #1
0
        protected LandLayout(ILandSettings settings)
        {
            Bounds   = settings.LandBounds;
            Settings = settings;

            var points    = GeneratePoints(settings.ZonesCount, Bounds, settings.ZonesDensity);
            var cells     = CellMeshGenerator.Generate(points, (Bounds)Bounds);
            var zonesType = SetZoneTypes(cells, settings);

            var zones = new ZoneLayout[points.Length];

            for (int i = 0; i < zones.Length; i++)
            {
                zones[i] = new ZoneLayout(zonesType[i], cells[i]);
            }

            Zones = zones;

            _idwCoeff = settings.IDWCoeff;
            var zoneMaxType = (int)settings.ZoneTypes.Max(z => z.Type);

            _influenceLookup = new float[zoneMaxType + 1];
            _zoneTypesCount  = zones.Where(z => z.Type != ZoneType.Empty).Distinct(ZoneLayout.TypeComparer).Count();
            _zoneSettings    = settings.ZoneTypes.ToArray();
        }
Пример #2
0
 public ColorMesher(ILandSettings settings, MesherSettings mesherSettings)
 {
     _settings = settings;
     _blocksColors = new Color[(int)mesherSettings.Blocks.Max(z => z.Block) + 1];
     foreach (var blockColor in mesherSettings.Blocks)
         _blocksColors[(int) blockColor.Block] = blockColor.Color;
 }
 public InfluenceMesher(ILandSettings settings)
 {
     _settings = settings;
     _zoneInfluenceColors = new Color[(int)settings.ZoneTypes.Max(z => z.Type) + 1];
     foreach (var zoneSettingse in settings.ZoneTypes)
         _zoneInfluenceColors[(int) zoneSettingse.Type] = zoneSettingse.LandColor;
     _zoneTypes = _settings.ZoneTypes.Select(z => z.Type).ToArray();
 }
Пример #4
0
        public TextureMesher(ILandSettings settings, MesherSettings meshSettings)
        {
            _meshSettings = meshSettings;

            foreach (var block in meshSettings.Blocks)
            {
                _blockSettings.Add(block.Block, block);
            }
        }
Пример #5
0
 public ColorMesher(ILandSettings settings, MesherSettings mesherSettings)
 {
     _settings     = settings;
     _blocksColors = new Color[(int)mesherSettings.Blocks.Max(z => z.Block) + 1];
     foreach (var blockColor in mesherSettings.Blocks)
     {
         _blocksColors[(int)blockColor.Block] = blockColor.Color;
     }
 }
        public TextureMesher(ILandSettings settings, MesherSettings meshSettings)
        {
            _meshSettings = meshSettings;

            foreach (var block in meshSettings.Blocks)
            {
                _blockSettings.Add(block.Block, block);
            }
        }
Пример #7
0
 public InfluenceMesher(ILandSettings settings)
 {
     _settings            = settings;
     _zoneInfluenceColors = new Color[(int)settings.ZoneTypes.Max(z => z.Type) + 1];
     foreach (var zoneSettingse in settings.ZoneTypes)
     {
         _zoneInfluenceColors[(int)zoneSettingse.Type] = zoneSettingse.LandColor;
     }
     _zoneTypes = _settings.ZoneTypes.Select(z => z.Type).ToArray();
 }
Пример #8
0
 public void CreateFlora(ILandSettings settings, IEnumerable<Vector3> positions)
 {
     if(positions != null)
         foreach (var position in positions)
         {
             var newTree = Instantiate(settings.Tree);
             newTree.transform.parent = transform;
             newTree.transform.position = position;
             newTree.transform.rotation = Quaternion.Euler(0, Random.Range(0, 359), 0);
         }
 }
Пример #9
0
 public void CreateStones(ILandSettings settings, IEnumerable<Vector3> positions)
 {
     if (positions != null)
         foreach (var position in positions)
         {
             var newStone = Instantiate(settings.Stone);
             newStone.transform.parent = transform;
             newStone.transform.localPosition = position;
             newStone.transform.rotation = Random.rotation;
             newStone.transform.localScale = Vector3.one*Random.Range(1, 5);
         }
 }
Пример #10
0
 public Land(LandLayout layout, ILandSettings settings)
 {
     _settings       = settings;
     _zones          = layout.Zones.Select(z => new Zone(z)).ToArray();
     Layout          = layout;
     _idwCoeff       = settings.IDWCoeff;
     _idwOffset      = settings.IDWOffset;
     _zoneMaxType    = settings.ZoneTypes.Max(z => z.Type);
     _zoneTypesCount = _zones.Where(z => z.Type != ZoneType.Empty).Distinct(Zone.TypeComparer).Count();
     _zoneSettings   = settings.ZoneTypes.ToArray();
     _chunksBounds   = new Bounds2i(settings.LandBounds.Min / (settings.BlocksCount * settings.BlockSize),
                                    settings.LandBounds.Max / (settings.BlocksCount * settings.BlockSize));
 }
Пример #11
0
 public Land(LandLayout layout, ILandSettings settings)
 {
     _settings = settings;
     _zones = layout.Zones.Select(z => new Zone(z)).ToArray();
     Layout = layout;
     _idwCoeff = settings.IDWCoeff;
     _idwOffset = settings.IDWOffset;
     _zoneMaxType = settings.ZoneTypes.Max(z => z.Type);
     _zoneTypesCount = _zones.Where(z => z.Type != ZoneType.Empty).Distinct(Zone.TypeComparer).Count();
     _zoneSettings = settings.ZoneTypes.ToArray();
     _chunksBounds = new Bounds2i(settings.LandBounds.Min/(settings.BlocksCount*settings.BlockSize),
         settings.LandBounds.Max/(settings.BlocksCount*settings.BlockSize));
 }
Пример #12
0
        protected override ZoneType[] SetZoneTypes(Cell[] cells, ILandSettings settings)
        {
            var zones = new ZoneType[cells.Length];
            var zoneTypes = settings.ZoneTypes.Select(z => z.Type).ToArray();

            for (var i = 0; i < zones.Length; i++)
            {
                var zoneType = zoneTypes[Random.Range(0, zoneTypes.Length)];
                zones[i] = zoneType;
            }

            return zones;
        }
Пример #13
0
 public void CreateFlora(ILandSettings settings, IEnumerable <Vector3> positions)
 {
     if (positions != null)
     {
         foreach (var position in positions)
         {
             var newTree = Instantiate(settings.Tree);
             newTree.transform.parent   = transform;
             newTree.transform.position = position;
             newTree.transform.rotation = Quaternion.Euler(0, Random.Range(0, 359), 0);
         }
     }
 }
Пример #14
0
        protected override ZoneType[] SetZoneTypes(Cell[] cells, ILandSettings settings)
        {
            var zones     = new ZoneType[cells.Length];
            var zoneTypes = settings.ZoneTypes.Select(z => z.Type).ToArray();

            for (var i = 0; i < zones.Length; i++)
            {
                var zoneType = zoneTypes[Random.Range(0, zoneTypes.Length)];
                zones[i] = zoneType;
            }

            return(zones);
        }
Пример #15
0
 public void CreateStones(ILandSettings settings, IEnumerable <Vector3> positions)
 {
     if (positions != null)
     {
         foreach (var position in positions)
         {
             var newStone = Instantiate(settings.Stone);
             newStone.transform.parent        = transform;
             newStone.transform.localPosition = position;
             newStone.transform.rotation      = Random.rotation;
             newStone.transform.localScale    = Vector3.one * Random.Range(1, 5);
         }
     }
 }
Пример #16
0
        protected ZoneGenerator(ZoneLayout zone, [NotNull] LandLayout land, [NotNull] ILandSettings landSettings)
        {
            if (land == null) throw new ArgumentNullException("land");
            if (landSettings == null) throw new ArgumentNullException("landSettings");

            _zone = zone;
            Land = land;
            _landSettings = landSettings;
            _blocksCount = landSettings.BlocksCount;
            _blockSize = landSettings.BlockSize;
            _chunkSize = _blocksCount*_blockSize;
            _zoneMaxType = landSettings.ZoneTypes.Max(z => z.Type);
            DefaultBlock = landSettings.ZoneTypes.First(z => z.Type == zone.Type).DefaultBlock;
        }
Пример #17
0
        public LandMap GenerateMap(ILandSettings settings)
        {
            var time = Stopwatch.StartNew();

            //Land = new Land(Layout, settings);

            //Generate land's chunks
            var map = new LandMap(settings, LandLayout);
            var landGenerator = new LandGenerator(LandLayout, settings);
            Map = landGenerator.Generate(map);

            time.Stop();
            //Debug.Log(Land.GetStaticstics());
            Debug.Log(string.Format("Generate map {0} ms", time.ElapsedMilliseconds));

            return Map;
        }
Пример #18
0
        public LandMap GenerateMap(ILandSettings settings)
        {
            var time = Stopwatch.StartNew();

            //Land = new Land(Layout, settings);

            //Generate land's chunks
            var map           = new LandMap(settings, LandLayout);
            var landGenerator = new LandGenerator(LandLayout, settings);

            Map = landGenerator.Generate(map);

            time.Stop();
            //Debug.Log(Land.GetStaticstics());
            Debug.Log(string.Format("Generate map {0} ms", time.ElapsedMilliseconds));

            return(Map);
        }
Пример #19
0
        protected ZoneGenerator(ZoneLayout zone, [NotNull] LandLayout land, [NotNull] ILandSettings landSettings)
        {
            if (land == null)
            {
                throw new ArgumentNullException("land");
            }
            if (landSettings == null)
            {
                throw new ArgumentNullException("landSettings");
            }

            _zone         = zone;
            Land          = land;
            _landSettings = landSettings;
            _blocksCount  = landSettings.BlocksCount;
            _blockSize    = landSettings.BlockSize;
            _chunkSize    = _blocksCount * _blockSize;
            _zoneMaxType  = landSettings.ZoneTypes.Max(z => z.Type);
            DefaultBlock  = landSettings.ZoneTypes.First(z => z.Type == zone.Type).DefaultBlock;
        }
        protected override ZoneType[] SetZoneTypes(Cell[] cells, ILandSettings settings)
        {
            var zoneTypes = settings.ZoneTypes.Select(z => z.Type).ToArray();
            var zones = new ZoneType[cells.Length];

            //Calculate zone types
            for (var i = 0; i < zones.Length; i++)
            {
                if (zones[i] == ZoneType.Empty)
                {
                    //Start cluster
                    var zoneType = zoneTypes[Random.Range(0, zoneTypes.Length)];
                    var clusterSize = Random.Range(2, 5);
                    var zoneIndexes = GetFreeNeighborsDepthFirst(cells, zones, i, clusterSize);
                    foreach (var zoneIndex in zoneIndexes)
                        zones[zoneIndex] = zoneType;
                }
            }

            return zones;
        }
Пример #21
0
        protected LandLayout(ILandSettings settings)
        {
            Bounds = settings.LandBounds;
            Settings = settings;

            var points = GeneratePoints(settings.ZonesCount, Bounds, settings.ZonesDensity);
            var cells = CellMeshGenerator.Generate(points, (Bounds) Bounds);
            var zonesType = SetZoneTypes(cells, settings);

            var zones = new ZoneLayout[points.Length];
            for (int i = 0; i < zones.Length; i++)
                zones[i] = new ZoneLayout(zonesType[i], cells[i]);

            Zones = zones;

            _idwCoeff = settings.IDWCoeff;
            var zoneMaxType = (int)settings.ZoneTypes.Max(z => z.Type);
            _influenceLookup = new float[zoneMaxType + 1];
            _zoneTypesCount = zones.Where(z => z.Type != ZoneType.Empty).Distinct(ZoneLayout.TypeComparer).Count();
            _zoneSettings = settings.ZoneTypes.ToArray();
        }
        protected override ZoneType[] SetZoneTypes(Cell[] cells, ILandSettings settings)
        {
            var zoneTypes = settings.ZoneTypes.Select(z => z.Type).ToArray();
            var zones     = new ZoneType[cells.Length];

            //Calculate zone types
            for (var i = 0; i < zones.Length; i++)
            {
                if (zones[i] == ZoneType.Empty)
                {
                    //Start cluster
                    var zoneType    = zoneTypes[Random.Range(0, zoneTypes.Length)];
                    var clusterSize = Random.Range(2, 5);
                    var zoneIndexes = GetFreeNeighborsDepthFirst(cells, zones, i, clusterSize);
                    foreach (var zoneIndex in zoneIndexes)
                    {
                        zones[zoneIndex] = zoneType;
                    }
                }
            }

            return(zones);
        }
Пример #23
0
 public TestLayout(ILandSettings settings)
     : base(settings)
 {
 }
 public HillsGenerator(ZoneLayout zone, LandLayout land, ILandSettings landSettings) : base(zone, land, landSettings)
 {
 }
Пример #25
0
 public RandomLayout(ILandSettings settings)
     : base(settings)
 {
 }
 public PoissonClusteredLayout(ILandSettings settings) : base(settings)
 {
 }
Пример #27
0
 public TestLayout(ILandSettings settings) : base(settings)
 {
 }
Пример #28
0
 public RandomLayout(ILandSettings settings) : base(settings)
 {
 }
Пример #29
0
 public ConeGenerator(ZoneLayout zone, [NotNull] LandLayout land, [NotNull] ILandSettings landSettings) : base(zone, land, landSettings)
 {
 }
 public PoissonClusteredLayout(ILandSettings settings)
     : base(settings)
 {
 }
Пример #31
0
 protected abstract ZoneType[] SetZoneTypes(Cell[] cells, ILandSettings settings);
Пример #32
0
 public LandMap(ILandSettings settings, LandLayout layout)
 {
     _settings = settings;
     Layout    = layout;
 }
Пример #33
0
 public LandMap(ILandSettings settings, LandLayout layout)
 {
     _settings = settings;
     Layout = layout;
 }
Пример #34
0
 public LandGenerator(LandLayout land, ILandSettings settings)
 {
     _land     = land;
     _settings = settings;
 }
Пример #35
0
 protected abstract ZoneType[] SetZoneTypes(Cell[] cells, ILandSettings settings);
Пример #36
0
 public LandGenerator(LandLayout land, ILandSettings settings)
 {
     _land = land;
     _settings = settings;
 }
 public DefaultGenerator(ZoneLayout zone, LandLayout land, ILandSettings landSettings) : base(zone, land, landSettings)
 {
     
 }
Пример #38
0
 public LakeGenerator(ZoneLayout zone, LandLayout land, ILandSettings landSettings) : base(zone, land, landSettings)
 {
 }
 public MountainsGenerator(ZoneLayout zone, LandLayout land, ILandSettings landSettings) : base(zone, land, landSettings)
 {
 }