Пример #1
0
        /// <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, ICollection <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();
        }
Пример #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.service.GetMatchDetails(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        = objDetails.Name;
                                objData.FullName    = objDetails.FullName;
                                objData.Location    = objDetails.Location;
                                objData.MapLocation = objDetails.MapLocation;
                                objData.ChatCode    = objDetails.ChatCode;
                                objData.Points      = objDetails.Points;
                            }

                            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);
        }
Пример #3
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();

                            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.RedDesertBorderlands;
                            }
                            else if (mapDetails is EternalBattlegrounds)
                            {
                                objData.Map = WvWMap.EternalBattlegrounds;
                            }
                            else
                            {
                                objData.Map = WvWMap.Unknown;
                            }

                            objData.ID         = new WvWObjectiveId(objective.ObjectiveId, objData.Map);
                            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 = 12;
                                break;

                            case ObjectiveType.Keep:
                                objData.Points = 8;
                                break;

                            case ObjectiveType.Tower:
                                objData.Points = 4;
                                break;

                            case ObjectiveType.Camp:
                                objData.Points = 2;
                                break;

                            default:
                                break;
                            }

                            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);
        }