Exemplo n.º 1
0
    private static void ProcessDetails(Dictionary <int, int[, ]> details, DslExpression.DslCalculator calc, string proc, int cx, int cy, int r)
    {
        int x  = cx - r;
        int y  = cy - r;
        int w  = r * 2;
        int h  = r * 2;
        int r2 = r * r;

        for (int ix = 0; ix < w; ++ix)
        {
            for (int iy = 0; iy < h; ++iy)
            {
                int xi = x + ix;
                int yi = y + iy;
                int dx = xi - cx;
                int dy = yi - cy;
                if (dx * dx + dy * dy <= r2)
                {
                    foreach (var pair in details)
                    {
                        int layer  = pair.Key;
                        var detail = pair.Value[xi, yi];
                        calc.SetVariable("detail", detail);
                        calc.Calc(proc, xi, yi, layer);
                        pair.Value[xi, yi] = (int)Convert.ChangeType(calc.GetVariable("detail"), typeof(int));
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
    private static bool ExecuteUpdate(string dslFile)
    {
        try {
            if (!File.Exists(dslFile))
            {
                return(false);
            }
            bool        ret  = false;
            string      txt  = File.ReadAllText(dslFile);
            Dsl.DslFile file = new Dsl.DslFile();
            if (file.Load(dslFile, (string msg) => { Debug.LogError(msg); }))
            {
                s_Calculator = new DslExpression.DslCalculator();
                s_Calculator.Init();
                s_Calculator.SetGlobalVariable("@@processkey", s_ProcessKey);
                s_Calculator.SetGlobalVariable("@@haskey", s_HasKey);
                s_Calculator.SetGlobalVariable("global", DslExpression.CalculatorValue.FromObject(GlobalVariables.Instance));
                s_Calculator.Register("verifycacheserver", new DslExpression.ExpressionFactoryHelper <VerifyCacheServerExp>());

                foreach (var info in file.DslInfos)
                {
                    s_Calculator.LoadDsl(info);
                }
                object retObj = s_Calculator.Calc("main");
                if (null != retObj)
                {
                    ret = (bool)System.Convert.ChangeType(retObj, typeof(bool));
                }
            }
            return(ret);
        }
        catch {
            return(false);
        }
    }
Exemplo n.º 3
0
    private static void ProcessAlphamaps(float[,,] alphamaps, DslExpression.DslCalculator calc, string proc, int cx, int cy, int r)
    {
        int alphanum = alphamaps.GetLength(2);
        int x        = cx - r;
        int y        = cy - r;
        int w        = r * 2;
        int h        = r * 2;
        int r2       = r * r;

        for (int ix = 0; ix < w; ++ix)
        {
            for (int iy = 0; iy < h; ++iy)
            {
                int xi = x + ix;
                int yi = y + iy;
                int dx = xi - cx;
                int dy = yi - cy;
                if (dx * dx + dy * dy <= r2)
                {
                    float[] alphas = calc.GetVariable("alphas") as float[];
                    for (int i = 0; i < alphanum; ++i)
                    {
                        alphas[i] = alphamaps[xi, yi, i];
                    }
                    var v = calc.Calc(proc, xi, yi);
                    for (int i = 0; i < alphanum; ++i)
                    {
                        alphamaps[xi, yi, i] = alphas[i];
                    }
                }
            }
        }
    }
Exemplo n.º 4
0
    private static void ProcessHeights(float[,] datas, DslExpression.DslCalculator calc, string proc, int cx, int cy, int r)
    {
        int x  = cx - r;
        int y  = cy - r;
        int w  = r * 2;
        int h  = r * 2;
        int r2 = r * r;

        for (int ix = 0; ix < w; ++ix)
        {
            for (int iy = 0; iy < h; ++iy)
            {
                int xi = x + ix;
                int yi = y + iy;
                int dx = xi - cx;
                int dy = yi - cy;
                if (dx * dx + dy * dy <= r2)
                {
                    calc.SetVariable("height", datas[yi, xi]);
                    calc.Calc(proc, xi, yi);
                    datas[yi, xi] = (float)Convert.ChangeType(calc.GetVariable("height"), typeof(float));
                }
            }
        }
    }
Exemplo n.º 5
0
 private static void ProcessHeights(float[,] datas, DslExpression.DslCalculator calc, string proc, int x, int y, int w, int h)
 {
     for (int ix = 0; ix < w; ++ix)
     {
         for (int iy = 0; iy < h; ++iy)
         {
             int xi = x + ix;
             int yi = y + iy;
             calc.SetVariable("height", datas[yi, xi]);
             calc.Calc(proc, xi, yi);
             datas[yi, xi] = (float)Convert.ChangeType(calc.GetVariable("height"), typeof(float));
         }
     }
 }
Exemplo n.º 6
0
 private static void ProcessDetails(Dictionary <int, int[, ]> details, DslExpression.DslCalculator calc, string proc, int x, int y, int w, int h)
 {
     for (int ix = 0; ix < w; ++ix)
     {
         for (int iy = 0; iy < h; ++iy)
         {
             int xi = x + ix;
             int yi = y + iy;
             foreach (var pair in details)
             {
                 int layer  = pair.Key;
                 var detail = pair.Value[xi, yi];
                 calc.SetVariable("detail", detail);
                 calc.Calc(proc, xi, yi, layer);
                 pair.Value[xi, yi] = (int)Convert.ChangeType(calc.GetVariable("detail"), typeof(int));
             }
         }
     }
 }
Exemplo n.º 7
0
    private static void ProcessAlphamaps(float[,,] alphamaps, DslExpression.DslCalculator calc, string proc, int x, int y, int w, int h)
    {
        int alphanum = alphamaps.GetLength(2);

        for (int ix = 0; ix < w; ++ix)
        {
            for (int iy = 0; iy < h; ++iy)
            {
                int     xi     = x + ix;
                int     yi     = y + iy;
                float[] alphas = calc.GetVariable("alphas") as float[];
                for (int i = 0; i < alphanum; ++i)
                {
                    alphas[i] = alphamaps[xi, yi, i];
                }
                var v = calc.Calc(proc, xi, yi);
                for (int i = 0; i < alphanum; ++i)
                {
                    alphamaps[xi, yi, i] = alphas[i];
                }
            }
        }
    }