コード例 #1
0
ファイル: QuestsSystem.cs プロジェクト: jashking/CryoFall
        /// <summary>
        /// Try to set quest as completed (if player has this quest and all the requirements are satisfied).
        /// </summary>
        public static void ServerCompleteQuest(
            PlayerCharacterQuests characterQuests,
            IProtoQuest questToComplete,
            bool ignoreRequirements)
        {
            characterQuests.ServerClaimReward(questToComplete, ignoreRequirements);

            var handler = ServerCharacterQuestCompleted;

            if (handler is not null)
            {
                Api.SafeInvoke(() => handler.Invoke(characterQuests.Character, questToComplete));
            }

            // success! (no exceptions thrown)
            // adding dependant quests
            foreach (var otherQuest in AllQuests)
            {
                if (!otherQuest.Prerequisites.Contains(questToComplete) ||
                    !ServerArePrerequisitesSatisfied(otherQuest, characterQuests))
                {
                    continue;
                }

                characterQuests.ServerTryAddQuest(otherQuest, isUnlocked: true);
            }
        }
コード例 #2
0
ファイル: QuestsSystem.cs プロジェクト: jashking/CryoFall
 public static void ServerInitCharacterQuests(PlayerCharacterQuests characterQuests)
 {
     // add all quests which don't have any prerequisites or which are already satisfied
     foreach (var protoQuest in AllQuests)
     {
         var isUnlocked = ServerArePrerequisitesSatisfied(protoQuest, characterQuests);
         characterQuests.ServerTryAddQuest(protoQuest, isUnlocked);
     }
 }
コード例 #3
0
ファイル: QuestsSystem.cs プロジェクト: jashking/CryoFall
        private static bool ServerArePrerequisitesSatisfied(IProtoQuest quest, PlayerCharacterQuests characterQuests)
        {
            if (quest.Prerequisites.Count == 0)
            {
                return(true);
            }

            foreach (var requiredQuest in quest.Prerequisites)
            {
                if (!characterQuests.SharedHasCompletedQuest(requiredQuest))
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #4
0
ファイル: QuestsSystem.cs プロジェクト: johndragon/CryoFall
        /// <summary>
        /// Try to set quest as completed (if player has this quest and all the requirements are satisfied).
        /// </summary>
        public static void ServerCompleteQuest(
            PlayerCharacterQuests characterQuests,
            IProtoQuest questToComplete,
            bool ignoreRequirements)
        {
            characterQuests.ServerTryClaimReward(questToComplete, ignoreRequirements);

            // success! (no exceptions thrown)
            // adding dependant quests
            foreach (var otherQuest in AllQuests)
            {
                if (!otherQuest.Prerequisites.Contains(questToComplete) ||
                    !ServerArePrequisitesSatisfied(otherQuest, characterQuests))
                {
                    continue;
                }

                characterQuests.ServerTryAddQuest(otherQuest, isUnlocked: true);
            }
        }