Example #1
0
    // -----------------------------------------------------------------------------------
    // Modify
    // -----------------------------------------------------------------------------------
    public void Modify(int value, bool showPopup = true)
    {
        bool bReset = false;

        foreach (UCE_WorldEventData data in template.thresholdData)
        {
            if (data.thresholdType == ThresholdType.Below &&
                count > data.thresholdValue &&
                count + value <= data.thresholdValue)
            {
                if (data.limitToThreshold)
                {
                    count = data.thresholdValue;
                }
                else if (data.resetOnThreshold)
                {
                    bReset = true;
                }

                if (!string.IsNullOrWhiteSpace(data.messageOnThreshold) && showPopup)
                {
                    NetworkManagerMMO.UCE_BroadCastPopupToOnlinePlayers(template, data.messageParticipantsOnly, data.messageOnThreshold);
                }

                if (data.stopFurtherThresholdChecks)
                {
                    break;
                }
            }
            else if (data.thresholdType == ThresholdType.Above &&
                     count < data.thresholdValue &&
                     count + value >= data.thresholdValue)
            {
                if (data.limitToThreshold)
                {
                    count = data.thresholdValue;
                }
                else if (data.resetOnThreshold)
                {
                    bReset = true;
                }

                if (!string.IsNullOrWhiteSpace(data.messageOnThreshold) && showPopup)
                {
                    NetworkManagerMMO.UCE_BroadCastPopupToOnlinePlayers(template, data.messageParticipantsOnly, data.messageOnThreshold);
                }

                if (data.stopFurtherThresholdChecks)
                {
                    break;
                }
            }
        }

        if (!bReset)
        {
            count += value;
        }
        else
        {
            count = 0;
        }

        participated = true;
    }