狗屎Minimax坏我代码
This commit is contained in:
@@ -1,12 +1,8 @@
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
using SickscoreGames;
|
||||
|
||||
namespace SickscoreGames.HUDNavigationSystem
|
||||
{
|
||||
@@ -17,7 +13,7 @@ namespace SickscoreGames.HUDNavigationSystem
|
||||
public static HUDNavigationSystem Instance {
|
||||
get {
|
||||
if (_Instance == null) {
|
||||
_Instance = FindObjectOfType<HUDNavigationSystem> ();
|
||||
_Instance = HUDNavigationExtensions.FindFirst<HUDNavigationSystem> ();
|
||||
}
|
||||
return _Instance;
|
||||
}
|
||||
@@ -112,6 +108,8 @@ namespace SickscoreGames.HUDNavigationSystem
|
||||
[HideInInspector]public HNSMapProfile currentMinimapProfile;
|
||||
[Tooltip("Select the minimap mode you want to use.")]
|
||||
public MinimapModes minimapMode = MinimapModes.RotatePlayer;
|
||||
[Tooltip("Select the minimap shape you want to use.")]
|
||||
public MinimapShapes minimapShape = MinimapShapes.Rectangular;
|
||||
[Tooltip("Define the minimap scale. Change value to zoom the minimap.")]
|
||||
public float minimapScale = .25f;
|
||||
[Tooltip("Define the minimap radius. Elements will be displayed on the border of the minimap, depending on the minimap scale.")]
|
||||
@@ -218,7 +216,7 @@ namespace SickscoreGames.HUDNavigationSystem
|
||||
|
||||
// try to automatically assign the player camera and transform if possible
|
||||
if (PlayerCamera == null) {
|
||||
HNSPlayerCamera hnsCamera = GameObject.FindObjectOfType<HNSPlayerCamera> ();
|
||||
HNSPlayerCamera hnsCamera = HUDNavigationExtensions.FindFirst<HNSPlayerCamera>();
|
||||
if (hnsCamera != null)
|
||||
PlayerCamera = hnsCamera.GetComponent<Camera> ();
|
||||
else
|
||||
@@ -227,7 +225,7 @@ namespace SickscoreGames.HUDNavigationSystem
|
||||
Debug.LogError("[HUDNavigationSystem] Player camera unassigned. Assign camera to resume system!");
|
||||
}
|
||||
if (PlayerController == null) {
|
||||
HNSPlayerController hnsTransform = GameObject.FindObjectOfType<HNSPlayerController> ();
|
||||
HNSPlayerController hnsTransform = HUDNavigationExtensions.FindFirst<HNSPlayerController> ();
|
||||
if (hnsTransform != null)
|
||||
PlayerController = hnsTransform.gameObject.transform;
|
||||
if (PlayerController == null)
|
||||
@@ -239,6 +237,23 @@ namespace SickscoreGames.HUDNavigationSystem
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Change the currently assigned canvas at runtime.
|
||||
/// </summary>
|
||||
/// <param name="hnsCanvas">HUD Navigation Canvas.</param>
|
||||
public void ChangeCanvas (HUDNavigationCanvas hnsCanvas)
|
||||
{
|
||||
if (hnsCanvas == null)
|
||||
return;
|
||||
|
||||
// assign new instance
|
||||
_HUDNavigationCanvas = hnsCanvas;
|
||||
|
||||
// re-init all components
|
||||
InitAllComponents();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Change the currently assigned player camera at runtime.
|
||||
/// </summary>
|
||||
@@ -377,8 +392,9 @@ namespace SickscoreGames.HUDNavigationSystem
|
||||
_HUDNavigationCanvas.InitIndicators ();
|
||||
else
|
||||
_HUDNavigationCanvas.ShowIndicators (false);
|
||||
|
||||
|
||||
// init minimap
|
||||
currentMinimapProfile = minimapProfile;
|
||||
if (useMinimap && minimapProfile != null)
|
||||
_HUDNavigationCanvas.InitMinimap (minimapProfile);
|
||||
else
|
||||
@@ -393,7 +409,7 @@ namespace SickscoreGames.HUDNavigationSystem
|
||||
return;
|
||||
|
||||
// return, if references are missing
|
||||
if (PlayerCamera == null || PlayerController == null)
|
||||
if (PlayerCamera == null || PlayerController == null || _HUDNavigationCanvas == null)
|
||||
return;
|
||||
|
||||
// update navigation elements
|
||||
@@ -558,20 +574,23 @@ namespace SickscoreGames.HUDNavigationSystem
|
||||
}
|
||||
}
|
||||
|
||||
// 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));
|
||||
}
|
||||
// apply radar container rotation
|
||||
element.Radar.PrefabRect.rotation = Quaternion.identity;
|
||||
|
||||
// keep marker icon identity rotation?
|
||||
if (!element.rotateWithGameObject)
|
||||
element.Radar.Icon.transform.rotation = Quaternion.identity;
|
||||
// apply radar icon rotation
|
||||
Quaternion iconRotation = Quaternion.identity;
|
||||
if (element.rotateWithGameObject)
|
||||
{
|
||||
float zRotation = -element.transform.eulerAngles.y;
|
||||
if (radarMode == RadarModes.RotateRadar)
|
||||
{
|
||||
Transform rotationReference = GetRotationReference ();
|
||||
zRotation += rotationReference.eulerAngles.y;
|
||||
}
|
||||
|
||||
iconRotation = Quaternion.Euler(0f, 0f, zRotation);
|
||||
}
|
||||
element.Radar.Icon.transform.rotation = iconRotation;
|
||||
|
||||
// update marker values
|
||||
float invertedDistance = radarMaxRadius - _rawDistance;
|
||||
@@ -589,9 +608,11 @@ namespace SickscoreGames.HUDNavigationSystem
|
||||
element.SetMarkerPosition (NavigationElementType.Radar, markerPos);
|
||||
|
||||
// handle marker's above/below arrows
|
||||
bool heightSystemConditions = useRadarHeightSystem && element.useRadarHeightSystem && element.IsInRadarRadius;
|
||||
element.ShowRadarAboveArrow (heightSystemConditions && -posOffset.y < -radarDistanceAbove);
|
||||
element.ShowRadarBelowArrow (heightSystemConditions && -posOffset.y > radarDistanceBelow);
|
||||
if (useRadarHeightSystem) {
|
||||
bool heightSystemConditions = element.useRadarHeightSystem && element.IsInRadarRadius;
|
||||
element.ShowRadarAboveArrow (heightSystemConditions && -posOffset.y < -radarDistanceAbove);
|
||||
element.ShowRadarBelowArrow (heightSystemConditions && -posOffset.y > radarDistanceBelow);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -776,15 +797,20 @@ namespace SickscoreGames.HUDNavigationSystem
|
||||
|
||||
// always keep marker within minimap rect
|
||||
bool outOfBounds;
|
||||
markerPos = _HUDNavigationCanvas.Minimap.ElementContainer.KeepInRectBounds(markerPos, out outOfBounds);
|
||||
if (minimapShape == MinimapShapes.Rectangular)
|
||||
markerPos = _HUDNavigationCanvas.Minimap.ElementContainer.KeepInRectBounds(markerPos, out outOfBounds);
|
||||
else
|
||||
markerPos = _HUDNavigationCanvas.Minimap.ElementContainer.KeepInCircleBounds(markerPos, out outOfBounds);
|
||||
|
||||
// set marker position
|
||||
element.SetMarkerPosition (NavigationElementType.Minimap, markerPos);
|
||||
|
||||
// handle marker's above/below arrows
|
||||
bool heightSystemConditions = useMinimapHeightSystem && element.useMinimapHeightSystem && element.IsInMinimapRadius && !outOfBounds;
|
||||
element.ShowMinimapAboveArrow (heightSystemConditions && -posOffset.y < -minimapDistanceAbove);
|
||||
element.ShowMinimapBelowArrow (heightSystemConditions && -posOffset.y > minimapDistanceBelow);
|
||||
if (useMinimapHeightSystem) {
|
||||
bool heightSystemConditions = element.useMinimapHeightSystem && element.IsInMinimapRadius && !outOfBounds;
|
||||
element.ShowMinimapAboveArrow (heightSystemConditions && -posOffset.y < -minimapDistanceAbove);
|
||||
element.ShowMinimapBelowArrow (heightSystemConditions && -posOffset.y > minimapDistanceBelow);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -865,6 +891,7 @@ namespace SickscoreGames.HUDNavigationSystem
|
||||
|
||||
this.useMinimap = config.useMinimap;
|
||||
this.minimapMode = config.minimapMode;
|
||||
this.minimapShape = config.minimapShape;
|
||||
this.minimapScale = config.minimapScale;
|
||||
this.minimapRadius = config.minimapRadius;
|
||||
this.useMinimapScaling = config.useMinimapScaling;
|
||||
@@ -910,5 +937,12 @@ namespace SickscoreGames.HUDNavigationSystem
|
||||
{
|
||||
RotateMinimap, RotatePlayer
|
||||
}
|
||||
|
||||
|
||||
[System.Serializable]
|
||||
public enum MinimapShapes
|
||||
{
|
||||
Rectangular, Circular
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user