示例#1
0
    /// <summary>
    /// Processes an optional criteria
    /// </summary>
    /// <param name="unit">The unit who completed the criteria</param>
    /// <param name="player">The player who completed the criteria</param>
    /// <param name="criteria">The criteria which is completed</param>
    public virtual void ProcessOptionalCriteria(CQExamplePlayer unit, CQPlayerObject player, Criteria criteria)
    {
        activeOptionalCriterias[player].Remove(criteria);
        completedOptionalCriterias[player].Add(criteria);
        if (CustomQuestSettings.SettingsHolder.optionalCriteriaSpecificRewards && criteria.giveRewardsOnCompletion)
        {
            GiveReward(unit, player, criteria.rewards);
        }
        else if (optionalThresholds[criteria.Level] > 0) //Ignores thresholds if its value is 0 or lower
        {                                                //Threshold logic
            int thresholdCounter = 0;
            foreach (Criteria c in completedOptionalCriterias[player])
            {
                if (c.Level == criteria.Level)
                {
                    thresholdCounter += 1;
                }
            }
            if (optionalThresholds[criteria.Level] <= thresholdCounter)
            {     //Threshold reached
                for (int i = 0; i < activeOptionalCriterias[player].Count; i++)
                { //Removing the rest of the activeCriterias and uncompleted criterias
                    completedOptionalCriterias[player].Remove(activeOptionalCriterias[player][i]);
                    activeOptionalCriterias[player].Remove(activeOptionalCriterias[player][i]);
                }
                int counter = 0;
                while (activeOptionalCriterias[player].Count <= 0)
                { //Adds the new level of criterias
                    if (!matchOptionalLevels)
                    {
                        foreach (Criteria c in optionalCriterias)
                        {
                            if (c.Level == criteria.Level + counter)
                            {
                                activeOptionalCriterias[player].Add(c);
                                c.StartCriteria(player);
                            }
                        }
                    }
                    counter++;
                }
            }
        }

        criteria.Complete(player, unit);
    }
示例#2
0
 /// <summary>
 /// Processes a criteria
 /// </summary>
 /// <param name="unit">The unit who completed the criteria</param>
 /// <param name="player">The player who completed the criteria</param>
 /// <param name="criteria">The criteria which is completed</param>
 public virtual void ProcessCriteria(CQExamplePlayer unit, CQPlayerObject player, Criteria criteria)
 {
     unCompletedCriterias[player].Remove(criteria);
     activeCriterias[player].Remove(criteria);
     completedCriterias[player].Add(criteria);
     if (activeCriterias[player].Count <= 0 && unCompletedCriterias[player].Count > 0)
     {
         int counter = 1;
         while (activeCriterias[player].Count <= 0)
         { //Adds the new level of criterias
             foreach (Criteria c in unCompletedCriterias[player])
             {
                 if (c.Level == criteria.Level + counter)
                 {
                     activeCriterias[player].Add(c);
                     c.StartCriteria(player);
                 }
             }
             if (matchOptionalLevels)
             {
                 activeOptionalCriterias[player].Clear();
                 foreach (Criteria c in optionalCriterias)
                 {
                     if (c.Level == criteria.Level + counter)
                     {
                         activeOptionalCriterias[player].Add(c);
                         c.StartCriteria(player);
                     }
                 }
             }
             counter++;
             if (counter > 100)
             {
                 Debug.Log("infinite loop prevented");
                 break;
             }
         }
     }
     else if (thresholds.Count > 0)          //Checks for any threshold level - Prevents errors.
     {
         if (thresholds[criteria.Level] > 0) //Ignores thresholds if its value is 0 or lower
         {                                   //Threshold logic
             int thresholdCounter = 0;
             foreach (Criteria c in completedCriterias[player])
             {
                 if (c.Level == criteria.Level)
                 {
                     thresholdCounter += 1;
                 }
             }
             if (thresholds[criteria.Level] <= thresholdCounter)
             {     //Threshold reached
                 for (int i = 0; i < activeCriterias[player].Count; i++)
                 { //Removing the rest of the activeCriterias and uncompleted criterias
                     unCompletedCriterias[player].Remove(activeCriterias[player][i]);
                     activeCriterias[player].Remove(activeCriterias[player][i]);
                 }
                 int counter = 0;
                 while (activeCriterias[player].Count <= 0)
                 { //Adds the new level of criterias
                     foreach (Criteria c in unCompletedCriterias[player])
                     {
                         if (c.Level == criteria.Level + counter)
                         {
                             activeCriterias[player].Add(c);
                             c.StartCriteria(player);
                         }
                     }
                     if (matchOptionalLevels)
                     {
                         activeOptionalCriterias[player].Clear();
                         foreach (Criteria c in optionalCriterias)
                         {
                             if (c.Level == criteria.Level + counter)
                             {
                                 activeOptionalCriterias[player].Add(c);
                                 c.StartCriteria(player);
                             }
                         }
                     }
                     counter++;
                     if (counter > 100)
                     {
                         Debug.Log("infinite loop prevented");
                         break;
                     }
                 }
             }
         }
     }
     if (activeCriterias[player].Count > 0)
     {
         EventInfoHolder tmpE = new EventInfoHolder();
         tmpE.quest = this;
         QuestHandler.TriggerEvent("ResetQuestInList", tmpE); //Sends out the ResetQuestInList event
     }
     if (autoComplete == true && activeCriterias[player].Count <= 0)
     {
         OnCompletion(player, unit);
     }
     if (CustomQuestSettings.SettingsHolder.criteriaSpecificRewards && criteria.giveRewardsOnCompletion)
     {
         GiveReward(unit, player, criteria.rewards);
     }
     criteria.Complete(player, unit);
 }