Пример #1
0
    // CTOR

    public AchievementUnlocker(AchievementUnlockerDescriptor i_Descriptor)
    {
        m_AchievementId = i_Descriptor.achievementId;

        m_CheckOnEvent = i_Descriptor.checkOnEvent;
        m_EventName    = i_Descriptor.eventName;

        m_Conditions = new List <UserStatCondition>();

        for (int conditionDescriptorIndex = 0; conditionDescriptorIndex < i_Descriptor.conditionsCount; ++conditionDescriptorIndex)
        {
            UserStatConditionDescriptor conditionDescriptor = i_Descriptor.GetConditionDescriptor(conditionDescriptorIndex);
            if (conditionDescriptor != null)
            {
                UserStatCondition condition = conditionDescriptor.BuildCondition();
                if (condition != null)
                {
                    m_Conditions.Add(condition);
                }
            }
        }
    }
Пример #2
0
    public UserStatCondition BuildCondition()
    {
        UserStatCondition condition = null;

        UserStatCondition firstCondition  = null;
        UserStatCondition secondCondition = null;

        UserStatCondition subCondition = null;

        switch (m_ConditionType)
        {
        case UserStatConditionType.Int:
            condition = new UserStatIntCondition(m_StatId, m_NumericConditionType, m_IntValue);
            break;

        case UserStatConditionType.Bool:
            condition = new UserStatBoolCondition(m_StatId, m_BooleanConditionType);
            break;

        case UserStatConditionType.Float:
            condition = new UserStatFloatCondition(m_StatId, m_NumericConditionType, m_FloatValue);
            break;

        case UserStatConditionType.String:
            condition = new UserStatStringCondition(m_StatId, m_StringConditionType, m_StringValue);
            break;

        case UserStatConditionType.And:

            firstCondition  = m_FirstCondition.BuildCondition();
            secondCondition = m_SecondCondition.BuildCondition();

            condition = new UserStatAndCondition(firstCondition, secondCondition);

            break;

        case UserStatConditionType.Or:

            firstCondition  = m_FirstCondition.BuildCondition();
            secondCondition = m_SecondCondition.BuildCondition();

            condition = new UserStatOrCondition(firstCondition, secondCondition);

            break;

        case UserStatConditionType.Xor:

            firstCondition  = m_FirstCondition.BuildCondition();
            secondCondition = m_SecondCondition.BuildCondition();

            condition = new UserStatXorCondition(firstCondition, secondCondition);

            break;

        case UserStatConditionType.Not:

            subCondition = m_Condition.BuildCondition();

            condition = new UserStatNotCondition(subCondition);

            break;
        }

        return(condition);
    }