/// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="objective">The objective details</param>
        /// <param name="wvwTeams">Collection containing all of the WvW Teams</param>
        public WvWObjectiveViewModel(WvWObjective objective, WvWUserData userData, IEnumerable<WvWTeamViewModel> wvwTeams, ICollection<WvWObjectiveViewModel> displayedNotificationsCollection)
        {
            this.ModelData = objective;
            this.userData = userData;
            this.wvwTeams = wvwTeams;
            this.displayedNotificationsCollection = displayedNotificationsCollection;

            this.PrevWorldOwner = WorldColor.None;
            this.FlipTime = DateTime.UtcNow;
            this.TimerValue = TimeSpan.Zero;
            this.DistanceFromPlayer = 0.0;
            this.IsRIActive = false;
            this.IsNotificationShown = false;
            this.IsRemovingNotification = false;
            this.GuildClaimer = new GuildViewModel();

            this.userData.PropertyChanged += (o, e) => this.RefreshVisibility();
            this.userData.HiddenObjectives.CollectionChanged += (o, e) => this.RefreshVisibility();
            this.RefreshVisibility();
        }
Exemple #2
0
        /// <summary>
        /// Retrieves a list of the objectives in the given match for all maps
        /// </summary>
        /// <param name="matchId">The match's ID</param>
        public IEnumerable<WvWObjective> GetAllObjectives(string matchId)
        {
            List<WvWObjective> objectives = new List<WvWObjective>();
            try
            {
                var matchDetails = this.matchService.Find(new Matchup { MatchId = matchId });
                if (matchDetails != null)
                {
                    foreach (var mapDetails in matchDetails.Maps)
                    {
                        foreach (var objective in mapDetails.Objectives)
                        {
                            var objData = new WvWObjective();

                            objData.ID = objective.ObjectiveId;
                            objData.MatchId = matchId;
                            objData.GuildOwner = objective.OwnerGuildId;

                            var objDetails = this.ObjectivesTable.Objectives.FirstOrDefault(obj => obj.ID == objData.ID);
                            if (objDetails != null)
                            {
                                objData.Type = objDetails.Type;
                                objData.Name = this.objectiveNamesProvider.GetString(objData.ID, WvWObjectiveNameEnum.Short);
                                objData.FullName = this.objectiveNamesProvider.GetString(objData.ID, WvWObjectiveNameEnum.Full);
                                objData.Location = this.objectiveNamesProvider.GetString(objData.ID, WvWObjectiveNameEnum.Cardinal);
                                objData.MapLocation = objDetails.MapLocation;
                                objData.ChatCode = objDetails.ChatCode;
                            }

                            switch (objData.Type)
                            {
                                case ObjectiveType.Castle:
                                    objData.Points = 35;
                                    break;
                                case ObjectiveType.Keep:
                                    objData.Points = 25;
                                    break;
                                case ObjectiveType.Tower:
                                    objData.Points = 10;
                                    break;
                                case ObjectiveType.Camp:
                                    objData.Points = 5;
                                    break;
                                default:
                                    break;
                            }

                            if (mapDetails is BlueBorderlands)
                                objData.Map = WvWMap.BlueBorderlands;
                            else if (mapDetails is GreenBorderlands)
                                objData.Map = WvWMap.GreenBorderlands;
                            else if (mapDetails is RedBorderlands)
                                objData.Map = WvWMap.RedBorderlands;
                            else if (mapDetails is EternalBattlegrounds)
                                objData.Map = WvWMap.EternalBattlegrounds;
                            else
                                objData.Map = WvWMap.Unknown;

                            switch (objective.Owner)
                            {
                                case TeamColor.Blue:
                                    objData.WorldOwner = WorldColor.Blue;
                                    break;
                                case TeamColor.Green:
                                    objData.WorldOwner = WorldColor.Green;
                                    break;
                                case TeamColor.Red:
                                    objData.WorldOwner = WorldColor.Red;
                                    break;
                                default:
                                    objData.WorldOwner = WorldColor.None;
                                    break;
                            }

                            objectives.Add(objData);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // Don't crash if something goes wrong (like if WvW is resetting)
                logger.Error(ex);
            }

            return objectives;
        }