Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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)]);
        }
Esempio n. 3
0
 public float Eval(EvalContext ctx)
 {
     return value;
 }
Esempio n. 4
0
        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;
        }