public void Draw(GUIMap map, Rect area)
        {
            UpdateValues();
            var center = map.PixelToRelative(GM.MetersToPixels(GM.LatLonToMeters(position.x, position.y), map.Zoom)).ToVector2();

            if (Texture != null)
            {
                var size = new Vector2(Texture.width, Texture.height);

                // Scale of 1 means 1 pixel is 1 map pixel in scale 19
                // Scale of 2 means 1 pixel is 0.5 map pixel in scale 18
                // and so on...
                var pixelsSize     = GM.MetersToPixels(GM.PixelsToMeters(new Vector2d(size.x * scale.x, size.y * scale.y), 19), map.Zoom);
                var midWidthHeight = pixelsSize.ToVector2() / 2f;
                var textRect       = ExtensionRect.FromCorners(center - midWidthHeight, center + midWidthHeight);

                /*var areaRect = textRect.Intersection(area);
                 * GUI.DrawTextureWithTexCoords(areaRect, i, textRect.ToTexCoords(areaRect));*/
                GUI.DrawTexture(textRect, Texture);

                Handles.BeginGUI();

                var influencePixels = map.PixelToRelative(GM.MetersToPixels(GM.LatLonToMeters(position.x, position.y) + new Vector2d(interactionRange, 0), map.Zoom)).ToVector2() - center;

                Handles.color = Color.black;
                Handles.DrawWireArc(center, Vector3.back, Vector2.up, 360, influencePixels.magnitude);
                Handles.EndGUI();
            }
        }
        public void Draw(GUIMap map, Rect area)
        {
            UpdateValues();

            var degree = this.degree * Mathf.Deg2Rad;

            var center = (map.Center + GM.MetersToLatLon(new Vector2d(distance * Mathd.Sin(degree), distance * Mathd.Cos(degree)))).ToVector2();

            center = map.PixelToRelative(GM.MetersToPixels(GM.LatLonToMeters(center.x, center.y), map.Zoom)).ToVector2();
            if (Texture != null)
            {
                var size = new Vector2(Texture.width, Texture.height);

                // Scale of 1 means 1 pixel is 1 map pixel in scale 19
                // Scale of 2 means 1 pixel is 0.5 map pixel in scale 18
                // and so on...
                var pixelsSize     = GM.MetersToPixels(GM.PixelsToMeters(new Vector2d(size.x * scale.x, size.y * scale.y), 19), map.Zoom);
                var midWidthHeight = pixelsSize.ToVector2() / 2f;
                var textRect       = ExtensionRect.FromCorners(center - midWidthHeight, center + midWidthHeight);

                /*var areaRect = textRect.Intersection(area);
                 * GUI.DrawTextureWithTexCoords(areaRect, i, textRect.ToTexCoords(areaRect));*/
                GUI.DrawTexture(textRect, Texture);
            }
        }
Beispiel #3
0
        /* -----------------------------
        *  Drawing methods
        *-----------------------------*/

        protected void DrawTiles(Rect area)
        {
            // Download and draw tiles
            Vector2d topLeftCorner     = GM.PixelsToTile(centerPixel - new Vector2d(area.width / 2f, area.height / 2f)),
                     bottomRightCorner = GM.PixelsToTile(centerPixel + new Vector2d(area.width / 2f, area.height / 2f));

            for (double x = topLeftCorner.x; x <= bottomRightCorner.x; x++)
            {
                for (double y = topLeftCorner.y; y <= bottomRightCorner.y; y++)
                {
                    var tp = TileProvider.GetTile(new Vector3d(x, y, Zoom), (texture) => { if (Repaint != null)
                                                                                           {
                                                                                               Repaint();
                                                                                           }
                                                  });
                    var tileBounds = GM.TileBounds(new Vector2d(x, y), Zoom);
                    var tileRect   = ExtensionRect.FromCorners(
                        GM.MetersToPixels(tileBounds.Min, Zoom).ToVector2(),
                        GM.MetersToPixels(tileBounds.Min + tileBounds.Size, Zoom).ToVector2());

                    var windowRect = new Rect(tileRect.position + PATR.ToVector2(), tileRect.size);
                    var areaRect   = windowRect.Intersection(area);
                    if (areaRect.width < 0 || areaRect.height < 0)
                    {
                        continue;
                    }

                    GUI.DrawTextureWithTexCoords(areaRect, tp.Texture, windowRect.ToTexCoords(areaRect));
                }
            }
        }