Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new marker on the compass bar, based on the given object.
        /// </summary>
        /// <param name="obj">The GameObject with a QT_MapObject on it.</param>
        public void AddMarker(QT_MapObject obj)
        {
            QT_MapMarker marker = Instantiate(MarkerPrefab, markersTransform);

            marker.Initialize(obj, MarkerSize);
            Markers.Add(marker);
        }
Ejemplo n.º 2
0
        private Vector2 CalculatePosition(QT_MapMarker marker)
        {
            float   compassDegree     = CompassSize.x / 360;
            Vector2 referencePosition = ReferenceObject.Position(QT_MapType.Map3D);
            Vector2 referenceForward  = new Vector2(ReferenceObject.transform.forward.x, ReferenceObject.transform.forward.z);
            float   angle             = Vector2.SignedAngle(marker.Object.Position(QT_MapType.Map3D) - referencePosition, referenceForward);

            return(new Vector2(compassDegree * angle, 0));
        }
Ejemplo n.º 3
0
        protected virtual Vector2 CalculatePosition(QT_MapMarker marker)
        {
            Vector2 mapSize    = rectTransform.rect.size;
            Vector2 worldToMap = new Vector2(mapSize.x / WorldSize.x, mapSize.y / WorldSize.y);
            Vector2 difference = marker.Object.Position(Type) - ReferenceObject.Position(Type);

            Zoom = Mathf.Clamp(Zoom, MinZoom, MaxZoom);

            return(new Vector2(difference.x * worldToMap.x * Zoom, difference.y * worldToMap.y * Zoom));
        }
Ejemplo n.º 4
0
        private Vector2 CalculateScale(QT_MapMarker marker)
        {
            float distance = Vector2.Distance(ReferenceObject.Position(QT_MapType.Map3D), marker.Object.Position(QT_MapType.Map3D));
            float scale    = 0;

            if (distance < MaxRenderDistance)
            {
                scale = Mathf.Clamp(1 - distance / MaxRenderDistance, MinScale, MaxScale);
            }

            return(new Vector2(scale, scale));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a new marker on the map, based on the given object.
        /// </summary>
        /// <param name="obj">The GameObject with a QT_MapObject on it.</param>
        /// <param name="reference">Whether or not this is the reference object.</param>
        public void AddMarker(QT_MapObject obj, bool reference)
        {
            QT_MapMarker marker = Instantiate(MarkerPrefab, reference ? transform : markersTransform);

            marker.Initialize(obj, MarkerSize);

            if (!reference)
            {
                Markers.Add(marker);
            }
            else
            {
                ReferenceMarker = marker;
            }
        }
Ejemplo n.º 6
0
        protected override Vector2 CalculatePosition(QT_MapMarker marker)
        {
            Vector2 mapSize    = rectTransform.rect.size;
            Vector2 worldToMap = new Vector2(mapSize.x / WorldSize.x, mapSize.y / WorldSize.y);
            Vector2 difference = marker.Object.Position(Type) - ReferenceObject.Position(Type);

            Zoom = Mathf.Clamp(Zoom, MinZoom, MaxZoom);
            Vector2 position = new Vector2(difference.x * worldToMap.x * Zoom, difference.y * worldToMap.y * Zoom);

            if (MapCollider == QT_MapColliderType.Rectangle)
            {
                position.x = Mathf.Clamp(position.x, -mapSize.x / 2, mapSize.x / 2);
                position.y = Mathf.Clamp(position.y, -mapSize.y / 2, mapSize.y / 2);
            }
            else if (MapCollider == QT_MapColliderType.Circle)
            {
                float magnitude = Mathf.Clamp(position.magnitude, 1, Mathf.Min(mapSize.x, mapSize.y) / 2);
                position.Normalize();
                position *= magnitude;
            }

            return(position);
        }