예제 #1
0
    public bool CheckQuestCompletion(Quest quest)
    {
        E_QuestStatus thisQuestStatus = E_QuestStatus.Satsified;

        if (m_QuestDictionary.TryGetValue(quest, out thisQuestStatus))
        {
            return(true);
        }
        else
        {
            Debug.LogError("No Quest has been found to be satsified");
        }
        return(false);
    }
예제 #2
0
    //Check if condition is satsified
    public bool CheckCondition(Condition condition)
    {
        //If there is already a true condition in the condition tracker that matches then return true
        bool thisBool = true;

        if (m_ConditionTrackerDictionary.TryGetValue(condition, out thisBool))
        {
            return(true);
        }
        else
        {
            //Check each catagories and see if those categories has been satsified
            int conditionPassed     = 0;
            int conditionPassedNeed =
                condition.QuestDictionary.Count +
                condition.ItemDictionary.Count +
                condition.DialoguePerformedList.Count;


            if (condition.NeedQuest)
            {
                //Cross reference Quest Log in Quest Manager with condition
                foreach (KeyValuePair <Quest, E_QuestStatus> keyValue in condition.QuestDictionary)
                {
                    Quest         questRequirement       = keyValue.Key;
                    E_QuestStatus questStatusRequirement = keyValue.Value;

                    QuestE_QuestStatusDictionary questList = QuestManager.Instance.QuestDictionary;
                    E_QuestStatus actual;
                    E_QuestStatus stored;

                    switch (questStatusRequirement)
                    {
                    case E_QuestStatus.Completed:
                        actual = E_QuestStatus.Completed;
                        if (questList.TryGetValue(questRequirement, out stored) && stored == actual)
                        {
                            conditionPassed++;
                        }
                        break;

                    case E_QuestStatus.Satsified:
                        actual = E_QuestStatus.Satsified;
                        if (questList.TryGetValue(questRequirement, out stored) && stored == actual)
                        {
                            conditionPassed++;
                        }
                        break;

                    case E_QuestStatus.InProgress:
                        actual = E_QuestStatus.InProgress;
                        if (questList.TryGetValue(questRequirement, out stored) && stored == actual)
                        {
                            conditionPassed++;
                        }
                        break;

                    case E_QuestStatus.NotBeenAdded:
                        actual = E_QuestStatus.NotBeenAdded;
                        if (!questList.TryGetValue(questRequirement, out stored) && stored == actual)
                        {
                            conditionPassed++;
                        }
                        break;
                    }
                }
            }
            if (condition.NeedItem)
            {
                throw new NotImplementedException();
            }
            if (condition.NeedDialoguePerformed)
            {
                throw new NotImplementedException();
            }
            if (conditionPassed == conditionPassedNeed)
            {
                //If existing condition that matches with the Tracker exist and is false, then set to true
                bool thisBool2 = false;
                if (m_ConditionTrackerDictionary.TryGetValue(condition, out thisBool2))
                {
                    m_ConditionTrackerDictionary[condition] = true;
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
    }