示例#1
0
文件: ExprTree.cs 项目: otaviog/Fruki
        public float Eval(EvalContext ctx)
        {
            float val,
                leftval = left.Eval(ctx),
                rightval = right.Eval(ctx);

            switch (op)
            {
                case '+':
                    val = leftval + rightval;
                    break;
                case '-':
                    val = leftval - rightval;
                    break;
                case '*':
                    val = leftval * rightval;
                    break;
                case '/':
                    val = leftval / rightval;
                    break;
                case 'b':
                default:
                    val = rightval;
                    break;
            }

            return val;
        }
示例#2
0
文件: ExprTree.cs 项目: otaviog/Fruki
        public float Eval(EvalContext ctx)
        {
            StatesSet stSet = ctx.CurrStatesSet;
            State state = ctx.CurrState;
            int autonomusIdx = stSet.GetAutonomusStateIndice(autonomusName);

            Autonomus autonomus = ctx.CurrSAN.AutonomusAt(autonomusIdx);

            return (float) autonomus.NodeAt(state[stSet.GetAutonomusStateIndice(autonomusName)]);
        }
示例#3
0
文件: ExprTree.cs 项目: otaviog/Fruki
 public float Eval(EvalContext ctx)
 {
     return value;
 }
示例#4
0
文件: ExprTree.cs 项目: otaviog/Fruki
        public float Eval(EvalContext ctx)
        {
            bool bval = false;
            float leftval = left.Eval(ctx);
            float rightval = right.Eval(ctx);
            switch (op)
            {
                case Operators.AND:
                    bval = IsNotZero(leftval) && IsNotZero(rightval);
                    break;
                case Operators.OR:
                    bval = IsNotZero(leftval) || IsNotZero(rightval);
                    break;
                case Operators.XOR:
                    bval = bval ^ IsNotZero(rightval);
                    break;
                case Operators.EQ:
                    bval = Math.Abs(leftval - rightval) < float.Epsilon;
                    break;
                case Operators.GT:
                    bval = leftval > rightval;
                    break;
                case Operators.LT:
                    bval = leftval < rightval;
                    break;
                case Operators.EGT:
                    bval = leftval >= rightval;
                    break;
                case Operators.ELT:
                    bval = leftval <= rightval;
                    break;
                case Operators.NOTEQ:
                    bval = Math.Abs(leftval - rightval) >= float.Epsilon;
                    break;
                case Operators.UNARY:
                    bval = rightval > 0.0f ? true : false;
                    break;
            }

            return bval ? 1.0f : 0.0f;
        }