コード例 #1
0
        private void CopyConnectionConditions(EditableConnection editableConnection, Connection connection)
        {
            List <EditableCondition> editableConditions = editableConnection.Conditions;

            for (int i = 0; i < editableConditions.Count; i++)
            {
                if (editableConditions[i].ConditionType == EditableCondition.eConditionType.BoolCondition)
                {
                    EditableBoolCondition ebc = editableConditions[i] as EditableBoolCondition;

                    BoolCondition bc = new BoolCondition();
                    bc.ParameterName = ebc.ParameterName;
                    switch (ebc.CheckType)
                    {
                    case EditableBoolCondition.eCheckType.equal:
                        bc.CheckType = BoolCondition.eCheckType.equal;
                        break;

                    case EditableBoolCondition.eCheckType.notEqual:
                        bc.CheckType = BoolCondition.eCheckType.notEqual;
                        break;
                    }
                    bc.RequiredValue = ebc.RequiredValue;

                    connection.Conditions.Add(bc);
                }
                else if (editableConditions[i].ConditionType == EditableCondition.eConditionType.IntCondition)
                {
                    EditableIntCondition eic = editableConditions[i] as EditableIntCondition;

                    IntCondition ic = new IntCondition();
                    ic.ParameterName = eic.ParameterName;
                    switch (eic.CheckType)
                    {
                    case EditableIntCondition.eCheckType.equal:
                        ic.CheckType = IntCondition.eCheckType.equal;
                        break;

                    case EditableIntCondition.eCheckType.greaterThan:
                        ic.CheckType = IntCondition.eCheckType.greaterThan;
                        break;

                    case EditableIntCondition.eCheckType.lessThan:
                        ic.CheckType = IntCondition.eCheckType.lessThan;
                        break;
                    }
                    ic.RequiredValue = eic.RequiredValue;

                    connection.Conditions.Add(ic);
                }
            }
        }
コード例 #2
0
        private bool ConditionsMet(Connection connection)
        {
            List <Condition> conditions = connection.Conditions;

            for (int i = 0; i < conditions.Count; i++)
            {
                bool conditionMet = false;

                // Int condition
                if (conditions[i].ConditionType == Condition.eConditionType.IntCondition)
                {
                    IntCondition condition = conditions[i] as IntCondition;

                    string       paramName     = condition.ParameterName;
                    int          requiredValue = condition.RequiredValue;
                    eParamStatus status;
                    int          currentValue = m_conversation.GetInt(paramName, out status);

                    switch (condition.CheckType)
                    {
                    case IntCondition.eCheckType.equal:
                        conditionMet = (currentValue == requiredValue);
                        break;

                    case IntCondition.eCheckType.greaterThan:
                        conditionMet = (currentValue > requiredValue);
                        break;

                    case IntCondition.eCheckType.lessThan:
                        conditionMet = (currentValue < requiredValue);
                        break;
                    }
                }
                // Bool condition
                if (conditions[i].ConditionType == Condition.eConditionType.BoolCondition)
                {
                    BoolCondition condition = conditions[i] as BoolCondition;

                    string       paramName     = condition.ParameterName;
                    bool         requiredValue = condition.RequiredValue;
                    eParamStatus status;
                    bool         currentValue = m_conversation.GetBool(paramName, out status);

                    switch (condition.CheckType)
                    {
                    case BoolCondition.eCheckType.equal:
                        conditionMet = (currentValue == requiredValue);
                        break;

                    case BoolCondition.eCheckType.notEqual:
                        conditionMet = (currentValue != requiredValue);
                        break;
                    }
                }

                if (!conditionMet)
                {
                    return(false);
                }
            }

            return(true);
        }