コード例 #1
0
    public void Init()
    {
        _paramTerrain      = (TerrainParameter)AssetDatabase.LoadAssetAtPath(_terrainParamPath, typeof(TerrainParameter));
        _paramWeather      = (WeatherParameter)AssetDatabase.LoadAssetAtPath(_weatherParamPath, typeof(WeatherParameter));
        _paramTemperature  = (TemperatureParameter)AssetDatabase.LoadAssetAtPath(_temperatureParamPath, typeof(TemperatureParameter));
        _paramMana         = (ManaParameter)AssetDatabase.LoadAssetAtPath(_manaParamPath, typeof(ManaParameter));
        _paramRain         = (RainParameter)AssetDatabase.LoadAssetAtPath(_rainParamPath, typeof(RainParameter));
        _biomeDistribution = (BiomeDistribution)AssetDatabase.LoadAssetAtPath(_biomeDistributionPath, typeof(BiomeDistribution));
        _terrainColor      = (ColorRangeDistribution)AssetDatabase.LoadAssetAtPath(_terrainColorRangePath, typeof(ColorRangeDistribution));
        _weatherColor      = (ColorRangeDistribution)AssetDatabase.LoadAssetAtPath(_weatherColorRangePath, typeof(ColorRangeDistribution));
        _manaColor         = (ColorRangeDistribution)AssetDatabase.LoadAssetAtPath(_manaColorRangePath, typeof(ColorRangeDistribution));
        _rainColor         = (ColorRangeDistribution)AssetDatabase.LoadAssetAtPath(_rainColorRangePath, typeof(ColorRangeDistribution));

        _serializedObj             = new SerializedObject(this);
        _propertyParamTerrain      = _serializedObj.FindProperty("_paramTerrain");
        _propertyParamWeather      = _serializedObj.FindProperty("_paramWeather");
        _propertyParamTemperature  = _serializedObj.FindProperty("_paramTemperature");
        _propertyParamMana         = _serializedObj.FindProperty("_paramMana");
        _propertyParamRain         = _serializedObj.FindProperty("_paramRain");
        _propertyBiomeDistribution = _serializedObj.FindProperty("_biomeDistribution");
        _propertyTerrainColorRange = _serializedObj.FindProperty("_terrainColor");
        _propertyWeatherColorRange = _serializedObj.FindProperty("_weatherColor");
        _propertyManaColorRange    = _serializedObj.FindProperty("_manaColor");
        _propertyRainColorRange    = _serializedObj.FindProperty("_rainColor");
        _propertyWidth             = _serializedObj.FindProperty("_width");
        _propertyHeight            = _serializedObj.FindProperty("_height");
        _propertySeed = _serializedObj.FindProperty("_seed");

        _noticeTxt    = string.Empty;
        _worldTexture = null;
        _tileData     = null;
        _executor.Clear();
    }
コード例 #2
0
    public IEnumerator GenerateRiverMap(
        int width,
        int height,
        float[] heightMap,
        RainParameter para,
        IReturn <float[]> ret)
    {
        _width  = width;
        _height = height;
        _para   = para;

        var startLocations = heightMap
                             .Select((h, idx) => new { h, idx })
                             .OrderByDescending(i => i.h)
                             .Take(heightMap.Length / (int)(1 / _para.HEIGHT_LOCATIONS))
                             .Select(o => o.idx).ToArray();

        _directionMap = new int[heightMap.Length];
        _rainMap      = new int[heightMap.Length];

        yield return(_GenerateDirationMap(heightMap));

        yield return(_GenerateRainMap(startLocations, heightMap));

        var rains   = _rainMap.Where(i => i > 0);
        var average = (rains.Sum() / rains.Count()) * _para.RIVER_AVERAGE_FACTOR;

        var rainResult = _rainMap.Select(i => Mathf.Min(i / average, 1)).ToArray();

        ret.Accept(rainResult);
    }