コード例 #1
0
    private void OnEnable()
    {
        questCache  = Resources.LoadAll <Quest>("Configuration");
        quest       = target as Quest;
        talkerCache = Resources.LoadAll <TalkerInformation>("Configuration").Where(x => x.Enable).ToArray();
        holder      = talkerCache.FirstOrDefault(x => x.QuestsStored.Contains(quest));
        itemCache   = Resources.LoadAll <ItemBase>("Configuration");

        lineHeight            = EditorGUIUtility.singleLineHeight;
        lineHeightSpace       = lineHeight + 2;
        _ID                   = serializedObject.FindProperty("_ID");
        title                 = serializedObject.FindProperty("title");
        description           = serializedObject.FindProperty("description");
        abandonable           = serializedObject.FindProperty("abandonable");
        group                 = serializedObject.FindProperty("group");
        questType             = serializedObject.FindProperty("questType");
        repeatFrequancy       = serializedObject.FindProperty("repeatFrequancy");
        timeUnit              = serializedObject.FindProperty("timeUnit");
        acceptCondition       = serializedObject.FindProperty("acceptCondition");
        beginDialogue         = serializedObject.FindProperty("beginDialogue");
        ongoingDialogue       = serializedObject.FindProperty("ongoingDialogue");
        completeDialogue      = serializedObject.FindProperty("completeDialogue");
        rewardItems           = serializedObject.FindProperty("rewardItems");
        _NPCToSubmit          = serializedObject.FindProperty("_NPCToSubmit");
        cmpltObjctvInOrder    = serializedObject.FindProperty("cmpltObjctvInOrder");
        objectives            = serializedObject.FindProperty("objectives");
        groupSelector         = new ObjectSelectionDrawer <QuestGroup>(group, "_name", "", "归属组", "无");
        npcSelector           = new ObjectSelectionDrawer <TalkerInformation>(_NPCToSubmit, "_name", talkerCache, "在此NPC处提交", "接取处NPC");
        acceptConditionDrawer = new ConditionGroupDrawer(serializedObject, acceptCondition, lineHeight, lineHeightSpace, "接取条件列表");
        rewardDrawer          = new ItemAmountListDrawer(serializedObject, rewardItems, lineHeight, lineHeightSpace, "奖励列表");
        HandlingObjectiveList();
        showState = new AnimBool(objectives.isExpanded);
        AddAnimaListener(OnAnima);
    }
コード例 #2
0
 int GetNPCIndex(TalkerInformation npc)
 {
     if (npcs.Contains(npc))
     {
         return(Array.IndexOf(npcs, npc));
     }
     else
     {
         return(-1);
     }
 }
コード例 #3
0
ファイル: TalkerData.cs プロジェクト: Zetan9565/Project-ZT
 public TalkerData(TalkerInformation info) : base(info)
 {
     if (Info.IsVendor)
     {
         shop = new ShopData(this, info.Shop);
         ShopManager.Vendors.Add(this);
     }
     if (Info.IsWarehouseAgent)
     {
         Inventory = new Inventory(Info.WarehouseCapcity, ignoreLock: true);
     }
     relationshipInstance = new Relationship();
     InitQuest();
 }
コード例 #4
0
    private void OnEnable()
    {
        character = target as CharacterInformation;
        enemy     = target as EnemyInformation;
        talker    = target as TalkerInformation;
        player    = target as PlayerInformation;
        if (talker)
        {
            allTalkers = Resources.LoadAll <TalkerInformation>("").ToList();
            allTalkers.Remove(talker);
        }
        _ID   = serializedObject.FindProperty("_ID");
        _Name = serializedObject.FindProperty("_Name");
        sex   = serializedObject.FindProperty("sex");

        lineHeight      = EditorGUIUtility.singleLineHeight;
        lineHeightSpace = lineHeight + 5;

        if (enemy)
        {
            dropItems = serializedObject.FindProperty("dropItems");
            HandlingDropItemList();
        }
        else if (talker)
        {
            defalutDialogue      = serializedObject.FindProperty("defaultDialogue");
            canDEV_RLAT          = serializedObject.FindProperty("canDEV_RLAT");
            favoriteItemDialogue = serializedObject.FindProperty("favoriteItemDialogue");
            normalItemDialogue   = serializedObject.FindProperty("normalItemDialogue");
            hateItemDialogue     = serializedObject.FindProperty("hateItemDialogue");
            favoriteItems        = serializedObject.FindProperty("favoriteItems");
            hateItems            = serializedObject.FindProperty("hateItems");
            canMarry             = serializedObject.FindProperty("canMarry");
            isWarehouseAgent     = serializedObject.FindProperty("isWarehouseAgent");
            isVendor             = serializedObject.FindProperty("isVendor");
            warehouse            = serializedObject.FindProperty("warehouse");
            shop         = serializedObject.FindProperty("shop");
            questsStored = serializedObject.FindProperty("questsStored");

            HandlingFavoriteItemList();
            HandlingHateItemList();
            HandlingQuestList();
        }
        else if (player)
        {
            backpack = serializedObject.FindProperty("backpack");
        }
    }
コード例 #5
0
    private void DoOption(WordsOptionData option)
    {
        wordsToSay.Clear();
        currentOption = option;

        if (option.model.OptionType == WordsOptionType.SubmitAndGet)
        {
            if (option.model.IsValid)
            {
                if (BackpackManager.Instance.CanLose(option.model.ItemToSubmit.item, option.model.ItemToSubmit.Amount, (ItemWithAmount)option.model.ItemCanGet))
                {
                    BackpackManager.Instance.LoseItem(option.model.ItemToSubmit.item, option.model.ItemToSubmit.Amount, (ItemWithAmount)option.model.ItemCanGet);
                }
                else
                {
                    currentOption = null;
                    return;
                }
            }
            else
            {
                MessageManager.Instance.New("无效的选项");
            }
        }
        if (option.model.OptionType == WordsOptionType.OnlyGet)
        {
            if (option.model.IsValid)
            {
                if (!BackpackManager.Instance.CanGet(option.model.ItemCanGet.item, option.model.ItemCanGet.Amount))
                {
                    currentOption = null;
                    return;
                }
                else
                {
                    BackpackManager.Instance.GetItem(option.model.ItemCanGet.item, option.model.ItemCanGet.Amount);
                }
            }
            else
            {
                MessageManager.Instance.New("无效的选项");
            }
        }
        if (option.model.OptionType == WordsOptionType.Choice)//是选择型选项
        {
            choiceOptionSaid.Push(option);
            if (option.parent.model.IsCorrectOption(option.model))
            {
                DoDialogue(option.parent.parent.model, option.indexToGoBack);
            }
            else
            {
                NewWords(option.parent.model.TalkerType != TalkerType.Player, option.parent.model.WrongChoiceWords);//对话人的类型由句子决定,说的话是句子带的选择错误时说的话
            }
        }
        if (option.model.HasWordsToSay || option.model.OptionType == WordsOptionType.BranchWords)
        {
            NewWords(option.model.TalkerType != TalkerType.Player, option.model.Words);//对话人的类型由选项决定,说的话是选项自带的
        }
        else if (option.model.OptionType == WordsOptionType.BranchDialogue)
        {
            DoDialogue(option.model.Dialogue, option.model.SpecifyIndex);
        }
        SayNextWords();

        void NewWords(bool condition, string words)
        {
            TalkerInformation talkerInfo = null;

            if (condition)
            {
                if (!option.parent.parent.model.UseUnifiedNPC)
                {
                    talkerInfo = option.parent.model.TalkerInfo;
                }
                else if (option.parent.parent.model.UseUnifiedNPC && option.parent.parent.model.UseCurrentTalkerInfo)
                {
                    talkerInfo = currentTalker.GetData <TalkerData>().Info;
                }
                else if (option.parent.parent.model.UseUnifiedNPC && !option.parent.parent.model.UseCurrentTalkerInfo)
                {
                    talkerInfo = option.parent.parent.model.UnifiedNPC;
                }
                wordsToSay.Push(new DialogueWordsData(new DialogueWords(talkerInfo, words), null));
            }
            else
            {
                wordsToSay.Push(new DialogueWordsData(new DialogueWords(null, words, TalkerType.Player), null));
            }
        }
    }
コード例 #6
0
 public DialogueWords(TalkerInformation talkerInfo, string words, TalkerType talkerType = 0)
 {
     this.talkerInfo = talkerInfo;
     this.words      = words;
     this.talkerType = talkerType;
 }
コード例 #7
0
ファイル: DialogueManager.cs プロジェクト: pengeel/Project-ZT
    public void StartOptionDialogue(WordsOption option)
    {
        if (option == null || !option.IsValid)
        {
            return;
        }
        var optionInstance = option.Cloned;

        optionInstance.runtimeWordsParentIndex = currentDialog.IndexOfWords(currentWords);
        if (currentWords.NeedToChusCorrectOption)
        {
            optionInstance.runtimeDialogParent = currentDialog;
            if (currentWords.IndexOfCorrectOption == currentWords.IndexOfOption(option))
            {
                optionInstance.runtimeIndexToGoBack = optionInstance.runtimeWordsParentIndex + 1;
            }
            else
            {
                optionInstance.runtimeIndexToGoBack = optionInstance.runtimeWordsParentIndex;
            }
        }
        else if (option.GoBack)
        {
            optionInstance.runtimeDialogParent = currentDialog;
            if (option.OptionType == WordsOptionType.SubmitAndGet || option.OptionType == WordsOptionType.OnlyGet || option.IndexToGoBack < 0)
            {
                optionInstance.runtimeIndexToGoBack = optionInstance.runtimeWordsParentIndex;
            }
            else
            {
                optionInstance.runtimeIndexToGoBack = option.IndexToGoBack;
            }
        }
        wordsOptionInstances.Push(optionInstance);
        currentOption = option;
        if (option.OptionType == WordsOptionType.SubmitAndGet && option.IsValid)
        {
            if (BackpackManager.Instance.TryLoseItem_Boolean(option.ItemToSubmit, option.ItemCanGet))
            {
                BackpackManager.Instance.LoseItem(option.ItemToSubmit, option.ItemCanGet);
            }
            else
            {
                wordsOptionInstances.Pop();
                currentOption = null;
                return;
            }
        }
        if (option.OptionType == WordsOptionType.OnlyGet && option.IsValid)
        {
            if (!BackpackManager.Instance.TryGetItem_Boolean(option.ItemCanGet))
            {
                wordsOptionInstances.Pop();
                currentOption = null;
                return;
            }
            else
            {
                BackpackManager.Instance.GetItem(option.ItemCanGet);
            }
        }
        if (option.OptionType == WordsOptionType.Choice && (!option.HasWordsToSay || option.HasWordsToSay && string.IsNullOrEmpty(option.Words)))
        {
            HandlingLastOptionWords();
            SayNextWords();
            return;
        }
        if (option.OptionType == WordsOptionType.BranchDialogue && option.Dialogue)
        {
            StartDialogue(optionInstance.Dialogue, optionInstance.SpecifyIndex);
        }
        else if (!string.IsNullOrEmpty(option.Words))
        {
            TalkerInformation talkerInfo = null;
            if (optionInstance.TalkerType == TalkerType.NPC)
            {
                if (!currentDialog.UseUnifiedNPC && optionInstance.runtimeWordsParentIndex > -1 && optionInstance.runtimeWordsParentIndex < currentDialog.Words.Count)
                {
                    talkerInfo = currentDialog.Words[optionInstance.runtimeWordsParentIndex].TalkerInfo;
                    //Debug.Log(talkerInfo + "A");
                }
                else if (currentDialog.UseUnifiedNPC && currentDialog.UseCurrentTalkerInfo)
                {
                    talkerInfo = CurrentTalker.Info;
                    //Debug.Log(talkerInfo + "B");
                }
                else if (currentDialog.UseUnifiedNPC && !currentDialog.UseCurrentTalkerInfo)
                {
                    talkerInfo = currentDialog.UnifiedNPC;
                    //Debug.Log(talkerInfo + "C");
                }
            }
            if (option.GoBack)
            {
                StartOneWords(new DialogueWords(talkerInfo, optionInstance.Words, optionInstance.TalkerType), currentDialog, optionInstance.runtimeIndexToGoBack);
            }
            else
            {
                StartOneWords(new DialogueWords(talkerInfo, optionInstance.Words, optionInstance.TalkerType));
            }
            SayNextWords();
        }
    }