Example #1
0
        public void ReadXml(XmlReader reader)
        {
            int parsedId = -1;
            if (int.TryParse(reader.GetAttribute("ObjectiveId"), out parsedId))
                this.ObjectiveId = parsedId;

            WvWMap parsedMap = WvWMap.Unknown;
            if (Enum.TryParse(reader.GetAttribute("Map"), out parsedMap))
                this.Map = parsedMap;

        }
Example #2
0
        /// <summary>
        /// Rebuilds the current objectives collections
        /// </summary>
        private void RebuildCurrentObjectivesCollection(WvWMap map)
        {
            logger.Debug("Building objectives collection");

            Threading.InvokeOnUI(() =>
            {
                this.CurrentObjectives.Clear();
                foreach (var objective in this.AllObjectives.Where(obj => obj.Map == map))
                {
                    this.CurrentObjectives.Add(objective);
                }
            });
        }
Example #3
0
        public void ReadXml(XmlReader reader)
        {
            int parsedId = -1;

            if (int.TryParse(reader.GetAttribute("ObjectiveId"), out parsedId))
            {
                this.ObjectiveId = parsedId;
            }

            WvWMap parsedMap = WvWMap.Unknown;

            if (Enum.TryParse(reader.GetAttribute("Map"), out parsedMap))
            {
                this.Map = parsedMap;
            }
        }
Example #4
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            WvWMap map = (WvWMap)value;

            switch (map)
            {
            case WvWMap.BlueBorderlands:
                return("/Images/Backgrounds/Small1_b.png");

            case WvWMap.GreenBorderlands:
                return("/Images/Backgrounds/Small1_g.png");

            case WvWMap.RedBorderlands:
                return("/Images/Backgrounds/Small1_r.png");

            case WvWMap.EternalBattlegrounds:
            case WvWMap.Unknown:
            default:
                return("/Images/Backgrounds/Small1.png");
            }
        }
Example #5
0
 /// <summary>
 /// Performs a check for a map change and performs any neccessary actions if the map has changed
 /// </summary>
 private void CheckForMapChange()
 {
     if (this.MapOverride != WvWMap.Unknown)
     {
         if (this.MapOverride != this.prevMap)
         {
             // Map changed, rebuild the objectives
             this.prevMap        = this.MapOverride;
             this.currentMap.Map = this.MapOverride;
             this.RebuildCurrentObjectivesCollection(this.MapOverride);
         }
     }
     else
     {
         if (this.PlayerMap != this.prevMap)
         {
             // Map changed, rebuild the objectives
             this.prevMap        = this.PlayerMap;
             this.currentMap.Map = this.PlayerMap;
             this.RebuildCurrentObjectivesCollection(this.PlayerMap);
         }
     }
 }
Example #6
0
        /// <summary>
        /// Rebuilds the current objectives collections
        /// </summary>
        private void RebuildCurrentObjectivesCollection(WvWMap map)
        {
            logger.Debug("Building objectives collection");

            Threading.InvokeOnUI(() =>
            {
                this.CurrentObjectives.Clear();
                foreach (var objective in this.AllObjectives.Where(obj => obj.Map == map))
                {
                    this.CurrentObjectives.Add(objective);
                }
            });
        }
Example #7
0
 /// <summary>
 /// Performs a check for a map change and performs any neccessary actions if the map has changed
 /// </summary>
 private void CheckForMapChange()
 {
     if (this.MapOverride != WvWMap.Unknown)
     {
         if (this.MapOverride != this.prevMap)
         {
             // Map changed, rebuild the objectives
             this.prevMap = this.MapOverride;
             this.currentMap.Map = this.MapOverride;
             this.RebuildCurrentObjectivesCollection(this.MapOverride);
         }
     }
     else
     {
         if (this.PlayerMap != this.prevMap)
         {
             // Map changed, rebuild the objectives
             this.prevMap = this.PlayerMap;
             this.currentMap.Map = this.PlayerMap;
             this.RebuildCurrentObjectivesCollection(this.PlayerMap);
         }
     }
 }
Example #8
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            WvWMap map = (WvWMap)value;

            if (targetType == typeof(string))
            {
                switch (map)
                {
                case WvWMap.BlueBorderlands:
                    return("Blue Borderlands");

                case WvWMap.GreenBorderlands:
                    return("Green Borderlands");

                case WvWMap.RedBorderlands:
                    return("Red Borderlands");

                case WvWMap.EternalBattlegrounds:
                    return("Eternal Battlegrounds");

                default:
                    return(map.ToString());
                }
            }
            else if (targetType == typeof(System.Windows.Media.Color))
            {
                switch (map)
                {
                case WvWMap.BlueBorderlands:
                    return(System.Windows.Media.Colors.SkyBlue);

                case WvWMap.GreenBorderlands:
                    return(System.Windows.Media.Colors.LightGreen);

                case WvWMap.RedBorderlands:
                    return(System.Windows.Media.Colors.Pink);

                case WvWMap.EternalBattlegrounds:
                    return(System.Windows.Media.Colors.White);

                default:
                    return(System.Windows.Media.Colors.White);
                }
            }
            else if (targetType == typeof(System.Windows.Media.Brush) ||
                     targetType == typeof(System.Windows.Media.SolidColorBrush))
            {
                switch (map)
                {
                case WvWMap.BlueBorderlands:
                    return(System.Windows.Media.Brushes.SkyBlue);

                case WvWMap.GreenBorderlands:
                    return(System.Windows.Media.Brushes.LightGreen);

                case WvWMap.RedBorderlands:
                    return(System.Windows.Media.Brushes.Pink);

                case WvWMap.EternalBattlegrounds:
                    return(System.Windows.Media.Brushes.White);

                default:
                    return(System.Windows.Media.Brushes.White);
                }
            }
            else
            {
                return(map);
            }
        }
Example #9
0
        /// <summary>
        /// Retrieves a list of the objectives in the given match and map
        /// </summary>
        /// <param name="matchId">The match's ID</param>
        /// <param name="mapId">The map's ID</param>
        public IEnumerable <WvWObjective> GetMapObjectives(string matchId, WvWMap map)
        {
            List <WvWObjective> objectives = new List <WvWObjective>();

            try
            {
                var matchDetails = this.service.GetMatchDetails(matchId);
                if (matchDetails != null)
                {
                    CompetitiveMap mapDetails = null;
                    switch (map)
                    {
                    case WvWMap.BlueBorderlands:
                        mapDetails = matchDetails.Maps.FirstOrDefault(m => m is BlueBorderlands);
                        break;

                    case WvWMap.GreenBorderlands:
                        mapDetails = matchDetails.Maps.FirstOrDefault(m => m is GreenBorderlands);
                        break;

                    case WvWMap.RedBorderlands:
                        mapDetails = matchDetails.Maps.FirstOrDefault(m => m is RedBorderlands);
                        break;

                    case WvWMap.EternalBattlegrounds:
                        mapDetails = matchDetails.Maps.FirstOrDefault(m => m is EternalBattlegrounds);
                        break;

                    default:
                        break;
                    }

                    if (mapDetails != null)
                    {
                        foreach (var objective in mapDetails.Objectives)
                        {
                            var objData = new WvWObjective();

                            objData.ID         = objective.ObjectiveId;
                            objData.MatchId    = matchId;
                            objData.Map        = map;
                            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.Points      = objDetails.Points;
                            }

                            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);
        }
Example #10
0
        /// <summary>
        /// Retrieves a list of the objectives in the given match and map
        /// </summary>
        /// <param name="matchId">The match's ID</param>
        /// <param name="mapId">The map's ID</param>
        public IEnumerable <WvWObjective> GetMapObjectives(string matchId, WvWMap map)
        {
            List <WvWObjective> objectives = new List <WvWObjective>();

            try
            {
                var matchDetails = this.matchService.Find(new Matchup {
                    MatchId = matchId
                });
                if (matchDetails != null)
                {
                    CompetitiveMap mapDetails = null;
                    switch (map)
                    {
                    case WvWMap.BlueBorderlands:
                        mapDetails = matchDetails.Maps.FirstOrDefault(m => m is BlueBorderlands);
                        break;

                    case WvWMap.GreenBorderlands:
                        mapDetails = matchDetails.Maps.FirstOrDefault(m => m is GreenBorderlands);
                        break;

                    case WvWMap.RedDesertBorderlands:
                    case WvWMap.RedAplineBorderlands:
                        mapDetails = matchDetails.Maps.FirstOrDefault(m => m is RedBorderlands);
                        break;

                    case WvWMap.EternalBattlegrounds:
                        mapDetails = matchDetails.Maps.FirstOrDefault(m => m is EternalBattlegrounds);
                        break;

                    default:
                        break;
                    }

                    if (mapDetails != null)
                    {
                        foreach (var objective in mapDetails.Objectives)
                        {
                            var objData = new WvWObjective();

                            objData.ID         = new WvWObjectiveId(objective.ObjectiveId, map);
                            objData.MatchId    = matchId;
                            objData.Map        = map;
                            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;
                            }

                            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);
        }
Example #11
0
 /// <summary>
 /// Parameterised constructor
 /// </summary>
 public WvWObjectiveId(int objectiveId, WvWMap map)
 {
     this.ObjectiveId = objectiveId;
     this.Map = map;
 }
Example #12
0
        /// <summary>
        /// Retrieves a list of the objectives in the given match and map
        /// </summary>
        /// <param name="matchId">The match's ID</param>
        /// <param name="mapId">The map's ID</param>
        public IEnumerable<WvWObjective> GetMapObjectives(string matchId, WvWMap map)
        {
            List<WvWObjective> objectives = new List<WvWObjective>();
            try
            {
                var matchDetails = this.matchService.Find(new Matchup { MatchId = matchId });
                if (matchDetails != null)
                {
                    CompetitiveMap mapDetails = null;
                    switch (map)
                    {
                        case WvWMap.BlueBorderlands:
                            mapDetails = matchDetails.Maps.FirstOrDefault(m => m is BlueBorderlands);
                            break;
                        case WvWMap.GreenBorderlands:
                            mapDetails = matchDetails.Maps.FirstOrDefault(m => m is GreenBorderlands);
                            break;
                        case WvWMap.RedBorderlands:
                            mapDetails = matchDetails.Maps.FirstOrDefault(m => m is RedBorderlands);
                            break;
                        case WvWMap.EternalBattlegrounds:
                            mapDetails = matchDetails.Maps.FirstOrDefault(m => m is EternalBattlegrounds);
                            break;
                        default:
                            break;
                    }

                    if (mapDetails != null)
                    {
                        foreach (var objective in mapDetails.Objectives)
                        {
                            var objData = new WvWObjective();

                            objData.ID = objective.ObjectiveId;
                            objData.MatchId = matchId;
                            objData.Map = map;
                            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;
                            }

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

                            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;
        }
Example #13
0
 /// <summary>
 /// Parameterised constructor
 /// </summary>
 public WvWObjectiveId(int objectiveId, WvWMap map)
 {
     this.ObjectiveId = objectiveId;
     this.Map         = map;
 }