Ejemplo n.º 1
0
        protected virtual void NetFuncCompleteQuest(int questDataId)
        {
            int   indexOfQuest = this.IndexOfQuest(questDataId);
            Quest quest;

            if (indexOfQuest < 0 || !GameInstance.Quests.TryGetValue(questDataId, out quest))
            {
                return;
            }
            CharacterQuest characterQuest = quests[indexOfQuest];

            if (!characterQuest.IsAllTasksDone(this))
            {
                return;
            }
            if (characterQuest.isComplete)
            {
                return;
            }
            QuestTask[] tasks = quest.tasks;
            foreach (QuestTask task in tasks)
            {
                switch (task.taskType)
                {
                case QuestTaskType.CollectItem:
                    this.DecreaseItems(task.itemAmount.item.DataId, task.itemAmount.amount);
                    break;
                }
            }
            Reward reward = gameplayRule.MakeQuestReward(quest);

            RewardExp(reward, 1f, RewardGivenType.Quest);
            RewardCurrencies(reward, 1f, RewardGivenType.Quest);
            ItemAmount[] rewardItems = quest.rewardItems;
            if (rewardItems != null && rewardItems.Length > 0)
            {
                foreach (ItemAmount rewardItem in rewardItems)
                {
                    if (rewardItem.item != null && rewardItem.amount > 0)
                    {
                        this.IncreaseItems(CharacterItem.Create(rewardItem.item, 1, rewardItem.amount));
                    }
                }
            }
            characterQuest.isComplete = true;
            if (!quest.canRepeat)
            {
                quests[indexOfQuest] = characterQuest;
            }
            else
            {
                quests.RemoveAt(indexOfQuest);
            }
        }
Ejemplo n.º 2
0
        public bool IsPass(IPlayerCharacterData character)
        {
            int  indexOfQuest        = -1;
            bool questTasksCompleted = false;
            bool questCompleted      = false;

            if (quest != null)
            {
                indexOfQuest = character.IndexOfQuest(quest.DataId);
                if (indexOfQuest >= 0)
                {
                    CharacterQuest characterQuest = character.Quests[indexOfQuest];
                    questTasksCompleted = characterQuest.IsAllTasksDone(character);
                    questCompleted      = characterQuest.isComplete;
                }
            }
            switch (conditionType)
            {
            case NpcDialogConditionType.LevelMoreThanOrEqual:
                return(character.Level >= conditionalLevel);

            case NpcDialogConditionType.LevelLessThanOrEqual:
                return(character.Level <= conditionalLevel);

            case NpcDialogConditionType.QuestNotStarted:
                return(indexOfQuest < 0);

            case NpcDialogConditionType.QuestOngoing:
                return(!questTasksCompleted);

            case NpcDialogConditionType.QuestTasksCompleted:
                return(questTasksCompleted);

            case NpcDialogConditionType.QuestCompleted:
                return(questCompleted);
            }
            return(true);
        }