void UpdateMinimapElement(HUDNavigationElement element, Vector3 screenPos, float distance) { // check if element is hidden within the minimap if (element.hideInMinimap) { element.SetMarkerActive(NavigationElementType.Minimap, false); return; } // check distance if (distance > minimapRadius) { // invoke events if (element.IsInMinimapRadius) { element.IsInMinimapRadius = false; element.OnLeaveRadius.Invoke(element, NavigationElementType.Minimap); } // hide element if (!element.ignoreMinimapRadius) { element.SetMarkerActive(NavigationElementType.Minimap, false); return; } } else { // invoke events if (!element.IsInMinimapRadius) { element.IsInMinimapRadius = true; element.OnEnterRadius.Invoke(element, NavigationElementType.Minimap); } } // rotate marker within minimap with gameobject? if (element.rotateWithGameObjectMM) { element.Minimap.Icon.transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, -element.transform.eulerAngles.y)); } else { element.Minimap.Icon.transform.rotation = Quaternion.identity; } // set marker active element.SetMarkerActive(NavigationElementType.Minimap, true); // calculate marker position Vector2 unitScale = minimapProfile.GetMapUnitScale(); Vector3 posOffset = element.GetPositionOffset(PlayerController.position); //修改 小地图“食物”移动逻辑 //Vector3 markerPos = new Vector3 (posOffset.x * unitScale.x, posOffset.z * unitScale.y, 0f) * minimapScale; /// //Start Vector3 markerPos = new Vector3(posOffset.x * unitScale.x, posOffset.y * unitScale.x, 0f) * minimapScale; //end // adjust marker position when using minimap rotation mode if (minimapMode == MinimapModes.RotateMinimap) { markerPos = PlayerController.MinimapRotationOffset(markerPos); } // always keep marker within minimap rect bool outOfBounds = false; markerPos = _HUDNavigationCanvas.Minimap.ElementContainer.KeepInRectBounds(markerPos, out outOfBounds); // set marker position element.SetMarkerPosition(NavigationElementType.Minimap, markerPos); // handle marker's above/below arrows element.ShowMinimapAboveArrow(useMinimapHeightSystem && element.useMinimapHeightSystem && !outOfBounds && -posOffset.y < -minimapDistanceAbove); element.ShowMinimapBelowArrow(useMinimapHeightSystem && element.useMinimapHeightSystem && !outOfBounds && -posOffset.y > minimapDistanceBelow); }
void UpdateRadarElement(HUDNavigationElement element, Vector3 screenPos, float distance) { float _scaledRadius = RadarRadius * RadarZoom; float _scaledMaxRadius = RadarMaxRadius * RadarZoom; // check for destroyed marker if (element.RadarMarker == null) { return; } // check if element is hidden within the compass bar 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(NavigationElementType.Radar); } // check max distance if (distance > _scaledMaxRadius) { element.SetMarkerActive(NavigationElementType.Radar, false); return; } // set scaled distance when out of range distance = _scaledRadius; } else { // rotate marker Transform rotationReference = GetRotationReference(); if (RadarType == RadarTypes.RotateRadar) { element.RadarMarker.transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, -element.transform.eulerAngles.y + rotationReference.eulerAngles.y)); } else { element.RadarMarker.transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, -element.transform.eulerAngles.y)); } // invoke events if (!element.IsInRadarRadius) { element.IsInRadarRadius = true; element.OnEnterRadius.Invoke(NavigationElementType.Radar); } } // set marker active element.SetMarkerActive(NavigationElementType.Radar, true); // calculate marker position Vector3 posOffset = element.GetPositionOffset(PlayerController); Vector3 markerPos = new Vector3(posOffset.x, posOffset.z, 0f); markerPos.Normalize(); markerPos *= (distance / _scaledRadius) * (_HUDNavigationCanvas.Radar.ElementContainer.GetRadius() - element.GetIconRadius()); // set marker position element.SetMarkerPosition(NavigationElementType.Radar, markerPos); }
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); }