Example #1
0
    public void OnTrigger()
    {
        if (triggerType == TriggerType.NewObjective)
        {
            if (objectivesID.Length > 1)
            {
                int[] result = objectiveManager.ReturnNonExistObjectives(objectivesID);

                if (result.Length > 1)
                {
                    objectiveManager.AddObjectives(result, showTime);
                }
                else if (result.Length == 1)
                {
                    objectiveManager.AddObjective(result[0], showTime);
                }
            }
            else
            {
                if (!objectiveManager.ContainsObjective(objectivesID[0]))
                {
                    objectiveManager.AddObjective(objectivesID[0], showTime);
                }
            }

            isTriggered = true;
        }
        else if (triggerType == TriggerType.Complete)
        {
            if (objectiveManager.ContainsObjective(objective))
            {
                objectiveManager.CompleteObjective(objective);
                isTriggered = true;
            }
            else if (preComplete)
            {
                objectiveManager.PreCompleteObjective(objective);
                isTriggered = true;
            }
        }
        else if (triggerType == TriggerType.CompleteAndNew)
        {
            bool contains = newWhenContains ? false : true;

            if (objectiveManager.ContainsObjective(objective))
            {
                objectiveManager.CompleteObjective(objective);
                contains    = true;
                isTriggered = true;
            }
            else if (preComplete)
            {
                objectiveManager.PreCompleteObjective(objective);
                contains    = true;
                isTriggered = true;
            }

            if (contains)
            {
                if (objectivesID.Length > 1)
                {
                    objectiveManager.AddObjectives(objectivesID, showTime, false);
                }
                else
                {
                    objectiveManager.AddObjective(objectivesID[0], showTime, false);
                }
            }
        }
    }