private void QuestsListElementInserted( NetworkSyncList <PlayerCharacterQuests.CharacterQuestEntry> source, int index, PlayerCharacterQuests.CharacterQuestEntry value) { this.Register(value); }
public static HUDQuestTrackingEntryControl Create(PlayerCharacterQuests.CharacterQuestEntry questEntry) { return(new HUDQuestTrackingEntryControl() { QuestEntry = questEntry }); }
private void QuestsListElementInserted( NetworkSyncList <PlayerCharacterQuests.CharacterQuestEntry> source, int index, PlayerCharacterQuests.CharacterQuestEntry value) { var vm = new ViewModelQuestEntry(value, this.ViewModelQuestEntryOnCompletedStateChanged); if (vm.QuestEntry.IsCompleted) { this.CompletedQuests.Insert(0, vm); if (this.CompletedQuests.Count == 1) { // display completed quests this.NotifyPropertyChanged(nameof(this.CompletedQuests)); } this.NotifyPropertyChanged(nameof(this.UnlockedQuestsCount)); return; } // add new active quest // make it expanded by default vm.SetIsCollapsed(false, removeNewFlag: false); this.ActiveQuests.Add(vm); if (this.ActiveQuests.Count == 1) { // remove no active quests label this.NotifyPropertyChanged(nameof(this.ActiveQuests)); } Api.Client.Audio.PlayOneShot(new SoundResource("UI/Quests/QuestUnlocked.ogg")); this.NotifyPropertyChanged(nameof(this.UnlockedQuestsCount)); }
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); }
private void QuestsListElementRemoved( NetworkSyncList <PlayerCharacterQuests.CharacterQuestEntry> source, int index, PlayerCharacterQuests.CharacterQuestEntry removedvalue) { foreach (var stackPanelChild in this.stackPanelChildren) { var control = (HUDQuestTrackingEntryControl)stackPanelChild; if (control.QuestEntry == removedvalue) { control.Hide(quick: false); return; } } }
private void QuestsListElementRemoved( NetworkSyncList <PlayerCharacterQuests.CharacterQuestEntry> source, int index, PlayerCharacterQuests.CharacterQuestEntry removedValue) { TryRemoveFrom(this.ActiveQuests); TryRemoveFrom(this.CompletedQuests); void TryRemoveFrom(ObservableCollection <ViewModelQuestEntry> list) { var viewModel = list.FirstOrDefault(vm => vm.QuestEntry == removedValue); if (viewModel != null) { list.Remove(viewModel); viewModel.Dispose(); } } this.NotifyPropertyChanged(nameof(this.UnlockedQuestsCount)); }
private void Register(PlayerCharacterQuests.CharacterQuestEntry questEntry) { if (this.registeredEntries.ContainsKey(questEntry)) { return; } questEntry.ClientSubscribe(_ => _.IsCompleted, _ => this.RefreshAllEntries(), this.stateSubscriptionStorage); if (questEntry.IsCompleted) { this.registeredEntries[questEntry] = null; return; } var control = HUDQuestTrackingEntryControl.Create(questEntry); this.registeredEntries[questEntry] = control; this.stackPanelChildren.Add(control); }
private void QuestsListElementInserted( NetworkSyncList <PlayerCharacterQuests.CharacterQuestEntry> source, int index, PlayerCharacterQuests.CharacterQuestEntry value) { var vm = new ViewModelQuestEntry(value, this.ViewModelQuestEntryOnCompletedStateChanged); if (vm.QuestEntry.IsCompleted) { this.CompletedQuests.Insert(0, vm); if (this.CompletedQuests.Count == 1) { // display completed quests this.NotifyPropertyChanged(nameof(this.CompletedQuests)); } this.NotifyPropertyChanged(nameof(this.UnlockedQuestsCount)); return; } // add new active quest // make it expanded by default vm.SetIsCollapsed(false, removeNewFlag: false); this.ActiveQuests.Add(vm); if (this.ActiveQuests.Count == 1) { // remove no active quests label this.NotifyPropertyChanged(nameof(this.ActiveQuests)); } // play quest unlocked sound (not more often than once per frame) if (lastQuestUnlockedFrame != Client.CurrentGame.ServerFrameNumber) { lastQuestUnlockedFrame = Client.CurrentGame.ServerFrameNumber; Api.Client.Audio.PlayOneShot(SoundResourceQuestUnlocked, volume: 0.5f); } this.NotifyPropertyChanged(nameof(this.UnlockedQuestsCount)); }