Esempio n. 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 void DrawTexture()
    {
        _executor.Clear();
        var MakeMapM = new Utility.Coroutine(_ShowHeightMap());

        _executor.Add(MakeMapM);
    }
Esempio n. 3
0
        /// <summary>
        /// Return a iterator block that executes the monad. See <see cref="IMonad{T}.Do"/>.
        /// </summary>
        public IEnumerator Do()
        {
            Executor executor = new Executor();

            using (var defer = new Defer())
            {
                defer.Add(() =>
                {
                    foreach (Coroutine c in executor)
                    {
                        c.Dispose();
                    }
                    executor.Clear();
                });

                for (int i = 0; i < _ms.Length; ++i)
                {
                    executor.Add(_Do(_ms[i]));
                }

                executor.Resume(Coroutine.Delta);
                while (!executor.Finished)
                {
                    if (Error != null)
                    {
                        yield break;
                    }
                    yield return(null);

                    executor.Resume(Coroutine.Delta);
                }

                if (Error != null)
                {
                    yield break;
                }
                Result = System.Array.ConvertAll(_ms, m => m.Result);
            }
        }
Esempio n. 4
0
 public override void Eval(Executor exec)
 {
     exec.Clear();
 }
Esempio n. 5
0
        /// <summary>
        /// We attempt to execute an expression (list of functions) on an empty stack. 
        /// When no exception is raised we know that the subexpression can be replaced with anything 
        /// that generates the values. 
        /// </summary>
        static CatExpr PartialEval(Executor exec, CatExpr fxns)
        {
            // Recursively partially evaluate all quotations
            for (int i = 0; i < fxns.Count; ++i)
            {
                Function f = fxns[i];
                if (f is PushFunction)
                {
                    PushFunction q = f as PushFunction;
                    CatExpr tmp = PartialEval(new Executor(), q.GetSubFxns());
                    fxns[i] = new PushFunction(tmp);
                }
            }

            CatExpr ret = new CatExpr();
            object[] values = null;

            int j = 0;
            while (j < fxns.Count)
            {
                try
                {
                    Function f = fxns[j];

                    if (f is DefinedFunction)
                    {
                        f.Eval(exec);
                    }
                    else
                    {
                        if (f.GetFxnType() == null)
                            throw new Exception("no type availables");

                        if (f.GetFxnType().HasSideEffects())
                            throw new Exception("can't perform partial execution when an expression has side-effects");

                        f.Eval(exec);
                    }

                    // at each step, we have to get the values stored so far
                    // since they could keep changing and any exception
                    // will obliterate the old values.
                    values = exec.GetStackAsArray();
                }
                catch
                {
                    if (values != null)
                    {
                        // Copy all of the values from the previous good execution 
                        for (int k = values.Length - 1; k >= 0; --k)
                            ret.Add(ValueToFunction(values[k]));
                    }
                    ret.Add(fxns[j]);
                    exec.Clear();
                    values = null;
                }
                j++;
            }

            if (values != null)
                for (int l = values.Length - 1; l >= 0; --l)
                    ret.Add(ValueToFunction(values[l]));

            return ret;
        }