Пример #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();
    }
    public BasicBiomeIdentifier(BiomeDistribution distribution)
    {
        _distribution = distribution;
        int humuditySum    = _distribution.HumidityRange.Sum(i => i);
        int heightSum      = _distribution.HeightRange.Sum(i => i);
        int temperatureSum = _distribution.TemperatureRange.Sum(i => i);

        float totalHumudity = 0;

        _humudityVariety = new float[_distribution.HumidityVariety];
        for (var i = 0; i < _distribution.HumidityVariety; i++)
        {
            totalHumudity      += _distribution.HumidityRange[i];
            _humudityVariety[i] = totalHumudity / humuditySum;
        }

        float totalHeight = 0;

        _heightVariety = new float[_distribution.HeightVariety];
        for (var i = 0; i < _distribution.HeightVariety; i++)
        {
            totalHeight      += _distribution.HeightRange[i];
            _heightVariety[i] = totalHeight / heightSum;
        }

        float totalTemperature = 0;

        _temperatureVariety = new float[_distribution.TemperatureVariety];
        for (var i = 0; i < _distribution.TemperatureVariety; i++)
        {
            totalTemperature      += _distribution.TemperatureRange[i];
            _temperatureVariety[i] = totalTemperature / temperatureSum;
        }
    }