예제 #1
0
        private void OnSelectElement(ReorderableList list)
        {
            var isIndexValid = (0 <= list.index && list.index < list.count);

            m_selectedQuestContent = isIndexValid ? (list.serializedProperty.GetArrayElementAtIndex(list.index).objectReferenceValue as QuestContent) : null;
            m_contentEditor        = null;
        }
예제 #2
0
        private void OnAddQuestContentType(object data)
        {
            var isSelectedQuest = m_isAsset;

            if (isSelectedQuest)
            {
                QuestEditorWindow.ApplyModifiedPropertiesFromSelectedQuestSerializedObject();
            }
            var type    = data as Type;
            var content = ScriptableObjectUtility.CreateScriptableObject(type);

            content.name           = type.Name;
            m_selectedQuestContent = content as QuestContent;
            m_contentEditor        = null;
            if (isSelectedQuest)
            {
                AssetUtility.AddToAsset(content, QuestEditorWindow.selectedQuestSerializedObject.targetObject);
                QuestEditorWindow.UpdateSelectedQuestSerializedObject();
            }
            m_list.serializedProperty.arraySize++;
            m_list.index = m_list.serializedProperty.arraySize - 1;
            m_list.serializedProperty.GetArrayElementAtIndex(m_list.serializedProperty.arraySize - 1).objectReferenceValue = content;
            m_list.serializedProperty.serializedObject.ApplyModifiedProperties();
            m_serializedObject.ApplyModifiedProperties();
            if (isSelectedQuest)
            {
                QuestEditorWindow.ApplyModifiedPropertiesFromSelectedQuestSerializedObject();
                AssetDatabase.SaveAssets();
            }
            m_needToClearFocus = true;
        }
예제 #3
0
 public void CopyFrom(QuestContent content)
 {
     if (content == null)
     {
         Debug.LogWarning("Quest Machine: QuestContentProxy.CopyFrom source is null.");
         return;
     }
     t = content.GetType().FullName;
     content.OnBeforeProxySerialization();
     if (content is HeadingTextQuestContent)
     {
         t = HeadingTypeString;
         s = GetHeadingTextQuestContentProxyData(content as HeadingTextQuestContent);
     }
     else if (content is BodyTextQuestContent)
     {
         t = BodyTypeString;
         s = GetBodyTextQuestContentProxyData(content as BodyTextQuestContent);
     }
     else if (content is IconQuestContent)
     {
         t = IconTypeString;
         s = GetIconQuestContentProxyData(content as IconQuestContent);
     }
     else if (content is ButtonQuestContent)
     {
         t = ButtonTypeString;
         s = GetButtonQuestContentProxyData(content as ButtonQuestContent);
     }
     else
     {
         s = JsonUtility.ToJson(content);
     }
 }
예제 #4
0
        /// <summary>
        /// Uses a list of reward systems to add rewards to the quest builder
        /// that are commensurate with the difficulty of the quest.
        /// </summary>
        /// <param name="questBuilder">QuestBuilder to receive reward offers.</param>
        /// <param name="entity">Quest giver entity.</param>
        /// <param name="goal">Goal step (determines quest difficulty).</param>
        /// <param name="rewardsUIContents">Text to introduce rewards.</param>
        /// <param name="rewardSystems">Reward systems from which to get rewards.</param>
        protected virtual void AddRewards(QuestBuilder questBuilder, QuestEntity entity, PlanStep goal, List <QuestContent> rewardsUIContents, List <RewardSystem> rewardSystems)
        {
            if (QuestGenerator.detailedDebug)
            {
                Debug.Log("Quest Machine: [Generator] Checking " + rewardSystems.Count + " reward systems for " + goal.fact.count + " " + goal.fact.entityType.name +
                          " (level " + goal.fact.entityType.level + ") on " + entity.name, entity);
            }
            questBuilder.AddOfferContents(QuestContent.CloneList <QuestContent>(rewardsUIContents).ToArray());

            var pointsRemaining = goal.fact.entityType.level * goal.fact.count;

            for (int i = 0; i < rewardSystems.Count; i++)
            {
                var rewardSystem = rewardSystems[i];
                if (rewardSystem == null)
                {
                    continue;
                }
                if (UnityEngine.Random.value > rewardSystem.probability)
                {
                    continue;
                }
                pointsRemaining = rewardSystem.DetermineReward(pointsRemaining, questBuilder.quest, goal.fact.entityType);
                if (pointsRemaining <= 0)
                {
                    break;
                }
            }
        }
예제 #5
0
 protected virtual void AddContent(QuestContent content) //[TODO] Pool template instances for reuse.
 {
     if (content == null)
     {
         return;
     }
     if (content is HeadingTextQuestContent)
     {
         AddHeadingContent(content as HeadingTextQuestContent);
     }
     else if (content is BodyTextQuestContent)
     {
         AddBodyContent(content as BodyTextQuestContent);
     }
     else if (content is ButtonQuestContent)
     {
         AddButtonContent(content as ButtonQuestContent);
     }
     else if (content is IconQuestContent)
     {
         AddIconContent(content as IconQuestContent);
     }
     else if (content is AudioClipQuestContent)
     {
         AddAudioContent(content as AudioClipQuestContent);
     }
 }
예제 #6
0
 public static void AddQuestTagsToTextTable(QuestContent content, TextTable textTable)
 {
     if (content == null)
     {
         return;
     }
     AddQuestTagsToTextTable(content.originalText, textTable);
 }
 private void MoveTextToTextTable(QuestContent content, TextTable textTable)
 {
     if (content == null)
     {
         return;
     }
     MoveTextToTextTable(content.originalText, textTable);
 }
예제 #8
0
        public static List <QuestContent> CreateList(QuestContentProxy[] contentListProxy)
        {
            var list = new List <QuestContent>();

            if (contentListProxy == null)
            {
                Debug.LogWarning("Quest Machine: QuestContentProxy.CreateList source is null.");
                return(list);
            }
            for (int i = 0; i < contentListProxy.Length; i++)
            {
                var contentProxy = contentListProxy[i];
                if (contentProxy == null || string.IsNullOrEmpty(contentProxy.t) || string.IsNullOrEmpty(contentProxy.s))
                {
                    continue;
                }
                QuestContent content = null;
                if (string.Equals(contentProxy.t, HeadingTypeString))
                {
                    content = ScriptableObject.CreateInstance <HeadingTextQuestContent>();
                    ApplyHeadingTextQuestContentProxyData(content as HeadingTextQuestContent, contentProxy.s);
                }
                else if (string.Equals(contentProxy.t, BodyTypeString))
                {
                    content = ScriptableObject.CreateInstance <BodyTextQuestContent>();
                    ApplyBodyTextQuestContentProxyData(content as BodyTextQuestContent, contentProxy.s);
                }
                else if (string.Equals(contentProxy.t, IconTypeString))
                {
                    content = ScriptableObject.CreateInstance <IconQuestContent>();
                    ApplyIconQuestContentProxyData(content as IconQuestContent, contentProxy.s);
                }
                else if (string.Equals(contentProxy.t, ButtonTypeString))
                {
                    content = ScriptableObject.CreateInstance <ButtonQuestContent>();
                    ApplyButtonQuestContentProxyData(content as ButtonQuestContent, contentProxy.s);
                }
                else
                {
                    content = ScriptableObject.CreateInstance(RuntimeTypeUtility.GetTypeFromName(contentProxy.t)) as QuestContent;
                    if (content != null)
                    {
                        JsonUtility.FromJsonOverwrite(contentProxy.s, content);
                    }
                }
                if (content != null)
                {
                    content.OnAfterProxyDeserialization();
                    list.Add(content);
                }
            }
            return(list);
        }
예제 #9
0
 private void SetupReorderableList(SerializedObject serializedObject, SerializedProperty contentListProperty)
 {
     if (contentListProperty == null)
     {
         return;
     }
     m_list = new ReorderableList(serializedObject, contentListProperty, true, true, true, true);
     m_list.drawHeaderCallback    = OnDrawHeader;
     m_list.drawElementCallback   = OnDrawElement;
     m_list.onSelectCallback      = OnSelectElement;
     m_list.onRemoveCallback      = OnRemoveElement;
     m_list.onAddDropdownCallback = OnAddDropdown;
     m_selectedQuestContent       = null;
     m_contentEditor = null;
 }
 protected float GetDisplayDuration(QuestContent content)
 {
     if (content is HeadingTextQuestContent)
     {
         return(GetDisplayDuration((content as HeadingTextQuestContent).headingText));
     }
     else if (content is BodyTextQuestContent)
     {
         return(GetDisplayDuration((content as BodyTextQuestContent).bodyText));
     }
     else if (content is IconQuestContent)
     {
         return(GetDisplayDuration((content as IconQuestContent).caption));
     }
     else
     {
         return(minDisplayDuration);
     }
 }
예제 #11
0
        /// <summary>
        /// Adds a final "return to quest giver" step.
        /// </summary>
        /// <returns>The return node.</returns>
        protected virtual QuestNode AddReturnNode(QuestBuilder questBuilder, QuestNode previousNode, QuestEntity entity, string mainTargetEntity, string mainTargetDescriptor, string domainName, PlanStep goal, int rewardsContentIndex = 9999) // Default to 9999 to not break any customer code using old signature.
        {
            var questGiver = entity.GetComponent <QuestGiver>();
            var giverID    = (questGiver != null) ? questGiver.id : ((entity != null) ? entity.displayName : null);
            var returnNode = questBuilder.AddDiscussQuestNode(previousNode, QuestMessageParticipant.QuestGiver, giverID);

            returnNode.id = new StringField("Return");
            previousNode  = returnNode;

            QuestStateInfo.ValidateStateInfoListCount(returnNode.stateInfoList);
            var hudText = "{Return to} " + questGiver.displayName;

            // Text when active:
            AddReturnNodeText(questBuilder, returnNode, questGiver, mainTargetEntity, mainTargetDescriptor, domainName, goal, hudText);

            // Add rewards content:
            var dialogueList     = returnNode.stateInfoList[(int)QuestNodeState.Active].categorizedContentList[(int)QuestContentCategory.Dialogue];
            var offerContentList = questBuilder.quest.offerContentList;

            for (int i = rewardsContentIndex; i < offerContentList.Count; i++)
            {
                var original = offerContentList[i];
                var copy     = QuestContent.Instantiate(original) as QuestContent;
                original.CloneSubassetsInto(copy);
                dialogueList.contentList.Add(copy);
            }

            var actionList = returnNode.GetStateInfo(QuestNodeState.Active).actionList;

            // Alert when active:
            AddReturnNodeAlert(questBuilder, returnNode, actionList, hudText);

            // Indicators:
            AddReturnNodeIndicators(questBuilder, returnNode, actionList, entity);

            return(previousNode);
        }
 protected override void AddContent(QuestContent content)
 {
     base.AddContent(content);
 }
예제 #13
0
 public QuestContentProxy(QuestContent content)
 {
     CopyFrom(content);
 }
예제 #14
0
        /// <summary>
        /// Sets sub-objects' runtime references to this quest.
        /// </summary>
        public void SetRuntimeReferences()
        {
            // Set references in start info:
            if (Application.isPlaying)
            {
                m_timeCooldownLastChecked = GameTime.time;
            }
            if (autostartConditionSet != null)
            {
                autostartConditionSet.SetRuntimeReferences(this, null);
            }
            if (offerConditionSet != null)
            {
                offerConditionSet.SetRuntimeReferences(this, null);
            }
            QuestContent.SetRuntimeReferences(offerConditionsUnmetContentList, this, null);
            QuestContent.SetRuntimeReferences(offerContentList, this, null);

            // Set references in counters:
            if (counterList != null)
            {
                for (int i = 0; i < counterList.Count; i++)
                {
                    counterList[i].SetRuntimeReferences(this);
                }
            }

            // Set references in state info:
            if (stateInfoList != null)
            {
                for (int i = 0; i < stateInfoList.Count; i++)
                {
                    var stateInfo = QuestStateInfo.GetStateInfo(stateInfoList, (QuestState)i);
                    if (stateInfo != null)
                    {
                        stateInfo.SetRuntimeReferences(this, null);
                    }
                }
            }

            // Set references in nodes:
            if (nodeList != null)
            {
                for (int i = 0; i < nodeList.Count; i++)
                {
                    if (nodeList[i] != null)
                    {
                        nodeList[i].InitializeRuntimeReferences(this);
                    }
                }
                for (int i = 0; i < nodeList.Count; i++)
                {
                    if (nodeList[i] != null)
                    {
                        nodeList[i].ConnectRuntimeNodeReferences();
                    }
                }
                for (int i = 0; i < nodeList.Count; i++)
                {
                    if (nodeList[i] != null)
                    {
                        nodeList[i].SetRuntimeNodeReferences();
                    }
                }
            }

            // Record list of any nodes' speakers who aren't the quest giver:
            RecordSpeakersUsedInQuestAndAnyNodes();

            // Add tags to dictionary:
            QuestMachineTags.AddTagsToDictionary(tagDictionary, title);
            QuestMachineTags.AddTagsToDictionary(tagDictionary, group);
            if (!StringField.IsNullOrEmpty(questGiverID))
            {
                tagDictionary.SetTag(QuestMachineTags.QUESTGIVERID, questGiverID);
            }
        }