Esempio n. 1
0
        protected SukiSchema()
        {
            name       = "";
            resolution = InputResolution.Trigger;
            data       = SukiData.Instance;

            CalculationFunction   = null;
            ReductionFunction     = null;
            ConditionFunction     = null;
            FloatBoundsFunction   = null;
            Vector2BoundsFunction = null;
            Vector3BoundsFunction = null;
        }
Esempio n. 2
0
        private void SetConditionFunction(Condition conditionOperation, float conditionOperand, float extentPercentage = 1f)
        {
            if (resolution != InputResolution.Trigger && resolution != InputResolution.Signal)
            {
                throw new System.Exception("Only Trigger and Signal resolution schemas can have Conditions.");
            }
            Condition op         = conditionOperation;
            float     operand    = conditionOperand;
            float     percentage = Mathf.Max(Mathf.Min(extentPercentage, 1f), 0f);

            ConditionFunction = (float value) => {
                bool ret = false;

                if (percentage != 1f)
                {
                    UpdateExtents(value);
                    // if the schema uses a percentage of extents, adjust the operand value
                    operand = percentage * maxExtent;
                    //Debug.Log(_id + " | Max Extent = " + maxExtent + " | operand = " + operand + " | value = " + value);
                }

                switch (op)
                {
                case Condition.GreaterThan:
                    ret = value > operand;
                    break;

                case Condition.GreatherThanEqual:
                    ret = value >= operand;
                    break;

                case Condition.Equal:
                    ret = value == operand;
                    break;

                case Condition.LessThanEqual:
                    ret = value <= operand;
                    break;

                case Condition.LessThan:
                    ret = value < operand;
                    break;

                default:
                    throw new System.Exception("Condition not recognized");
                }

                return(ret);
            };
        }