Пример #1
0
        /// <summary>
        /// Determines whether this instance is satisfied.
        /// </summary>
        /// <param name="state">The state of the AI.</param>
        /// <returns></returns>
        /// <exception cref="System.Exception">Invalid equality type in IntCondtion.IsSatisfied().</exception>
        public override bool IsSatisfied(AIState state)
        {
            var value = state.GetFloat(ID);

            if (!value.HasValue)
            {
                return false;
            }

            switch (Equality)
            {
                case EqualityType.Equals:
                    return value.Equals(Value);
                case EqualityType.NotEquals:
                    return !value.Equals(Value);
                case EqualityType.GreaterThan:
                    return value > Value;
                case EqualityType.LessThan:
                    return value < Value;
                case EqualityType.GreaterThanOrEqual:
                    return value >= Value;
                case EqualityType.LessThanOrEqual:
                    return value <= Value;
                default:
                    throw new Exception("Invalid equality type in FloatCondtion.IsSatisfied().");
            }
        }