public void LoadBounties()
        {
            // clear the bounties
            foreach (MapLayer map in m_MapBounties.Values)
            {
                map.Children.Clear();
            }

            foreach (GuildBounty bounty in GuildBountyDefinitions.BOUNTIES)
            {
                int mid = bounty.MapId;

                if (!m_MapLayers.ContainsKey(mid))
                {
                    m_MapLayers.Add(mid, new MapLayer());
                }

                BountyMapLayer b = new BountyMapLayer(bounty.Name);

                if (!m_MapBounties.ContainsKey(mid))
                {
                    m_MapBounties.Add(mid, new MapLayer());

                    // map bounties default to hidden
                    m_MapBounties[mid].Visibility = Visibility.Collapsed;

                    // we insert instead of add so events always show up under other pushpins
                    m_MapLayers[mid].Children.Insert(0, m_MapBounties[mid]);
                }

                if (bounty.Spawns != null)
                {
                    foreach (List <double> p in bounty.Spawns)
                    {
                        b.AddSpawningPoint(ArenaNetMap.Unproject(new Point(p[0], p[1]), ArenaNetMap.MaxZoomLevel));
                    }
                }

                if (bounty.Paths != null)
                {
                    int i = 0;
                    foreach (GuildBountyPath path in bounty.Paths)
                    {
                        LocationCollection locs = new LocationCollection();
                        foreach (List <double> p in path.Points)
                        {
                            locs.Add(ArenaNetMap.Unproject(new Point(p[0], p[1]), ArenaNetMap.MaxZoomLevel));
                        }
                        b.AddPath(locs, BOUNTY_PATH_BRUSHES[i], path.Direction);
                        i = (i + 1) % BOUNTY_PATH_BRUSHES.Length;
                    }
                }

                m_MapBounties[mid].Children.Add(b);
            }
        }
Exemple #2
0
        private void Map_UpdateView(double zoomLevel)
        {
            m_MapLayerContainer.HideMapLayer();

            if (zoomLevel >= 3)
            {
                int mid = GetMapByCenter(ArenaNetMap.Project(Map.Center, ArenaNetMap.MaxZoomLevel));
                m_MapLayerContainer.ShowMapLayer(mid);
            }

            ZoomInButton.IsEnabled  = (zoomLevel < ArenaNetMap.MaxZoomLevel);
            ZoomOutButton.IsEnabled = (zoomLevel > ArenaNetMap.MinZoomLevel);
        }
Exemple #3
0
        private void DrawPolyKeyDownHandler(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.LeftCtrl && !e.IsRepeat && !m_DrawingPolygon)
            {
                m_DrawingPolygon = true;

                if (m_DrawingPolygonItem != null)
                {
                    Map.Children.Remove(m_DrawingPolygonItem);
                }

                m_DrawingPolygonItem = null;

                m_DrawingPolylineItem                 = new MapPolyline();
                m_DrawingPolylineItem.Locations       = new LocationCollection();
                m_DrawingPolylineItem.Opacity         = 0.7;
                m_DrawingPolylineItem.Stroke          = System.Windows.Media.Brushes.Blue;
                m_DrawingPolylineItem.StrokeThickness = 3;

                Map.Children.Add(m_DrawingPolylineItem);

                e.Handled = true;
            }

            if (e.Key == Key.RightCtrl && !e.IsRepeat && m_DrawingPolygonItem != null)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("double[,] points = new double[,] {");

                for (int i = 0, n = m_DrawingPolygonItem.Locations.Count; i < n; i++)
                {
                    Point p = ArenaNetMap.Project(m_DrawingPolygonItem.Locations[i], ArenaNetMap.MaxZoomLevel);
                    sb.AppendFormat("{0}{{{1}, {2}}}", (i == 0 ? string.Empty : ", "), p.X, p.Y);
                }

                sb.Append("};");

                Window textBoxWindow = new Window();
                textBoxWindow.Width  = 320;
                textBoxWindow.Height = 240;

                TextBox textBox = new TextBox();
                textBox.Text          = sb.ToString();
                textBox.TextWrapping  = TextWrapping.WrapWithOverflow;
                textBoxWindow.Content = textBox;

                textBoxWindow.Show();
            }
        }
Exemple #4
0
        private void PlayerWorkerThread()
        {
            // wait for map data to be loaded before proceeding (or if we are cancelled)
            EventWaitHandle.WaitAny(new ManualResetEvent[] { m_MapDataLoaded, m_Canceled });

            while (m_Running)
            {
                try
                {
                    if (m_Link.DataAvailable && m_MapData.ContainsKey(m_Link.Map))
                    {
                        FloorMapDetails map = m_MapData[m_Link.Map];

                        // convert back to inches
                        double posX = m_Link.PositionX * 39.3700787;
                        double posZ = m_Link.PositionZ * 39.3700787;
                        double rot  = m_Link.RotationPlayer;

                        posX = ArenaNetMap.TranslateX(posX, map.MapRect, map.ContinentRect);
                        posZ = ArenaNetMap.TranslateZ(posZ, map.MapRect, map.ContinentRect);

                        Location loc = ArenaNetMap.Unproject(new Point(posX, posZ), ArenaNetMap.MaxZoomLevel);

                        // move the player icon
                        Dispatcher.Invoke(() =>
                        {
                            m_Player.Heading    = rot;
                            m_Player.Visibility = Visibility.Visible;

                            // only follow player if they've asked to and the location has changed
                            if (m_FollowPlayer && m_Player.Location != loc)
                            {
                                Map.SetView(loc, Map.ZoomLevel);
                            }

                            m_Player.Location = loc;
                        }, DispatcherPriority.Background, CancellationToken.None, new TimeSpan(0, 0, 1));
                    }
                }
                catch
                { }

                m_Canceled.WaitOne(100);
            }
        }
        public void LoadFloorMapDetails(int mid, FloorMapDetails map)
        {
            if (!m_MapLayers.ContainsKey(mid))
            {
                m_MapLayers.Add(mid, new MapLayer());
            }

            if (!m_MapWaypoints.ContainsKey(mid))
            {
                m_MapWaypoints.Add(mid, new MapLayer());
                m_MapLayers[mid].Children.Add(m_MapWaypoints[mid]);
            }

            if (!m_MapPointsOfInterest.ContainsKey(mid))
            {
                m_MapPointsOfInterest.Add(mid, new MapLayer());
                m_MapLayers[mid].Children.Add(m_MapPointsOfInterest[mid]);
            }

            if (!m_MapVistas.ContainsKey(mid))
            {
                m_MapVistas.Add(mid, new MapLayer());
                m_MapLayers[mid].Children.Add(m_MapVistas[mid]);
            }

            if (!m_MapDungeons.ContainsKey(mid))
            {
                m_MapDungeons.Add(mid, new MapLayer());
                m_MapLayers[mid].Children.Add(m_MapDungeons[mid]);
            }

            if (!m_MapRenownHearts.ContainsKey(mid))
            {
                m_MapRenownHearts.Add(mid, new MapLayer());
                m_MapLayers[mid].Children.Add(m_MapRenownHearts[mid]);
            }

            if (!m_MapSkillPoints.ContainsKey(mid))
            {
                m_MapSkillPoints.Add(mid, new MapLayer());
                m_MapLayers[mid].Children.Add(m_MapSkillPoints[mid]);
            }

            if (!m_MapSectors.ContainsKey(mid))
            {
                m_MapSectors.Add(mid, new MapLayer());
                m_MapLayers[mid].Children.Add(m_MapSectors[mid]);
            }

            m_MapWaypoints[mid].Children.Clear();
            m_MapPointsOfInterest[mid].Children.Clear();
            m_MapVistas[mid].Children.Clear();
            m_MapDungeons[mid].Children.Clear();
            m_MapRenownHearts[mid].Children.Clear();
            m_MapSkillPoints[mid].Children.Clear();
            m_MapSectors[mid].Children.Clear();

            foreach (PointOfInterest poi in map.PointsOfInterest)
            {
                Pushpin poiPin = new PointOfInterestPushpin(poi);

                poiPin.Location = ArenaNetMap.Unproject(new Point(poi.Coord[0], poi.Coord[1]), ArenaNetMap.MaxZoomLevel);

                switch (poi.TypeEnum)
                {
                case PointOfInterestType.Waypoint:
                    m_MapWaypoints[mid].Children.Add(poiPin);
                    break;

                case PointOfInterestType.Landmark:
                    m_MapPointsOfInterest[mid].Children.Add(poiPin);
                    break;

                case PointOfInterestType.Vista:
                    m_MapVistas[mid].Children.Add(poiPin);
                    break;

                case PointOfInterestType.Unlock:
                    m_MapDungeons[mid].Children.Add(poiPin);
                    break;

                default:
                    continue;
                }
            }

            foreach (Task rh in map.Tasks)
            {
                Pushpin rhPin = new TaskPushpin(rh);

                rhPin.Location = ArenaNetMap.Unproject(new Point(rh.Coord[0], rh.Coord[1]), ArenaNetMap.MaxZoomLevel);

                m_MapRenownHearts[mid].Children.Add(rhPin);
            }

            foreach (MappedModel sp in map.SkillChallenges)
            {
                Pushpin spPin = new SkillChallengePushpin(sp);

                spPin.Location = ArenaNetMap.Unproject(new Point(sp.Coord[0], sp.Coord[1]), ArenaNetMap.MaxZoomLevel);

                m_MapSkillPoints[mid].Children.Add(spPin);
            }

            // hide sectors by default
            m_MapSectors[mid].Visibility = Visibility.Collapsed;
            foreach (Sector s in map.Sectors)
            {
                Pushpin sPin = new SectorPushpin(s);

                sPin.Location = ArenaNetMap.Unproject(new Point(s.Coord[0], s.Coord[1]), ArenaNetMap.MaxZoomLevel);

                m_MapSectors[mid].Children.Add(sPin);
            }
        }
        public void LoadEvent(Guid eid, EventDetails ev, FloorMapDetails map, bool isChampion)
        {
            int mid = ev.MapId;

            if (!m_MapLayers.ContainsKey(mid))
            {
                m_MapLayers.Add(mid, new MapLayer());
            }

            if (!m_MapEvents.ContainsKey(mid))
            {
                m_MapEvents.Add(mid, new MapLayer());

                // we insert instead of add so events always show up under other pushpins
                m_MapLayers[mid].Children.Insert(0, m_MapEvents[mid]);
            }

            if (!m_MapEventPolygons.ContainsKey(mid))
            {
                m_MapEventPolygons.Add(mid, new MapLayer());

                // we insert instead of add so events always show up under other pushpins
                m_MapLayers[mid].Children.Insert(0, m_MapEventPolygons[mid]);
            }

            // clean up
            if (m_EventMapPolygons.ContainsKey(eid))
            {
                m_MapEvents[mid].Children.Remove(m_EventMapPolygons[eid]);
                m_EventMapPolygons.Remove(eid);
            }

            if (m_EventPushpins.ContainsKey(eid))
            {
                m_MapEvents[mid].Children.Remove(m_EventPushpins[eid]);
                m_EventPushpins.Remove(eid);
            }

            Point center = new Point(ArenaNetMap.TranslateX(ev.Location.Center[0], map.MapRect, map.ContinentRect),
                                     ArenaNetMap.TranslateZ(ev.Location.Center[1], map.MapRect, map.ContinentRect));

            switch (ev.Location.TypeEnum)
            {
            case LocationType.Poly:
                EventMapPolygon evPoly = new EventMapPolygon(ev, isChampion);

                foreach (List <double> pt in ev.Location.Points)
                {
                    evPoly.Locations.Add(
                        ArenaNetMap.Unproject(
                            new Point(
                                ArenaNetMap.TranslateX(pt[0], map.MapRect, map.ContinentRect),
                                ArenaNetMap.TranslateZ(pt[1], map.MapRect, map.ContinentRect)),
                            ArenaNetMap.MaxZoomLevel));
                }

                m_EventMapPolygons[eid] = evPoly;
                // insert so polys are below all pushpins
                m_MapEventPolygons[mid].Children.Insert(0, evPoly);
                break;

            case LocationType.Sphere:
            case LocationType.Cylinder:
                EventMapPolygon evCircle = new EventMapPolygon(ev, isChampion);

                double radius = ArenaNetMap.TranslateX(ev.Location.Center[0] + ev.Location.Radius, map.MapRect, map.ContinentRect) - center.X;

                for (int i = 0; i < 360; i += 10)
                {
                    evCircle.Locations.Add(
                        ArenaNetMap.Unproject(
                            new Point(
                                center.X + radius * Math.Cos(i * (Math.PI / 180)),
                                center.Y + radius * Math.Sin(i * (Math.PI / 180))),
                            ArenaNetMap.MaxZoomLevel));
                }

                m_EventMapPolygons[eid] = evCircle;
                // insert so polys are below all pushpins
                m_MapEventPolygons[ev.MapId].Children.Insert(0, evCircle);
                break;

            default:
                break;
            }

            EventPushpin evPin = new EventPushpin(ev);

            evPin.Location       = ArenaNetMap.Unproject(center, ArenaNetMap.MaxZoomLevel);
            m_EventPushpins[eid] = evPin;
            m_MapEvents[ev.MapId].Children.Add(evPin);
        }