예제 #1
0
        public TasksController(IZoneService zoneService, IPlayerService playerService, TasksUserData userData, CompositionContainer container)
        {
            logger.Debug("Initializing Player Tasks Controller");
            this.zoneService   = zoneService;
            this.playerService = playerService;
            this.container     = container;
            this.isStopped     = false;

            this.CharacterName = this.playerService.CharacterName;
            this.UserData      = userData;
            this.PlayerTasks   = new ObservableCollection <PlayerTaskViewModel>();

            // Initialize all loaded tasks
            logger.Info("Initializing all loaded player tasks");
            foreach (var task in this.UserData.Tasks)
            {
                var taskVm = new PlayerTaskViewModel(task, zoneService, this, this.container);
                taskVm.OnNewCharacterDetected(this.CharacterName);
                this.PlayerTasks.Add(taskVm);
            }

            // Initialize refresh timers
            this.refreshTimer    = new Timer(this.Refresh);
            this.RefreshInterval = 125;
            this.CurrentMapID    = -1;

            logger.Info("Player Tasks Controller initialized");
        }
예제 #2
0
        /// <summary>
        /// Constructs a new Player Marker view model
        /// </summary>
        /// <param name="taskViewModel">View model of the marker's corresponding task</param>
        public PlayerMarkerViewModel(PlayerTaskViewModel taskViewModel, IZoneService zoneService, IPlayerService playerService)
        {
            this.taskViewModel = taskViewModel;
            this.zoneService   = zoneService;
            this.playerService = playerService;

            this.taskViewModel.PropertyChanged      += TaskViewModel_PropertyChanged;
            this.taskViewModel.Task.PropertyChanged += Task_PropertyChanged;
        }
예제 #3
0
        /// <summary>
        /// Constructs a new Player Marker view model
        /// </summary>
        /// <param name="taskViewModel">View model of the marker's corresponding task</param>
        public PlayerMarkerViewModel(PlayerTaskViewModel taskViewModel, MapUserData userData, int currentContinentId, IZoneService zoneService, IPlayerService playerService)
        {
            this.taskViewModel      = taskViewModel;
            this.userData           = userData;
            this.currentContinentId = currentContinentId;
            this.zoneService        = zoneService;
            this.playerService      = playerService;

            this.userData.HiddenMarkerCategories.CollectionChanged += HiddenMarkerCategories_CollectionChanged;
            this.taskViewModel.PropertyChanged      += TaskViewModel_PropertyChanged;
            this.taskViewModel.Task.PropertyChanged += Task_PropertyChanged;
            this.RefreshVisibility();
        }
예제 #4
0
 /// <summary>
 /// Adds a new task to the collection of player tasks
 /// </summary>
 /// <param name="task">The task and viewmodel to add</param>
 public void AddOrUpdateTask(PlayerTaskViewModel taskViewModel)
 {
     // Lock so the refresh thread doesn't use the collection while we are modifying it
     lock (this.refreshLock)
     {
         Threading.InvokeOnUI(() =>
         {
             var existingTask = this.PlayerTasks.FirstOrDefault(t => t.Task.ID == taskViewModel.Task.ID);
             if (existingTask == null)
             {
                 this.UserData.Tasks.Add(taskViewModel.Task);
                 this.PlayerTasks.Add(taskViewModel);
             }
             else
             {
                 existingTask.Task.Name                    = taskViewModel.Task.Name;
                 existingTask.Task.Description             = taskViewModel.Task.Description;
                 existingTask.Task.IsCompletable           = taskViewModel.Task.IsCompletable;
                 existingTask.Task.IsAccountCompleted      = taskViewModel.Task.IsAccountCompleted;
                 existingTask.Task.IsCompletedPerCharacter = taskViewModel.Task.IsCompletedPerCharacter;
                 existingTask.Task.IsDailyReset            = taskViewModel.Task.IsDailyReset;
                 existingTask.Task.AutoComplete            = taskViewModel.Task.AutoComplete;
                 existingTask.Task.Location                = taskViewModel.Task.Location;
                 existingTask.Task.ContinentId             = taskViewModel.Task.ContinentId;
                 existingTask.Task.MapID                   = taskViewModel.Task.MapID;
                 existingTask.Task.IconUri                 = taskViewModel.Task.IconUri;
                 existingTask.Task.WaypointCode            = taskViewModel.Task.WaypointCode;
                 existingTask.Task.Category                = taskViewModel.Task.Category;
                 foreach (var character in taskViewModel.Task.CharacterCompletions.Keys)
                 {
                     if (!existingTask.Task.CharacterCompletions.ContainsKey(character))
                     {
                         existingTask.Task.CharacterCompletions.Add(character, taskViewModel.Task.CharacterCompletions[character]);
                     }
                     else
                     {
                         existingTask.Task.CharacterCompletions[character] = taskViewModel.Task.CharacterCompletions[character];
                     }
                 }
             }
         });
     }
 }