Esempio n. 1
0
        public ViewModelQuestEntry(
            PlayerCharacterQuests.CharacterQuestEntry questEntry,
            Action <ViewModelQuestEntry> callbackOnFinishedStateChanged,
            bool showRequirementIcons = true)
        {
            this.showRequirementIcons = showRequirementIcons;
            this.QuestEntry           = questEntry;

            var requirements = questEntry.Quest.Tasks;
            var viewModels   = new ViewModelQuestRequirement[requirements.Count];

            for (var index = 0; index < requirements.Count; index++)
            {
                var requirement      = requirements[index];
                var requirementState = questEntry.IsCompleted
                                           ? null
                                           : questEntry.TaskStates[index];

                viewModels[index] = new ViewModelQuestRequirement(requirement,
                                                                  requirementState,
                                                                  showIcon: showRequirementIcons);
            }

            this.Requirements = viewModels;

            this.QuestEntry.ClientSubscribe(
                _ => _.AreAllTasksCompleted,
                _ =>
            {
                this.NotifyPropertyChanged(nameof(this.AreAllTasksCompleted));
                this.NotifyPropertyChanged(nameof(this.IsRewardCanBeClaimed));
                this.NotifyPropertyChanged(nameof(this.IsNew));
                callbackOnFinishedStateChanged(this);
            },
                this);

            this.QuestEntry.ClientSubscribe(
                _ => _.IsCompleted,
                _ =>
            {
                this.NotifyPropertyChanged(nameof(this.IsCompletedAndRewardClaimed));
                this.NotifyPropertyChanged(nameof(this.IsRewardCanBeClaimed));
                this.NotifyPropertyChanged(nameof(this.IsNew));
                // this is required as the quest is completely finished when the reward is claimed
                callbackOnFinishedStateChanged(this);
            },
                this);

            this.QuestEntry.ClientSubscribe(
                _ => _.IsNew,
                _ => this.NotifyPropertyChanged(nameof(this.IsNew)),
                this);

            TechConstants.ClientLearningPointsGainMultiplierReceived +=
                this.ClientLearningPointsGainMultiplierReceivedHandler;
        }
        public ViewModelQuestEntry(
            PlayerCharacterQuests.CharacterQuestEntry questEntry,
            Action <ViewModelQuestEntry> callbackOnFinishedStateChanged)
        {
            this.QuestEntry = questEntry;

            var requirements = questEntry.Quest.Requirements;
            var viewModels   = new ViewModelQuestRequirement[requirements.Count];

            for (var index = 0; index < requirements.Count; index++)
            {
                var requirement      = requirements[index];
                var requirementState = questEntry.IsCompleted
                                           ? null
                                           : questEntry.RequirementStates[index];

                viewModels[index] = new ViewModelQuestRequirement(requirement, requirementState);
            }

            this.Requirements = viewModels;

            this.QuestEntry.ClientSubscribe(
                _ => _.AreAllRequirementsSatisfied,
                _ =>
            {
                this.NotifyPropertyChanged(nameof(this.AreAllRequirementsSatisfied));
                this.NotifyPropertyChanged(nameof(this.IsRewardCanBeClaimed));
                this.NotifyPropertyChanged(nameof(this.IsNew));
                callbackOnFinishedStateChanged(this);
            },
                this);

            this.QuestEntry.ClientSubscribe(
                _ => _.IsCompleted,
                _ =>
            {
                this.NotifyPropertyChanged(nameof(this.IsCompletedAndRewardClaimed));
                this.NotifyPropertyChanged(nameof(this.IsRewardCanBeClaimed));
                this.NotifyPropertyChanged(nameof(this.IsNew));
                // this is required as the quest is completely finished when the reward is claimed
                callbackOnFinishedStateChanged(this);
            },
                this);

            this.QuestEntry.ClientSubscribe(
                _ => _.IsNew,
                _ => this.NotifyPropertyChanged(nameof(this.IsNew)),
                this);
        }