Exemplo n.º 1
0
        public static List <QuestAction> CreateList(QuestActionProxy[] actionListProxy)
        {
            var list = new List <QuestAction>();

            if (actionListProxy == null)
            {
                Debug.LogWarning("Quest Machine: QuestActionProxy.CreateList source is null.");
                return(list);
            }
            for (int i = 0; i < actionListProxy.Length; i++)
            {
                var actionProxy = actionListProxy[i];
                if (actionProxy == null || string.IsNullOrEmpty(actionProxy.t) || string.IsNullOrEmpty(actionProxy.s))
                {
                    continue;
                }
                var action = ScriptableObject.CreateInstance(RuntimeTypeUtility.GetTypeFromName(actionProxy.t)) as QuestAction;
                if (action != null)
                {
                    JsonUtility.FromJsonOverwrite(actionProxy.s, action);
                    action.OnAfterProxyDeserialization();
                    list.Add(action);
                }
            }
            return(list);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public static List <QuestCondition> CreateList(QuestConditionProxy[] conditionsProxy)
        {
            var list = new List <QuestCondition>();

            if (conditionsProxy == null)
            {
                Debug.LogWarning("Quest Machine: QuestConditionProxy.CreateList source is null.");
                return(list);
            }
            for (int i = 0; i < conditionsProxy.Length; i++)
            {
                var conditionProxy = conditionsProxy[i];
                if (conditionProxy == null || string.IsNullOrEmpty(conditionProxy.t) || string.IsNullOrEmpty(conditionProxy.s))
                {
                    continue;
                }
                QuestCondition condition = null;
                if (string.Equals(conditionProxy.t, CounterTypeString))
                {
                    condition = ScriptableObject.CreateInstance <CounterQuestCondition>();
                    ApplyCounterQuestConditionProxyData(condition as CounterQuestCondition, conditionProxy.s);
                }
                else if (string.Equals(conditionProxy.t, MessageTypeString))
                {
                    condition = ScriptableObject.CreateInstance <MessageQuestCondition>();
                    ApplyMessageQuestConditionProxyData(condition as MessageQuestCondition, conditionProxy.s);
                }
                else if (string.Equals(conditionProxy.t, TimerTypeString))
                {
                    condition = ScriptableObject.CreateInstance <TimerQuestCondition>();
                    ApplyTimerQuestConditionProxyData(condition as TimerQuestCondition, conditionProxy.s);
                }
                else
                {
                    condition = ScriptableObject.CreateInstance(RuntimeTypeUtility.GetTypeFromName(conditionProxy.t)) as QuestCondition;
                    if (condition != null)
                    {
                        JsonUtility.FromJsonOverwrite(conditionProxy.s, condition);
                    }
                }
                if (condition != null)
                {
                    condition.OnAfterProxyDeserialization();
                    list.Add(condition);
                }
            }
            return(list);
        }