Ejemplo n.º 1
0
    private bool Evaluate()
    {
        bool unlock = (m_Conditions.Count > 0);

        for (int conditionIndex = 0; conditionIndex < m_Conditions.Count; ++conditionIndex)
        {
            UserStatCondition condition = m_Conditions[conditionIndex];
            if (condition != null)
            {
                bool conditionValue = condition.Evaluate();
                unlock &= conditionValue;
            }
        }

        return(unlock);
    }
Ejemplo n.º 2
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);
                }
            }
        }
    }
Ejemplo n.º 3
0
    // LOGIC

    public void Initialize()
    {
        StatsModule statsModule = GameServices.GetModuleMain <StatsModule>();

        if (statsModule != null)
        {
            for (int conditionIndex = 0; conditionIndex < m_Conditions.Count; ++conditionIndex)
            {
                UserStatCondition condition = m_Conditions[conditionIndex];
                if (condition != null)
                {
                    condition.Initialize(statsModule);
                }
            }
        }

        if (m_CheckOnEvent)
        {
            if (m_EventName != "")
            {
                Messenger.AddListener(m_EventName, OnEvent);
            }
        }
    }
    // CTOR

    public UserStatNotCondition(UserStatCondition i_Condition)
    {
        m_Condition = i_Condition;
    }
    // CTOR

    public UserStatOrCondition(UserStatCondition i_FirstCondition, UserStatCondition i_SecondCondition)
    {
        m_FirstCondition  = i_FirstCondition;
        m_SecondCondition = i_SecondCondition;
    }
Ejemplo n.º 6
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);
    }