Ejemplo n.º 1
0
        public void OnMapClick(PointerEventData eventData)
        {
            var offset    = eventData.position - (Vector2)minimap.IconsPanel.position + Vector2.one * minimap.MapImageSize / 2f;          // adding half of map size because draw zone have centered pivot.
            var resultPos = Minimap.InboundPositionToMap(offset, minimap.MapImageSize);

            SetIconPosition(resultPos, true);

            OnBeginDrag(eventData);
        }
Ejemplo n.º 2
0
        void ImitateDrag()
        {
            rectTransform.position = Input.mousePosition;

            var anchoredPosition = rectTransform.anchoredPosition;

            if (IsPositionIconOutOfBounds(anchoredPosition))
            {
                anchoredPosition = Minimap.InboundPositionToMap(anchoredPosition, minimap.MapImageSize);
            }

            SetIconPosition(anchoredPosition, true);
        }
Ejemplo n.º 3
0
        public void OnPointerDown(PointerEventData eventData)
        {
            if (eventData.button == PointerEventData.InputButton.Left)
            {
                minimapCameraIcon.OnMapClick(eventData);
            }
            else if (eventData.button == PointerEventData.InputButton.Right)
            {
                var offset = eventData.position - (Vector2)minimap.IconsPanel.position + Vector2.one * minimap.MapImageSize / 2f;                 // adding half of map size because draw zone have centered pivot.
                offset /= minimap.GetScaleFactor();

                var boundedMapPos = Minimap.InboundPositionToMap(offset, minimap.MapImageSize);

                Ordering.GiveMapOrder(boundedMapPos);
            }
        }