Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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();
            }
        }
Exemplo n.º 3
0
    /* ----------------------------------
     * INIT: Used for late initialization after constructor
     * ----------------------------------*/
    void Init()
    {
        EditorApplication.update += this.Update;

        place.DataStructure  = HelperExtention.GetOrCreateSObjectReturn <StructSearchData>(ref place.DataStructure, PATH_SAVE_SCRIPTABLE_OBJECT);
        place.namePlaceСache = "";
        place.DataStructure.dataChache.Clear();

        addressDropdown = new DropDown("Address");
        map             = new GUIMap();
        map.Repaint    += Repaint;
        map.Zoom        = 19;

        geometriesReorderableList = new ReorderableList(new ArrayList(), typeof(GMLGeometry), true, true, true, true);
        geometriesReorderableList.drawHeaderCallback  += DrawGMLGeometryHeader;
        geometriesReorderableList.drawElementCallback += DrawGMLGeometry;
        geometriesReorderableList.onAddCallback       += AddGMLGeometry;
        geometriesReorderableList.onRemoveCallback    += RemoveGMLGeometry;
        geometriesReorderableList.onReorderCallback   += ReorderGMLGeometries;

        // Creating the geometry list
        geometries = new List <GMLGeometry>();
        // Set geometries list reference
        geometriesReorderableList.list = geometries;
        map.Geometries = geometries;
    }
Exemplo n.º 4
0
        public void Repositionate(GUIMap map, Rect area)
        {
            if (!reference.TransformManagerParameters.ContainsKey("Position"))
            {
                reference.TransformManagerParameters.Add("Position", Vector2d.zero);
            }

            reference.TransformManagerParameters["Position"] = map.GeoMousePosition;
        }
Exemplo n.º 5
0
        public void Draw(GUIMap map, Rect area)
        {
            UpdateValues();
            var corner = area.position + new Vector2(position.x * area.width / gameWidth, area.height - (position.y * area.height / gameHeight));

            if (Texture != null)
            {
                var size = new Vector2(Texture.width * scale.x, Texture.height * scale.y);
                GUI.DrawTexture(new Rect(corner - new Vector2(size.x / 2f, size.y), size), Texture);
            }
        }
Exemplo n.º 6
0
        public void Repositionate(GUIMap map, Rect area)
        {
            var   centerMouseVector = (map.GeoMousePosition - map.Center).normalized;
            float angle             = Vector3.Angle(new Vector3(0.0f, 1.0f, 0.0f), new Vector3((float)centerMouseVector.x, (float)centerMouseVector.y, 0.0f));

            if (centerMouseVector.x < 0.0f)
            {
                angle = 360.0f - angle;
            }

            reference.TransformManagerParameters["Degree"] = angle;
        }
Exemplo n.º 7
0
        public void Repositionate(GUIMap map, Rect area)
        {
            if (!reference.TransformManagerParameters.ContainsKey("Position"))
            {
                reference.TransformManagerParameters.Add("Position", Vector2.zero);
            }

            var elemMapPosition = Event.current.mousePosition - area.position;

            // save position based on texture starting coord, by placing it on mouse center
            reference.TransformManagerParameters["Position"] = new Vector2d(
                elemMapPosition.x * gameWidth / area.width,
                gameHeight - (elemMapPosition.y * gameHeight / area.height + (Texture.height * scale.y) / 2f));
        }