Пример #1
0
        void UpdateRadarElement(HUDNavigationElement element, Vector3 screenPos, float distance)
        {
            float _scaledRadius    = radarRadius * radarZoom;
            float _scaledMaxRadius = radarMaxRadius * radarZoom;

            // check if element is hidden within the radar
            if (element.hideInRadar)
            {
                element.SetMarkerActive(NavigationElementType.Radar, false);
                return;
            }

            // check distance
            if (distance > _scaledRadius)
            {
                // invoke events
                if (element.IsInRadarRadius)
                {
                    element.IsInRadarRadius = false;
                    element.OnLeaveRadius.Invoke(element, NavigationElementType.Radar);
                }

                // check max distance
                if (distance > _scaledMaxRadius && !element.ignoreRadarRadius)
                {
                    element.SetMarkerActive(NavigationElementType.Radar, false);
                    return;
                }

                // set scaled distance when out of range
                distance = _scaledRadius;
            }
            else
            {
                // invoke events
                if (!element.IsInRadarRadius)
                {
                    element.IsInRadarRadius = true;
                    element.OnEnterRadius.Invoke(element, NavigationElementType.Radar);
                }
            }

            // rotate marker within radar with gameobject?
            Transform rotationReference = GetRotationReference();

            if (radarMode == RadarModes.RotateRadar)
            {
                element.Radar.PrefabRect.rotation = Quaternion.identity;
                if (element.rotateWithGameObject)
                {
                    element.Radar.Icon.transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, -element.transform.eulerAngles.y + rotationReference.eulerAngles.y));
                }
            }
            else
            {
                if (element.rotateWithGameObject)
                {
                    element.Radar.Icon.transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, -element.transform.eulerAngles.y));
                }
            }

            // keep marker icon identity rotation?
            if (!element.rotateWithGameObject)
            {
                element.Radar.Icon.transform.rotation = Quaternion.identity;
            }

            // set marker active
            element.SetMarkerActive(NavigationElementType.Radar, true);

            // calculate marker position
            Vector3 posOffset = element.GetPositionOffset(PlayerController.position);
            //修改 小地图食物坐标逻辑
            Vector3 markerPos = new Vector3(posOffset.x, posOffset.z, 0f);               ///

            markerPos.Normalize();
            markerPos *= (distance / _scaledRadius) * (_HUDNavigationCanvas.Radar.ElementContainer.GetRadius() - element.GetIconRadius(NavigationElementType.Radar));
            // set marker position
            element.SetMarkerPosition(NavigationElementType.Radar, markerPos);

            // handle marker's above/below arrows
            element.ShowRadarAboveArrow(useRadarHeightSystem && element.useRadarHeightSystem && element.IsInRadarRadius && -posOffset.y < -radarDistanceAbove);
            element.ShowRadarBelowArrow(useRadarHeightSystem && element.useRadarHeightSystem && element.IsInRadarRadius && -posOffset.y > radarDistanceBelow);
        }