3713 lines
117 KiB
C#
3713 lines
117 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class KGFMapSystem : KGFModule, KGFICustomGUI, KGFIValidator
|
|
{
|
|
public class KGFPhotoData
|
|
{
|
|
public Vector3 itsPosition = Vector3.zero;
|
|
|
|
public Texture2D itsTexture;
|
|
|
|
public float itsTextureSize;
|
|
|
|
public float itsMeters;
|
|
|
|
public GameObject itsPhotoPlane;
|
|
|
|
public Material itsPhotoPlaneMaterial;
|
|
}
|
|
|
|
public class KGFClickEventArgs : EventArgs
|
|
{
|
|
public Vector3 itsPosition = Vector3.zero;
|
|
|
|
public KGFClickEventArgs(Vector3 thePosition)
|
|
{
|
|
itsPosition = thePosition;
|
|
}
|
|
}
|
|
|
|
public class KGFMarkerEventArgs : EventArgs
|
|
{
|
|
public KGFIMapIcon itsMarker;
|
|
|
|
public KGFMarkerEventArgs(KGFIMapIcon theMarker)
|
|
{
|
|
itsMarker = theMarker;
|
|
}
|
|
}
|
|
|
|
public enum KGFMapSystemOrientation
|
|
{
|
|
XYSideScroller = 0,
|
|
XZDefault = 1
|
|
}
|
|
|
|
public class KGFFlagEventArgs : EventArgs
|
|
{
|
|
public Vector3 itsPosition = Vector3.zero;
|
|
|
|
public KGFFlagEventArgs(Vector3 thePosition)
|
|
{
|
|
itsPosition = thePosition;
|
|
}
|
|
}
|
|
|
|
[Serializable]
|
|
public class KGFDataMinimap
|
|
{
|
|
public minimap_global_settings itsGlobalSettings = new minimap_global_settings();
|
|
|
|
public minimap_gui_settings itsAppearanceMiniMap = new minimap_gui_settings();
|
|
|
|
public minimap_gui_fullscreen_settings itsAppearanceMap = new minimap_gui_fullscreen_settings();
|
|
|
|
public minimap_panning_settings itsPanning = new minimap_panning_settings();
|
|
|
|
public minimap_fogofwar_settings itsFogOfWar = new minimap_fogofwar_settings();
|
|
|
|
public minimap_zoom_settings itsZoomMiniMap = new minimap_zoom_settings();
|
|
|
|
public minimap_zoom_settings itsZoomMap = new minimap_zoom_settings();
|
|
|
|
public minimap_viewport_settings itsViewport = new minimap_viewport_settings();
|
|
|
|
public minimap_photo_settings itsPhoto = new minimap_photo_settings();
|
|
|
|
public minimap_userflags_settings itsUserFlags = new minimap_userflags_settings();
|
|
|
|
public minimap_shader_settings itsShaders = new minimap_shader_settings();
|
|
|
|
public minimap_tooltip_settings itsToolTip = new minimap_tooltip_settings();
|
|
}
|
|
|
|
[Serializable]
|
|
public class minimap_panning_settings
|
|
{
|
|
public bool itsActive;
|
|
|
|
public bool itsUseBounds;
|
|
|
|
public LayerMask itsBoundsLayers = -1;
|
|
}
|
|
|
|
[Serializable]
|
|
public class minimap_tooltip_settings
|
|
{
|
|
public bool itsActive;
|
|
|
|
public Texture2D itsTextureBackground;
|
|
|
|
public RectOffset itsBackgroundBorder;
|
|
|
|
public RectOffset itsBackgroundPadding;
|
|
|
|
public Color itsColorText = Color.white;
|
|
|
|
public Font itsFontText;
|
|
}
|
|
|
|
[Serializable]
|
|
public class minimap_global_settings
|
|
{
|
|
public bool itsHideGUI;
|
|
|
|
public LayerMask itsRenderLayers = 0;
|
|
|
|
public GameObject itsTarget;
|
|
|
|
public bool itsIsStatic = true;
|
|
|
|
public float itsStaticNorth;
|
|
|
|
public bool itsIsActive = true;
|
|
|
|
public Color itsColorMap = Color.white;
|
|
|
|
public Color itsColorBackground = Color.black;
|
|
|
|
public Color itsColorAll = Color.white;
|
|
|
|
public bool itsEnableLogMessages = true;
|
|
|
|
public KGFMapSystemOrientation itsOrientation = KGFMapSystemOrientation.XZDefault;
|
|
}
|
|
|
|
[Serializable]
|
|
public class minimap_photo_settings
|
|
{
|
|
public bool itsTakePhoto = true;
|
|
|
|
public LayerMask itsPhotoLayers = -1;
|
|
|
|
public float itsPixelPerMeter = 5f;
|
|
}
|
|
|
|
[Serializable]
|
|
public class minimap_shader_settings
|
|
{
|
|
public Shader itsShaderMapIcon;
|
|
|
|
public Shader itsShaderPhotoPlane;
|
|
|
|
public Shader itsShaderFogOfWar;
|
|
|
|
public Shader itsShaderMapMask;
|
|
}
|
|
|
|
[Serializable]
|
|
public class minimap_userflags_settings
|
|
{
|
|
public bool itsActive = true;
|
|
|
|
public KGFMapIcon itsMapIcon;
|
|
}
|
|
|
|
[Serializable]
|
|
public class minimap_viewport_settings
|
|
{
|
|
public bool itsActive;
|
|
|
|
public Color itsColor = Color.grey;
|
|
|
|
public Camera itsCamera;
|
|
}
|
|
|
|
[Serializable]
|
|
public class minimap_gui_settings
|
|
{
|
|
public float itsSize = 0.2f;
|
|
|
|
public float itsButtonSize = 0.1f;
|
|
|
|
public float itsButtonPadding;
|
|
|
|
public Texture2D itsButton;
|
|
|
|
public Texture2D itsButtonHover;
|
|
|
|
public Texture2D itsButtonDown;
|
|
|
|
public Texture2D itsIconZoomIn;
|
|
|
|
public Texture2D itsIconZoomOut;
|
|
|
|
public Texture2D itsIconZoomLock;
|
|
|
|
public Texture2D itsIconFullscreen;
|
|
|
|
public Texture2D itsBackground;
|
|
|
|
public int itsBackgroundBorder;
|
|
|
|
public Texture2D itsMask;
|
|
|
|
public float itsScaleIcons = 1f;
|
|
|
|
public float itsScaleArrows = 0.2f;
|
|
|
|
public float itsRadiusArrows = 1f;
|
|
|
|
public KGFAlignmentVertical itsAlignmentVertical;
|
|
|
|
public KGFAlignmentHorizontal itsAlignmentHorizontal = KGFAlignmentHorizontal.Right;
|
|
|
|
public float itsMarginHorizontal;
|
|
|
|
public float itsMarginVertical;
|
|
|
|
public Vector3 itsRotation = Vector3.zero;
|
|
}
|
|
|
|
[Serializable]
|
|
public class minimap_gui_fullscreen_settings
|
|
{
|
|
public float itsSize = 1f;
|
|
|
|
public float itsButtonSize = 0.1f;
|
|
|
|
public float itsButtonPadding;
|
|
|
|
public float itsButtonSpace = 0.01f;
|
|
|
|
public Texture2D itsButton;
|
|
|
|
public Texture2D itsButtonHover;
|
|
|
|
public Texture2D itsButtonDown;
|
|
|
|
public Texture2D itsIconZoomIn;
|
|
|
|
public Texture2D itsIconZoomOut;
|
|
|
|
public Texture2D itsIconZoomLock;
|
|
|
|
public Texture2D itsIconFullscreen;
|
|
|
|
public Texture2D itsBackground;
|
|
|
|
public int itsBackgroundBorder;
|
|
|
|
public Texture2D itsMask;
|
|
|
|
public float itsScaleIcons = 1f;
|
|
|
|
public KGFAlignmentVertical itsAlignmentVertical;
|
|
|
|
public KGFAlignmentHorizontal itsAlignmentHorizontal = KGFAlignmentHorizontal.Right;
|
|
|
|
public KGFOrientation itsOrientation;
|
|
}
|
|
|
|
[Serializable]
|
|
public class minimap_fogofwar_settings
|
|
{
|
|
public bool itsActive = true;
|
|
|
|
public int itsResolutionX = 10;
|
|
|
|
public int itsResolutionY = 10;
|
|
|
|
public float itsRevealDistance = 10f;
|
|
|
|
public float itsRevealedFullDistance = 5f;
|
|
|
|
public bool itsHideMapIcons;
|
|
}
|
|
|
|
[Serializable]
|
|
public class minimap_zoom_settings
|
|
{
|
|
public float itsZoomStartValue = 20f;
|
|
|
|
public float itsZoomMin = 10f;
|
|
|
|
public float itsZoomMax = 30f;
|
|
|
|
public float itsZoomChangeValue = 10f;
|
|
}
|
|
|
|
public class mapicon_listitem_script
|
|
{
|
|
public KGFMapSystem itsModule;
|
|
|
|
public KGFIMapIcon itsMapIcon;
|
|
|
|
public GameObject itsRepresentationInstance;
|
|
|
|
public Transform itsRepresentationInstanceTransform;
|
|
|
|
public bool itsRotate;
|
|
|
|
public GameObject itsRepresentationArrowInstance;
|
|
|
|
public Transform itsRepresentationArrowInstanceTransform;
|
|
|
|
public Transform itsMapIconTransform;
|
|
|
|
private bool itsVisibility;
|
|
|
|
private bool itsVisibilityArrow;
|
|
|
|
public Vector3 itsCachedRepresentationSize = Vector3.zero;
|
|
|
|
public Vector3 GetRepresentationSize()
|
|
{
|
|
if (itsRepresentationInstanceTransform != null)
|
|
{
|
|
return itsCachedRepresentationSize * itsRepresentationInstanceTransform.localScale.x;
|
|
}
|
|
return itsCachedRepresentationSize;
|
|
}
|
|
|
|
public void UpdateVisibility()
|
|
{
|
|
if (itsMapIcon == null)
|
|
{
|
|
return;
|
|
}
|
|
if (itsRepresentationInstance != null)
|
|
{
|
|
bool flag = itsMapIcon.GetIsVisible() && itsVisibility;
|
|
if (flag != KGFGetActive(itsRepresentationInstance))
|
|
{
|
|
foreach (Transform item in itsRepresentationInstance.transform)
|
|
{
|
|
GameObject gameObject = item.gameObject;
|
|
KGFSetChildrenActiveRecursively(gameObject, flag);
|
|
}
|
|
KGFSetChildrenActiveRecursively(itsRepresentationInstance, flag);
|
|
if (itsModule != null)
|
|
{
|
|
itsModule.LogInfo(string.Format("Icon of '{0}' (category='{1}') changed visibility to: {2}", itsMapIcon.GetTransform().name, itsMapIcon.GetCategory(), flag), itsModule.name, itsModule);
|
|
}
|
|
}
|
|
}
|
|
if (itsRepresentationArrowInstance != null)
|
|
{
|
|
KGFSetChildrenActiveRecursively(itsRepresentationArrowInstance, itsMapIcon.GetIsVisible() && itsVisibility && itsVisibilityArrow && itsMapIcon.GetIsArrowVisible());
|
|
}
|
|
}
|
|
|
|
public void UpdateIcon()
|
|
{
|
|
if (itsMapIcon == null)
|
|
{
|
|
return;
|
|
}
|
|
SetColorsInChildren(itsRepresentationArrowInstance, itsMapIcon.GetColor());
|
|
SetColorsInChildren(itsRepresentationInstance, itsMapIcon.GetColor());
|
|
if (itsRepresentationArrowInstance != null)
|
|
{
|
|
MeshRenderer component = itsRepresentationArrowInstance.GetComponent<MeshRenderer>();
|
|
if (component != null)
|
|
{
|
|
component.material.mainTexture = itsMapIcon.GetTextureArrow();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void SetColorsInChildren(GameObject theGameObject, Color theColor)
|
|
{
|
|
if (!(theGameObject != null))
|
|
{
|
|
return;
|
|
}
|
|
MeshRenderer[] componentsInChildren = theGameObject.GetComponentsInChildren<MeshRenderer>(true);
|
|
if (componentsInChildren == null)
|
|
{
|
|
return;
|
|
}
|
|
MeshRenderer[] array = componentsInChildren;
|
|
foreach (MeshRenderer meshRenderer in array)
|
|
{
|
|
Material sharedMaterial = meshRenderer.sharedMaterial;
|
|
if (sharedMaterial != null)
|
|
{
|
|
sharedMaterial.color = theColor;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void SetVisibility(bool theVisible)
|
|
{
|
|
if (theVisible != itsVisibility)
|
|
{
|
|
itsVisibility = theVisible;
|
|
UpdateVisibility();
|
|
}
|
|
}
|
|
|
|
public bool GetMapIconVisibilityEffective()
|
|
{
|
|
if (itsMapIcon != null)
|
|
{
|
|
return itsVisibility && itsMapIcon.GetIsVisible();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public void ShowArrow(bool theShow)
|
|
{
|
|
if (theShow != itsVisibilityArrow && itsRepresentationArrowInstance != null)
|
|
{
|
|
itsVisibilityArrow = theShow;
|
|
UpdateVisibility();
|
|
}
|
|
}
|
|
|
|
public bool GetIsArrowVisible()
|
|
{
|
|
return itsVisibilityArrow;
|
|
}
|
|
|
|
public void Destroy()
|
|
{
|
|
if (itsRepresentationArrowInstance != null)
|
|
{
|
|
UnityEngine.Object.Destroy(itsRepresentationArrowInstance);
|
|
}
|
|
if (itsRepresentationInstance != null)
|
|
{
|
|
UnityEngine.Object.Destroy(itsRepresentationInstance);
|
|
}
|
|
}
|
|
}
|
|
|
|
public delegate void RenderToolTipMethodType(string theToolTipText);
|
|
|
|
public KGFDataMinimap itsDataModuleMinimap = new KGFDataMinimap();
|
|
|
|
private const string itsLayerName = "mapsystem";
|
|
|
|
private bool itsMinimapActive = true;
|
|
|
|
private List<mapicon_listitem_script> itsListMapIcons = new List<mapicon_listitem_script>();
|
|
|
|
private int itsLayerMinimap = -1;
|
|
|
|
private Transform itsTargetTransform;
|
|
|
|
private Transform itsContainerFlags;
|
|
|
|
private Transform itsContainerUser;
|
|
|
|
public Transform itsContainerIcons;
|
|
|
|
private Transform itsContainerIconArrows;
|
|
|
|
private Material itsMaterialMaskedMinimap;
|
|
|
|
private Material itsMaterialViewport;
|
|
|
|
private Camera itsCamera;
|
|
|
|
private Transform itsCameraTransform;
|
|
|
|
public Camera itsCameraOutput;
|
|
|
|
private GameObject itsMinimapPlane;
|
|
|
|
private Transform itsMinimapPlaneTransform;
|
|
|
|
private MeshFilter itsMinimapMeshFilter;
|
|
|
|
private RenderTexture itsRendertexture;
|
|
|
|
private Rect itsTargetRect;
|
|
|
|
private Rect itsRectZoomIn;
|
|
|
|
private Rect itsRectZoomOut;
|
|
|
|
private Rect itsRectStatic;
|
|
|
|
private Rect itsRectFullscreen;
|
|
|
|
private GUIStyle itsGuiStyleButton;
|
|
|
|
private GUIStyle itsGuiStyleButtonFullscreen;
|
|
|
|
private GUIStyle itsGuiStyleBack;
|
|
|
|
private MeshFilter itsMeshFilterFogOfWarPlane;
|
|
|
|
private Color itsColorFogOfWarRevealed = new Color(0f, 0f, 0f, 0f);
|
|
|
|
private Vector2 itsSizeTerrain = Vector2.zero;
|
|
|
|
private Vector2 itsScalingFogOfWar = Vector2.zero;
|
|
|
|
private MeshRenderer itsMeshRendererMinimapPlane;
|
|
|
|
private Bounds itsTerrainBoundsPanning;
|
|
|
|
private Bounds itsTerrainBoundsPhoto;
|
|
|
|
private Vector2? itsSavedResolution;
|
|
|
|
private bool itsModeFullscreen;
|
|
|
|
private float itsCurrentZoomMiniMap;
|
|
|
|
private float itsCurrentZoomDestMiniMap;
|
|
|
|
private float itsCurrentZoomMap;
|
|
|
|
private float itsCurrentZoomDestMap;
|
|
|
|
private List<KGFMapIcon> itsListUserIcons = new List<KGFMapIcon>();
|
|
|
|
private List<KGFIMapIcon> itsListClickIcons = new List<KGFIMapIcon>();
|
|
|
|
private List<KGFPhotoData> itsListOfPhotoData = new List<KGFPhotoData>();
|
|
|
|
private KGFPhotoData[] itsArrayOfPhotoData;
|
|
|
|
private int itsArrayOfPhotoDataIndex;
|
|
|
|
private GameObject itsTempCameraGameObject;
|
|
|
|
public KGFDelegate EventVisibilityOnMinimapChanged = new KGFDelegate();
|
|
|
|
public KGFDelegate EventUserFlagCreated = new KGFDelegate();
|
|
|
|
public KGFDelegate EventClickedOnMinimap = new KGFDelegate();
|
|
|
|
public KGFDelegate EventMouseMapEntered = new KGFDelegate();
|
|
|
|
public KGFDelegate EventMouseMapLeft = new KGFDelegate();
|
|
|
|
public KGFDelegate EventMouseMapIconEntered = new KGFDelegate();
|
|
|
|
public KGFDelegate EventMouseMapIconLeft = new KGFDelegate();
|
|
|
|
public KGFDelegate EventMouseMapIconClicked = new KGFDelegate();
|
|
|
|
public KGFDelegate EventFullscreenModeChanged = new KGFDelegate();
|
|
|
|
private bool itsErrorMode;
|
|
|
|
private const string itsSaveIDFogOfWarValues = "minimap_FogOfWar_values";
|
|
|
|
private Color[] itsFOWColors;
|
|
|
|
private Vector3[] itsFOWVertices;
|
|
|
|
private GameObject itsGameObjectViewPort;
|
|
|
|
private Mesh itsViewPortCubeMesh;
|
|
|
|
private GameObject itsGameObjectPhotoParent;
|
|
|
|
private Texture2D itsTextureRenderMaskCurrent;
|
|
|
|
private Vector2 itsMapPanning = Vector2.zero;
|
|
|
|
private Vector2 itsMapPanningDest = Vector2.zero;
|
|
|
|
private Vector2 itsMapPanningMousePosLast = Vector2.zero;
|
|
|
|
private float itsPanningMinMouseDistanceStart = 2f;
|
|
|
|
private int itsPanningButton;
|
|
|
|
private float itsVelX;
|
|
|
|
private float itsVelY;
|
|
|
|
private List<Vector3> itsDeferedClickList = new List<Vector3>();
|
|
|
|
private Vector3 itsSavedMouseDownPoint = Vector3.zero;
|
|
|
|
private int itsClickUsedInFrame = -1;
|
|
|
|
private mapicon_listitem_script itsMapIconHoveredCurrent;
|
|
|
|
private bool itsMouseEnteredMap;
|
|
|
|
private float itsRotation;
|
|
|
|
private RenderToolTipMethodType itsRenderToolTipMethod;
|
|
|
|
private float itsZoomChangeVelocity;
|
|
|
|
private Vector2 itsCustomGuiPosition = Vector2.zero;
|
|
|
|
public KGFMapSystem()
|
|
: base(new Version(2, 3, 0, 0), new Version(1, 2, 0, 0))
|
|
{
|
|
}
|
|
|
|
public static void KGFSetChildrenActiveRecursively(GameObject theGameObject, bool theActive)
|
|
{
|
|
if (!(theGameObject == null))
|
|
{
|
|
theGameObject.SetActiveRecursively(theActive);
|
|
}
|
|
}
|
|
|
|
public static bool KGFGetActive(GameObject theGameObject)
|
|
{
|
|
return theGameObject.active;
|
|
}
|
|
|
|
private Vector3 ChangeVectorHeight(Vector3 theVector, float theHeight)
|
|
{
|
|
switch (itsDataModuleMinimap.itsGlobalSettings.itsOrientation)
|
|
{
|
|
case KGFMapSystemOrientation.XYSideScroller:
|
|
theVector.z = theHeight;
|
|
break;
|
|
case KGFMapSystemOrientation.XZDefault:
|
|
theVector.y = theHeight;
|
|
break;
|
|
}
|
|
return theVector;
|
|
}
|
|
|
|
private Vector3 ChangeVectorPlane(Vector3 theVector, float theI, float theJ)
|
|
{
|
|
switch (itsDataModuleMinimap.itsGlobalSettings.itsOrientation)
|
|
{
|
|
case KGFMapSystemOrientation.XYSideScroller:
|
|
theVector.x = theI;
|
|
theVector.y = theJ;
|
|
break;
|
|
case KGFMapSystemOrientation.XZDefault:
|
|
theVector.x = theI;
|
|
theVector.z = theJ;
|
|
break;
|
|
}
|
|
return theVector;
|
|
}
|
|
|
|
private Vector3 CreateVector(float theI, float theJ, float theHeight)
|
|
{
|
|
return ChangeVectorPlane(ChangeVectorHeight(Vector3.zero, theHeight), theI, theJ);
|
|
}
|
|
|
|
private float GetVector3Height(Vector3 theVector)
|
|
{
|
|
switch (itsDataModuleMinimap.itsGlobalSettings.itsOrientation)
|
|
{
|
|
case KGFMapSystemOrientation.XYSideScroller:
|
|
return theVector.z;
|
|
case KGFMapSystemOrientation.XZDefault:
|
|
return theVector.y;
|
|
default:
|
|
return 0f;
|
|
}
|
|
}
|
|
|
|
private Vector2 GetVector3Plane(Vector3 theVector)
|
|
{
|
|
switch (itsDataModuleMinimap.itsGlobalSettings.itsOrientation)
|
|
{
|
|
case KGFMapSystemOrientation.XYSideScroller:
|
|
return new Vector2(theVector.x, theVector.y);
|
|
case KGFMapSystemOrientation.XZDefault:
|
|
return new Vector2(theVector.x, theVector.z);
|
|
default:
|
|
return Vector2.zero;
|
|
}
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
RefreshIconsVisibility();
|
|
}
|
|
|
|
public void RefreshIconsVisibility()
|
|
{
|
|
foreach (mapicon_listitem_script itsListMapIcon in itsListMapIcons)
|
|
{
|
|
itsListMapIcon.UpdateVisibility();
|
|
}
|
|
}
|
|
|
|
public void UpdateIcon(KGFIMapIcon theIcon)
|
|
{
|
|
foreach (mapicon_listitem_script itsListMapIcon in itsListMapIcons)
|
|
{
|
|
if (itsListMapIcon.itsMapIcon == theIcon)
|
|
{
|
|
itsListMapIcon.UpdateIcon();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void MeasureScene()
|
|
{
|
|
GetMeasuredBounds(itsDataModuleMinimap.itsPanning.itsBoundsLayers, out itsTerrainBoundsPanning);
|
|
GetMeasuredBounds(itsDataModuleMinimap.itsPhoto.itsPhotoLayers, out itsTerrainBoundsPhoto);
|
|
itsSizeTerrain = GetVector3Plane(itsTerrainBoundsPhoto.size);
|
|
}
|
|
|
|
private float GetTerrainHeight(float theAddHeight)
|
|
{
|
|
if (itsDataModuleMinimap.itsGlobalSettings.itsOrientation == KGFMapSystemOrientation.XZDefault)
|
|
{
|
|
if (itsDataModuleMinimap.itsPhoto.itsTakePhoto)
|
|
{
|
|
return itsTerrainBoundsPhoto.min.y - 1f + theAddHeight;
|
|
}
|
|
return itsTerrainBoundsPhoto.max.y + 1f + theAddHeight;
|
|
}
|
|
return itsTerrainBoundsPhoto.max.z + 1f - theAddHeight;
|
|
}
|
|
|
|
private float GetHeightFog()
|
|
{
|
|
if (itsDataModuleMinimap.itsFogOfWar.itsHideMapIcons)
|
|
{
|
|
return GetTerrainHeight(0.5f);
|
|
}
|
|
return GetTerrainHeight(0.2f);
|
|
}
|
|
|
|
private float GetHeightIcons(int theIndex)
|
|
{
|
|
float num = 0.1f / (float)itsListMapIcons.Count * (float)theIndex;
|
|
return GetTerrainHeight(0.3f) + num;
|
|
}
|
|
|
|
private float GetHeightArrows(int theIndex)
|
|
{
|
|
float num = 0.1f / (float)itsListMapIcons.Count * (float)theIndex;
|
|
return GetTerrainHeight(0.9f) + num;
|
|
}
|
|
|
|
private float GetHeightViewPort()
|
|
{
|
|
return GetTerrainHeight(0.1f);
|
|
}
|
|
|
|
private float GetHeightFlags()
|
|
{
|
|
return GetTerrainHeight(0.4f);
|
|
}
|
|
|
|
private float GetHeightPhoto()
|
|
{
|
|
return GetTerrainHeight(0f);
|
|
}
|
|
|
|
protected override void KGFAwake()
|
|
{
|
|
UpdateStyles();
|
|
itsLayerMinimap = LayerMask.NameToLayer("mapsystem");
|
|
if (Validate().itsHasErrors)
|
|
{
|
|
itsErrorMode = true;
|
|
return;
|
|
}
|
|
CreateCameras();
|
|
CreateRenderTexture();
|
|
itsContainerFlags = new GameObject("flags").transform;
|
|
itsContainerFlags.parent = base.transform;
|
|
itsContainerUser = new GameObject("user").transform;
|
|
itsContainerUser.parent = base.transform;
|
|
itsContainerIcons = new GameObject("icons").transform;
|
|
itsContainerIcons.parent = base.transform;
|
|
itsContainerIconArrows = new GameObject("arrows").transform;
|
|
itsContainerIconArrows.parent = base.transform;
|
|
foreach (KGFIMapIcon @object in KGFAccessor.GetObjects<KGFIMapIcon>())
|
|
{
|
|
RegisterIcon(@object);
|
|
}
|
|
SetTarget(itsDataModuleMinimap.itsGlobalSettings.itsTarget);
|
|
KGFAccessor.RegisterAddEvent<KGFIMapIcon>(OnMapIconAdd);
|
|
KGFAccessor.RegisterRemoveEvent<KGFIMapIcon>(OnMapIconRemove);
|
|
}
|
|
|
|
private bool GetHasProVersion()
|
|
{
|
|
return SystemInfo.supportsRenderTextures;
|
|
}
|
|
|
|
private IEnumerator DeferedPhoto()
|
|
{
|
|
yield return new WaitForSeconds(0.1f);
|
|
AutoCreatePhoto();
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
if (itsErrorMode)
|
|
{
|
|
return;
|
|
}
|
|
MeasureScene();
|
|
if (itsDataModuleMinimap.itsPhoto.itsTakePhoto)
|
|
{
|
|
StartCoroutine(DeferedPhoto());
|
|
}
|
|
if (itsDataModuleMinimap.itsShaders.itsShaderFogOfWar == null)
|
|
{
|
|
LogWarning("itsDataModuleMinimap.itsShaders.itsShaderFogOfWar is not assigned. Please install the standard unity particle package. Assign the Particle Alpha Blend Shader to itsDataModuleMinimap.itsShaders.itsShaderFogOfWar.", base.name, this);
|
|
}
|
|
else if (itsDataModuleMinimap.itsFogOfWar.itsActive)
|
|
{
|
|
InitFogOfWar();
|
|
}
|
|
if (GetHasProVersion())
|
|
{
|
|
itsMinimapPlane = GenerateMinimapPlane();
|
|
itsMinimapPlaneTransform = itsMinimapPlane.transform;
|
|
MeshRenderer component = itsMinimapPlane.GetComponent<MeshRenderer>();
|
|
if (component == null)
|
|
{
|
|
LogError("Cannot find meshrenderer", base.name, this);
|
|
}
|
|
else
|
|
{
|
|
component.material.SetTexture("_MainTex", itsRendertexture);
|
|
if ((bool)HUDManager.Instance)
|
|
{
|
|
if (VRManager.IsVROn())
|
|
{
|
|
HUDManager.Instance.radarVRBackgroundRaw.texture = itsRendertexture;
|
|
}
|
|
else
|
|
{
|
|
HUDManager.Instance.radarVRBackgroundRaw.transform.parent.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
SetViewportEnabled(itsDataModuleMinimap.itsViewport.itsActive);
|
|
SetMinimapEnabled(itsDataModuleMinimap.itsGlobalSettings.itsIsActive);
|
|
}
|
|
|
|
private float GetWidth()
|
|
{
|
|
if (GetFullscreen())
|
|
{
|
|
return GetHeight() * ((float)Screen.width / (float)Screen.height);
|
|
}
|
|
return GetHeight();
|
|
}
|
|
|
|
private float GetHeight()
|
|
{
|
|
if (GetFullscreen())
|
|
{
|
|
return itsDataModuleMinimap.itsAppearanceMap.itsSize * (float)Screen.height;
|
|
}
|
|
return itsDataModuleMinimap.itsAppearanceMiniMap.itsSize * (float)Screen.height;
|
|
}
|
|
|
|
private float GetButtonSize()
|
|
{
|
|
if (GetFullscreen())
|
|
{
|
|
return itsDataModuleMinimap.itsAppearanceMap.itsButtonSize * GetHeight();
|
|
}
|
|
return itsDataModuleMinimap.itsAppearanceMiniMap.itsButtonSize * GetHeight();
|
|
}
|
|
|
|
private float GetButtonPadding()
|
|
{
|
|
if (GetFullscreen())
|
|
{
|
|
return itsDataModuleMinimap.itsAppearanceMap.itsButtonPadding * GetWidth();
|
|
}
|
|
return itsDataModuleMinimap.itsAppearanceMiniMap.itsButtonPadding * GetWidth();
|
|
}
|
|
|
|
private void LogError(string theError, string theCategory, MonoBehaviour theObject)
|
|
{
|
|
if (itsDataModuleMinimap.itsGlobalSettings.itsEnableLogMessages)
|
|
{
|
|
Debug.LogError(string.Format("{0} - {1}", theCategory, theError));
|
|
}
|
|
}
|
|
|
|
private void LogWarning(string theWarning, string theCategory, MonoBehaviour theObject)
|
|
{
|
|
if (itsDataModuleMinimap.itsGlobalSettings.itsEnableLogMessages)
|
|
{
|
|
Debug.LogWarning(string.Format("{0} - {1}", theCategory, theWarning));
|
|
}
|
|
}
|
|
|
|
private void LogInfo(string theError, string theCategory, MonoBehaviour theObject)
|
|
{
|
|
if (itsDataModuleMinimap.itsGlobalSettings.itsEnableLogMessages)
|
|
{
|
|
Debug.Log(string.Format("{0} - {1}", theCategory, theError));
|
|
}
|
|
}
|
|
|
|
private Mesh GeneratePlaneMeshXZ()
|
|
{
|
|
Mesh mesh = new Mesh();
|
|
Vector3[] vertices = new Vector3[4]
|
|
{
|
|
new Vector3(0f, 0f, 0f),
|
|
new Vector3(1f, 0f, 0f),
|
|
new Vector3(1f, 0f, 1f),
|
|
new Vector3(0f, 0f, 1f)
|
|
};
|
|
Vector3[] normals = new Vector3[4]
|
|
{
|
|
new Vector3(0f, 1f, 0f),
|
|
new Vector3(0f, 1f, 0f),
|
|
new Vector3(0f, 1f, 0f),
|
|
new Vector3(0f, 1f, 0f)
|
|
};
|
|
Vector2[] uv = new Vector2[4]
|
|
{
|
|
new Vector2(0f, 0f),
|
|
new Vector2(1f, 0f),
|
|
new Vector2(1f, 1f),
|
|
new Vector2(0f, 1f)
|
|
};
|
|
int[] triangles = new int[6] { 0, 3, 2, 0, 2, 1 };
|
|
mesh.vertices = vertices;
|
|
mesh.normals = normals;
|
|
mesh.uv = uv;
|
|
mesh.triangles = triangles;
|
|
return mesh;
|
|
}
|
|
|
|
private static Mesh GeneratePlaneMeshXZCentered()
|
|
{
|
|
Mesh mesh = new Mesh();
|
|
Vector3[] vertices = new Vector3[4]
|
|
{
|
|
new Vector3(-0.5f, 0f, -0.5f),
|
|
new Vector3(0.5f, 0f, -0.5f),
|
|
new Vector3(0.5f, 0f, 0.5f),
|
|
new Vector3(-0.5f, 0f, 0.5f)
|
|
};
|
|
Vector3[] normals = new Vector3[4]
|
|
{
|
|
new Vector3(0f, 1f, 0f),
|
|
new Vector3(0f, 1f, 0f),
|
|
new Vector3(0f, 1f, 0f),
|
|
new Vector3(0f, 1f, 0f)
|
|
};
|
|
Vector2[] uv = new Vector2[4]
|
|
{
|
|
new Vector2(0f, 0f),
|
|
new Vector2(1f, 0f),
|
|
new Vector2(1f, 1f),
|
|
new Vector2(0f, 1f)
|
|
};
|
|
int[] triangles = new int[6] { 0, 3, 2, 0, 2, 1 };
|
|
mesh.vertices = vertices;
|
|
mesh.normals = normals;
|
|
mesh.uv = uv;
|
|
mesh.triangles = triangles;
|
|
return mesh;
|
|
}
|
|
|
|
private Mesh CreatePlaneMesh(int theWidth, int theHeight)
|
|
{
|
|
Mesh mesh = new Mesh();
|
|
Vector3[] array = new Vector3[(theWidth + 1) * (theHeight + 1)];
|
|
for (int i = 0; i <= theHeight; i++)
|
|
{
|
|
for (int j = 0; j <= theWidth; j++)
|
|
{
|
|
array[i * (theWidth + 1) + j] = new Vector3(j, 0f, i);
|
|
}
|
|
}
|
|
Vector3[] array2 = new Vector3[array.Length];
|
|
for (int k = 0; k < array2.Length; k++)
|
|
{
|
|
array2[k] = new Vector3(0f, 1f, 0f);
|
|
}
|
|
int[] array3 = new int[array.Length * 2 * 3];
|
|
int num = 0;
|
|
for (int l = 0; l < theHeight; l++)
|
|
{
|
|
for (int m = 0; m < theWidth; m++)
|
|
{
|
|
int num2 = l * (theWidth + 1) + m;
|
|
if (num2 % 2 == 0)
|
|
{
|
|
array3[num++] = num2;
|
|
array3[num++] = num2 + (theWidth + 2);
|
|
array3[num++] = num2 + (theWidth + 1);
|
|
array3[num++] = num2;
|
|
array3[num++] = num2 + 1;
|
|
array3[num++] = num2 + theWidth + 2;
|
|
}
|
|
else
|
|
{
|
|
array3[num++] = num2;
|
|
array3[num++] = num2 + 1;
|
|
array3[num++] = num2 + (theWidth + 1);
|
|
array3[num++] = num2 + 1;
|
|
array3[num++] = num2 + theWidth + 2;
|
|
array3[num++] = num2 + (theWidth + 1);
|
|
}
|
|
}
|
|
}
|
|
Vector2[] array4 = new Vector2[array.Length];
|
|
for (int n = 0; n < array4.Length; n++)
|
|
{
|
|
array4[n] = Vector2.zero;
|
|
}
|
|
mesh.vertices = array;
|
|
mesh.normals = array2;
|
|
mesh.uv = array4;
|
|
mesh.triangles = array3;
|
|
return mesh;
|
|
}
|
|
|
|
private string SerializeFogOfWar()
|
|
{
|
|
if (itsMeshFilterFogOfWarPlane != null && itsMeshFilterFogOfWarPlane.mesh.colors != null)
|
|
{
|
|
string[] array = new string[itsMeshFilterFogOfWarPlane.mesh.vertices.Length];
|
|
for (int i = 0; i < itsMeshFilterFogOfWarPlane.mesh.vertices.Length; i++)
|
|
{
|
|
array[i] = string.Empty + itsMeshFilterFogOfWarPlane.mesh.colors[i].a;
|
|
}
|
|
return string.Join(";", array);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public void Save(string theSaveGameName)
|
|
{
|
|
string text = SerializeFogOfWar();
|
|
if (text != null)
|
|
{
|
|
PlayerPrefs.SetString(theSaveGameName + "minimap_FogOfWar_values", text);
|
|
}
|
|
}
|
|
|
|
private void DeserializeFogOfWar(string theSavedString)
|
|
{
|
|
if (theSavedString != null)
|
|
{
|
|
if (!(itsMeshFilterFogOfWarPlane != null) || itsMeshFilterFogOfWarPlane.mesh.colors == null)
|
|
{
|
|
return;
|
|
}
|
|
Color[] colors = itsMeshFilterFogOfWarPlane.mesh.colors;
|
|
string[] array = theSavedString.Split(';');
|
|
if (array.Length == colors.Length)
|
|
{
|
|
for (int i = 0; i < array.Length; i++)
|
|
{
|
|
try
|
|
{
|
|
colors[i].a = float.Parse(array[i]);
|
|
}
|
|
catch
|
|
{
|
|
LogError("Could not parse saved fog of war", base.name, this);
|
|
return;
|
|
}
|
|
}
|
|
itsMeshFilterFogOfWarPlane.mesh.colors = colors;
|
|
}
|
|
else
|
|
{
|
|
LogError("Saved fog of war size different from current.", base.name, this);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
LogError("No saved fog of war to load.", base.name, this);
|
|
}
|
|
}
|
|
|
|
public void Load(string theSaveGameName)
|
|
{
|
|
string theSavedString = PlayerPrefs.GetString(theSaveGameName + "minimap_FogOfWar_values", null);
|
|
DeserializeFogOfWar(theSavedString);
|
|
}
|
|
|
|
public void RevealFogOfWar()
|
|
{
|
|
if (!(itsMeshFilterFogOfWarPlane == null) && !(itsMeshFilterFogOfWarPlane.mesh == null))
|
|
{
|
|
Color[] colors = itsMeshFilterFogOfWarPlane.mesh.colors;
|
|
for (int i = 0; i < colors.Length; i++)
|
|
{
|
|
colors[i].a = 0f;
|
|
}
|
|
itsMeshFilterFogOfWarPlane.mesh.colors = colors;
|
|
}
|
|
}
|
|
|
|
private GameObject CreateFogOfWarPlane()
|
|
{
|
|
GameObject gameObject = new GameObject("fog_of_war");
|
|
gameObject.transform.parent = base.transform;
|
|
gameObject.layer = itsLayerMinimap;
|
|
MeshFilter meshFilter = gameObject.AddComponent<MeshFilter>();
|
|
meshFilter.mesh = CreatePlaneMesh(itsDataModuleMinimap.itsFogOfWar.itsResolutionX, itsDataModuleMinimap.itsFogOfWar.itsResolutionY);
|
|
MeshRenderer meshRenderer = gameObject.AddComponent<MeshRenderer>();
|
|
meshRenderer.material = new Material(itsDataModuleMinimap.itsShaders.itsShaderFogOfWar);
|
|
return gameObject;
|
|
}
|
|
|
|
public void InitFogOfWar()
|
|
{
|
|
itsScalingFogOfWar = new Vector2(itsSizeTerrain.x / (float)itsDataModuleMinimap.itsFogOfWar.itsResolutionX, itsSizeTerrain.y / (float)itsDataModuleMinimap.itsFogOfWar.itsResolutionY);
|
|
if (itsMeshFilterFogOfWarPlane != null)
|
|
{
|
|
UnityEngine.Object.Destroy(itsMeshFilterFogOfWarPlane.gameObject);
|
|
}
|
|
itsMeshFilterFogOfWarPlane = CreateFogOfWarPlane().GetComponent<MeshFilter>();
|
|
Vector3 theVector = itsTerrainBoundsPhoto.center - itsTerrainBoundsPhoto.extents;
|
|
theVector = ChangeVectorHeight(theVector, GetHeightFog());
|
|
if (itsDataModuleMinimap.itsGlobalSettings.itsOrientation == KGFMapSystemOrientation.XYSideScroller)
|
|
{
|
|
itsMeshFilterFogOfWarPlane.transform.eulerAngles = new Vector3(270f, 0f, 0f);
|
|
}
|
|
itsMeshFilterFogOfWarPlane.transform.position = theVector;
|
|
itsMeshFilterFogOfWarPlane.transform.localScale = new Vector3(itsScalingFogOfWar.x, 1f, itsScalingFogOfWar.y);
|
|
Color[] colors = itsMeshFilterFogOfWarPlane.mesh.colors;
|
|
colors = new Color[itsMeshFilterFogOfWarPlane.mesh.vertexCount];
|
|
for (int i = 0; i < colors.Length; i++)
|
|
{
|
|
colors[i] = itsDataModuleMinimap.itsGlobalSettings.itsColorBackground;
|
|
}
|
|
itsMeshFilterFogOfWarPlane.mesh.colors = colors;
|
|
itsFOWColors = colors;
|
|
itsFOWVertices = itsMeshFilterFogOfWarPlane.mesh.vertices;
|
|
}
|
|
|
|
public void RevealFogOfWarAtPoint(Vector3 thePosition)
|
|
{
|
|
if (itsMeshFilterFogOfWarPlane == null)
|
|
{
|
|
return;
|
|
}
|
|
Vector2 vector3Plane = GetVector3Plane(thePosition - itsMeshFilterFogOfWarPlane.transform.position);
|
|
Vector2 vector = new Vector2(Mathf.RoundToInt(vector3Plane.x / itsSizeTerrain.x * (float)itsDataModuleMinimap.itsFogOfWar.itsResolutionX), Mathf.RoundToInt(vector3Plane.y / itsSizeTerrain.y * (float)itsDataModuleMinimap.itsFogOfWar.itsResolutionY));
|
|
Vector2 vector2 = new Vector2(Mathf.RoundToInt(itsDataModuleMinimap.itsFogOfWar.itsRevealDistance / itsSizeTerrain.x * (float)itsDataModuleMinimap.itsFogOfWar.itsResolutionX), Mathf.RoundToInt(itsDataModuleMinimap.itsFogOfWar.itsRevealDistance / itsSizeTerrain.y * (float)itsDataModuleMinimap.itsFogOfWar.itsResolutionY)) * 2f;
|
|
Vector3 zero = Vector3.zero;
|
|
int num = Math.Min(itsDataModuleMinimap.itsFogOfWar.itsResolutionY + 1, (int)(vector.y + vector2.y));
|
|
for (int i = Math.Max(0, (int)(vector.y - vector2.y)); i < num; i++)
|
|
{
|
|
int num2 = Math.Min(itsDataModuleMinimap.itsFogOfWar.itsResolutionX + 1, (int)(vector.x + vector2.x));
|
|
for (int j = Math.Max(0, (int)(vector.x - vector2.x)); j < num2; j++)
|
|
{
|
|
int num3 = i * (itsDataModuleMinimap.itsFogOfWar.itsResolutionX + 1) + j;
|
|
zero = itsMeshFilterFogOfWarPlane.transform.position + new Vector3(itsFOWVertices[num3].x * itsScalingFogOfWar.x, itsFOWVertices[num3].z * itsScalingFogOfWar.y, itsFOWVertices[num3].z * itsScalingFogOfWar.y);
|
|
zero = ChangeVectorHeight(zero, GetVector3Height(thePosition));
|
|
float num4 = Vector3.Distance(zero, thePosition);
|
|
if (num4 < itsDataModuleMinimap.itsFogOfWar.itsRevealedFullDistance)
|
|
{
|
|
itsFOWColors[num3] = itsColorFogOfWarRevealed;
|
|
}
|
|
else if (num4 < itsDataModuleMinimap.itsFogOfWar.itsRevealDistance)
|
|
{
|
|
float a = Mathf.Min(itsFOWColors[num3].a, Mathf.Clamp((num4 - itsDataModuleMinimap.itsFogOfWar.itsRevealedFullDistance) / (itsDataModuleMinimap.itsFogOfWar.itsRevealDistance - itsDataModuleMinimap.itsFogOfWar.itsRevealedFullDistance), 0f, 1f));
|
|
itsFOWColors[num3].a = a;
|
|
}
|
|
}
|
|
}
|
|
int num5 = (int)(vector.y * (float)(itsDataModuleMinimap.itsFogOfWar.itsResolutionX + 1) + vector.x);
|
|
if (num5 >= 0 && num5 < itsFOWColors.Length)
|
|
{
|
|
itsFOWColors[num5] = itsColorFogOfWarRevealed;
|
|
}
|
|
itsMeshFilterFogOfWarPlane.mesh.colors = itsFOWColors;
|
|
}
|
|
|
|
private void UpdateViewPortCube()
|
|
{
|
|
if (itsDataModuleMinimap.itsGlobalSettings.itsOrientation == KGFMapSystemOrientation.XYSideScroller || itsDataModuleMinimap.itsGlobalSettings.itsTarget == null || itsDataModuleMinimap.itsViewport.itsCamera == null)
|
|
{
|
|
return;
|
|
}
|
|
if (itsViewPortCubeMesh == null)
|
|
{
|
|
itsGameObjectViewPort = new GameObject();
|
|
itsGameObjectViewPort.AddComponent<MeshFilter>().mesh = GeneratePlaneMeshXZ();
|
|
itsMaterialViewport = new Material(itsDataModuleMinimap.itsShaders.itsShaderMapIcon);
|
|
itsGameObjectViewPort.AddComponent<MeshRenderer>().material = itsMaterialViewport;
|
|
itsGameObjectViewPort.name = "minimap viewport";
|
|
itsGameObjectViewPort.transform.parent = base.transform;
|
|
SetLayerRecursively(itsGameObjectViewPort, itsLayerMinimap);
|
|
itsViewPortCubeMesh = itsGameObjectViewPort.GetComponent<MeshFilter>().mesh;
|
|
}
|
|
if (KGFGetActive(itsGameObjectViewPort) != itsDataModuleMinimap.itsViewport.itsActive)
|
|
{
|
|
KGFSetChildrenActiveRecursively(itsGameObjectViewPort, itsDataModuleMinimap.itsViewport.itsActive);
|
|
}
|
|
if (itsDataModuleMinimap.itsViewport.itsActive)
|
|
{
|
|
Vector3[] vertices = itsViewPortCubeMesh.vertices;
|
|
vertices[1] = itsDataModuleMinimap.itsViewport.itsCamera.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height / 2, itsDataModuleMinimap.itsViewport.itsCamera.farClipPlane));
|
|
vertices[2] = itsDataModuleMinimap.itsViewport.itsCamera.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height / 2, itsDataModuleMinimap.itsViewport.itsCamera.nearClipPlane));
|
|
vertices[3] = itsDataModuleMinimap.itsViewport.itsCamera.ScreenToWorldPoint(new Vector3(0f, Screen.height / 2, itsDataModuleMinimap.itsViewport.itsCamera.nearClipPlane));
|
|
vertices[0] = itsDataModuleMinimap.itsViewport.itsCamera.ScreenToWorldPoint(new Vector3(0f, Screen.height / 2, itsDataModuleMinimap.itsViewport.itsCamera.farClipPlane));
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
vertices[i].y = GetHeightViewPort();
|
|
}
|
|
itsViewPortCubeMesh.vertices = vertices;
|
|
itsViewPortCubeMesh.RecalculateBounds();
|
|
itsMaterialViewport.SetColor("_Color", itsDataModuleMinimap.itsViewport.itsColor);
|
|
}
|
|
}
|
|
|
|
private Bounds? GetBoundsOfTerrain(GameObject theTerrain)
|
|
{
|
|
MeshRenderer component = theTerrain.GetComponent<MeshRenderer>();
|
|
if (component != null)
|
|
{
|
|
return component.bounds;
|
|
}
|
|
TerrainCollider component2 = theTerrain.GetComponent<TerrainCollider>();
|
|
if (component2 != null)
|
|
{
|
|
return component2.bounds;
|
|
}
|
|
LogError("Could not get measure bounds of terrain.", base.name, this);
|
|
return null;
|
|
}
|
|
|
|
private void InitLayer()
|
|
{
|
|
if (itsLayerMinimap < 0)
|
|
{
|
|
itsLayerMinimap = LayerMask.NameToLayer("mapsystem");
|
|
}
|
|
}
|
|
|
|
public static bool IsInLayerMask(GameObject obj, LayerMask mask)
|
|
{
|
|
return (mask.value & (1 << obj.layer)) > 0;
|
|
}
|
|
|
|
private bool GetMeasuredBounds(LayerMask theLayers, out Bounds theBounds)
|
|
{
|
|
Bounds? bounds = null;
|
|
InitLayer();
|
|
if (Terrain.activeTerrain != null)
|
|
{
|
|
bounds = GetBoundsOfTerrain(Terrain.activeTerrain.gameObject);
|
|
}
|
|
Renderer[] array = UnityEngine.Object.FindObjectsOfType(typeof(Renderer)) as Renderer[];
|
|
if (array != null)
|
|
{
|
|
Renderer[] array2 = array;
|
|
foreach (Renderer renderer in array2)
|
|
{
|
|
if (renderer.gameObject.layer != itsLayerMinimap && IsInLayerMask(renderer.gameObject, theLayers))
|
|
{
|
|
if (!bounds.HasValue)
|
|
{
|
|
bounds = renderer.bounds;
|
|
continue;
|
|
}
|
|
Bounds value = bounds.Value;
|
|
value.Encapsulate(renderer.bounds);
|
|
bounds = value;
|
|
}
|
|
}
|
|
}
|
|
if (!bounds.HasValue)
|
|
{
|
|
LogError("Could not find terrain nor any other bounds in scene", base.name, this);
|
|
theBounds = default(Bounds);
|
|
return false;
|
|
}
|
|
theBounds = bounds.Value;
|
|
return true;
|
|
}
|
|
|
|
private float GetHighestNPOTSizeSmallerThanScreen()
|
|
{
|
|
float num = Screen.width;
|
|
if ((float)Screen.height < num)
|
|
{
|
|
num = Screen.height;
|
|
}
|
|
float num2;
|
|
for (num2 = 1f; num2 <= num; num2 *= 2f)
|
|
{
|
|
}
|
|
return num2 / 2f;
|
|
}
|
|
|
|
public void TakePhotoOfScene(bool theStartedFromEditor)
|
|
{
|
|
MeasureScene();
|
|
AutoCreatePhoto();
|
|
}
|
|
|
|
private void ClearPhotoData()
|
|
{
|
|
if (Application.isPlaying)
|
|
{
|
|
foreach (KGFPhotoData itsListOfPhotoDatum in itsListOfPhotoData)
|
|
{
|
|
UnityEngine.Object.Destroy(itsListOfPhotoDatum.itsPhotoPlane);
|
|
UnityEngine.Object.Destroy(itsListOfPhotoDatum.itsTexture);
|
|
}
|
|
}
|
|
itsListOfPhotoData.Clear();
|
|
}
|
|
|
|
private KGFPhotoCapture CreatePhotoCamera(float anOrtographicSize, float aTextureSize)
|
|
{
|
|
itsTempCameraGameObject = new GameObject("TempCamera");
|
|
switch (itsDataModuleMinimap.itsGlobalSettings.itsOrientation)
|
|
{
|
|
case KGFMapSystemOrientation.XYSideScroller:
|
|
itsTempCameraGameObject.transform.eulerAngles = new Vector3(0f, 0f, 0f);
|
|
break;
|
|
case KGFMapSystemOrientation.XZDefault:
|
|
itsTempCameraGameObject.transform.eulerAngles = new Vector3(90f, 0f, 0f);
|
|
break;
|
|
}
|
|
Camera camera = itsTempCameraGameObject.AddComponent<Camera>();
|
|
camera.depth = -100f;
|
|
camera.clearFlags = CameraClearFlags.Color;
|
|
camera.backgroundColor = Color.red;
|
|
camera.orthographic = true;
|
|
if (GetOrientation() == KGFMapSystemOrientation.XZDefault)
|
|
{
|
|
camera.farClipPlane = 2f + itsTerrainBoundsPhoto.size.y * 2f;
|
|
}
|
|
else
|
|
{
|
|
camera.farClipPlane = 2f + itsTerrainBoundsPhoto.size.z * 2f;
|
|
}
|
|
camera.cullingMask = itsDataModuleMinimap.itsPhoto.itsPhotoLayers;
|
|
camera.backgroundColor = itsDataModuleMinimap.itsGlobalSettings.itsColorBackground;
|
|
camera.clearFlags = CameraClearFlags.Color;
|
|
camera.aspect = 1f;
|
|
camera.orthographicSize = anOrtographicSize / 2f;
|
|
camera.pixelRect = new Rect(0f, 0f, aTextureSize, aTextureSize);
|
|
KGFSetChildrenActiveRecursively(camera.gameObject, true);
|
|
camera.enabled = true;
|
|
KGFPhotoCapture kGFPhotoCapture = itsTempCameraGameObject.AddComponent<KGFPhotoCapture>();
|
|
kGFPhotoCapture.itsMapSystem = this;
|
|
return kGFPhotoCapture;
|
|
}
|
|
|
|
private void AutoCreatePhoto()
|
|
{
|
|
if (itsGameObjectPhotoParent == null)
|
|
{
|
|
Transform transform = base.transform.Find("photo");
|
|
if (transform != null)
|
|
{
|
|
itsGameObjectPhotoParent = transform.gameObject;
|
|
}
|
|
}
|
|
if (itsTempCameraGameObject != null)
|
|
{
|
|
if (Application.isPlaying)
|
|
{
|
|
UnityEngine.Object.Destroy(itsTempCameraGameObject);
|
|
}
|
|
else
|
|
{
|
|
UnityEngine.Object.DestroyImmediate(itsTempCameraGameObject);
|
|
}
|
|
}
|
|
if (itsGameObjectPhotoParent != null)
|
|
{
|
|
if (Application.isPlaying)
|
|
{
|
|
UnityEngine.Object.Destroy(itsGameObjectPhotoParent);
|
|
}
|
|
else
|
|
{
|
|
UnityEngine.Object.DestroyImmediate(itsGameObjectPhotoParent);
|
|
}
|
|
}
|
|
itsGameObjectPhotoParent = new GameObject("photo");
|
|
itsGameObjectPhotoParent.transform.parent = base.transform;
|
|
Vector2 vector3Plane = GetVector3Plane(itsTerrainBoundsPhoto.min);
|
|
Vector2 vector3Plane2 = GetVector3Plane(itsTerrainBoundsPhoto.max);
|
|
float highestNPOTSizeSmallerThanScreen = GetHighestNPOTSizeSmallerThanScreen();
|
|
float num = highestNPOTSizeSmallerThanScreen / itsDataModuleMinimap.itsPhoto.itsPixelPerMeter;
|
|
float anOrtographicSize = highestNPOTSizeSmallerThanScreen / itsDataModuleMinimap.itsPhoto.itsPixelPerMeter;
|
|
int num2 = 0;
|
|
int num3 = 0;
|
|
ClearPhotoData();
|
|
do
|
|
{
|
|
KGFPhotoData kGFPhotoData = new KGFPhotoData();
|
|
kGFPhotoData.itsMeters = num;
|
|
Vector3 theVector = itsTerrainBoundsPhoto.max - itsTerrainBoundsPhoto.min;
|
|
theVector = ChangeVectorHeight(theVector, 0f);
|
|
switch (itsDataModuleMinimap.itsGlobalSettings.itsOrientation)
|
|
{
|
|
case KGFMapSystemOrientation.XYSideScroller:
|
|
kGFPhotoData.itsPosition = CreateVector(vector3Plane.x + num * (float)num2, vector3Plane.y + num * (float)num3, itsTerrainBoundsPhoto.max.z + 1f);
|
|
break;
|
|
case KGFMapSystemOrientation.XZDefault:
|
|
kGFPhotoData.itsPosition = CreateVector(vector3Plane.x + num * (float)num2, vector3Plane.y + num * (float)num3, itsTerrainBoundsPhoto.min.y - 1f);
|
|
break;
|
|
}
|
|
kGFPhotoData.itsTexture = new Texture2D((int)highestNPOTSizeSmallerThanScreen, (int)highestNPOTSizeSmallerThanScreen, TextureFormat.ARGB32, false);
|
|
kGFPhotoData.itsTextureSize = highestNPOTSizeSmallerThanScreen;
|
|
GameObject gameObject = GeneratePhotoPlane(kGFPhotoData);
|
|
KGFSetChildrenActiveRecursively(gameObject, false);
|
|
gameObject.transform.parent = itsGameObjectPhotoParent.transform;
|
|
gameObject.name = gameObject.name + "_" + num2 + "_" + num3;
|
|
SetLayerRecursively(gameObject.gameObject, itsLayerMinimap);
|
|
Vector3 itsPosition = kGFPhotoData.itsPosition;
|
|
gameObject.transform.position = itsPosition;
|
|
gameObject.transform.localScale = new Vector3(num, 1f, num);
|
|
switch (itsDataModuleMinimap.itsGlobalSettings.itsOrientation)
|
|
{
|
|
case KGFMapSystemOrientation.XYSideScroller:
|
|
gameObject.transform.localEulerAngles = new Vector3(270f, 0f, 0f);
|
|
break;
|
|
case KGFMapSystemOrientation.XZDefault:
|
|
gameObject.transform.localEulerAngles = Vector3.zero;
|
|
break;
|
|
}
|
|
kGFPhotoData.itsPhotoPlane = gameObject;
|
|
itsListOfPhotoData.Add(kGFPhotoData);
|
|
num2++;
|
|
if (vector3Plane.x + (float)num2 * num > vector3Plane2.x)
|
|
{
|
|
num2 = 0;
|
|
num3++;
|
|
}
|
|
}
|
|
while (!(vector3Plane.y + (float)num3 * num > vector3Plane2.y));
|
|
itsArrayOfPhotoData = itsListOfPhotoData.ToArray();
|
|
SetColors();
|
|
CreatePhotoCamera(anOrtographicSize, highestNPOTSizeSmallerThanScreen);
|
|
}
|
|
|
|
public KGFPhotoData[] GetPhotoData()
|
|
{
|
|
if (itsListOfPhotoData != null)
|
|
{
|
|
return itsListOfPhotoData.ToArray();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public GameObject GetPhotoParent()
|
|
{
|
|
return itsGameObjectPhotoParent;
|
|
}
|
|
|
|
public KGFPhotoData GetNextPhotoData()
|
|
{
|
|
if (itsArrayOfPhotoDataIndex < itsArrayOfPhotoData.Length)
|
|
{
|
|
itsArrayOfPhotoDataIndex++;
|
|
return itsArrayOfPhotoData[itsArrayOfPhotoDataIndex - 1];
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private void SetLayerRecursively(GameObject theGameObject, int theLayer)
|
|
{
|
|
theGameObject.layer = theLayer;
|
|
foreach (Transform item in theGameObject.transform)
|
|
{
|
|
GameObject theGameObject2 = item.gameObject;
|
|
SetLayerRecursively(theGameObject2, theLayer);
|
|
}
|
|
}
|
|
|
|
private void CreateCameras()
|
|
{
|
|
itsCamera = GetComponentInChildren<Camera>();
|
|
itsCamera.aspect = 1f;
|
|
itsCamera.orthographic = true;
|
|
itsCamera.clearFlags = CameraClearFlags.Color;
|
|
itsCamera.backgroundColor = itsDataModuleMinimap.itsGlobalSettings.itsColorBackground;
|
|
itsCameraTransform = itsCamera.transform;
|
|
GameObject gameObject = new GameObject("outputcamera");
|
|
itsCameraOutput = gameObject.AddComponent<Camera>();
|
|
itsCameraOutput.transform.parent = itsCamera.transform;
|
|
itsCameraOutput.transform.localPosition = Vector3.zero;
|
|
itsCameraOutput.transform.localEulerAngles = new Vector3(0f, 180f, 0f);
|
|
itsCameraOutput.transform.localScale = Vector3.one;
|
|
itsCameraOutput.orthographic = true;
|
|
itsCameraOutput.clearFlags = CameraClearFlags.Depth;
|
|
itsCameraOutput.depth = 50f;
|
|
itsCameraOutput.cullingMask = 1 << itsLayerMinimap;
|
|
gameObject.AddComponent<DisableFog>();
|
|
if (itsModeFullscreen)
|
|
{
|
|
itsCurrentZoomMap = itsDataModuleMinimap.itsZoomMap.itsZoomStartValue;
|
|
itsCurrentZoomDestMap = itsCurrentZoomMap;
|
|
}
|
|
else
|
|
{
|
|
itsCurrentZoomMiniMap = itsDataModuleMinimap.itsZoomMiniMap.itsZoomStartValue;
|
|
itsCurrentZoomDestMiniMap = itsCurrentZoomMiniMap;
|
|
}
|
|
UpdateOrthographicSize();
|
|
}
|
|
|
|
private void CreateRenderTexture()
|
|
{
|
|
if (itsDataModuleMinimap.itsAppearanceMiniMap.itsMask != null && GetHasProVersion())
|
|
{
|
|
itsRendertexture = new RenderTexture(512, 512, 16, RenderTextureFormat.ARGB32);
|
|
if (itsRendertexture != null)
|
|
{
|
|
itsRendertexture.isPowerOfTwo = true;
|
|
itsRendertexture.name = "minimap_rendertexture";
|
|
itsRendertexture.Create();
|
|
itsCamera.targetTexture = itsRendertexture;
|
|
}
|
|
else
|
|
{
|
|
LogError("cannot create rendertexture for minimap", base.name, this);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnGUI()
|
|
{
|
|
RenderGUI();
|
|
}
|
|
|
|
private void OnMapIconAdd(object theSender, EventArgs theArgs)
|
|
{
|
|
KGFAccessor.KGFAccessorEventargs kGFAccessorEventargs = theArgs as KGFAccessor.KGFAccessorEventargs;
|
|
if (kGFAccessorEventargs != null)
|
|
{
|
|
KGFIMapIcon kGFIMapIcon = kGFAccessorEventargs.GetObject() as KGFIMapIcon;
|
|
if (kGFIMapIcon != null)
|
|
{
|
|
RegisterIcon(kGFIMapIcon);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnMapIconRemove(object theSender, EventArgs theArgs)
|
|
{
|
|
KGFAccessor.KGFAccessorEventargs kGFAccessorEventargs = theArgs as KGFAccessor.KGFAccessorEventargs;
|
|
if (kGFAccessorEventargs != null)
|
|
{
|
|
KGFIMapIcon kGFIMapIcon = kGFAccessorEventargs.GetObject() as KGFIMapIcon;
|
|
if (kGFIMapIcon != null)
|
|
{
|
|
UnregisterMapIcon(kGFIMapIcon);
|
|
}
|
|
}
|
|
}
|
|
|
|
private KGFMapIcon CreateIconInternal(Vector3 theWorldPoint, KGFMapIcon theIcon, Transform theParent)
|
|
{
|
|
GameObject gameObject = UnityEngine.Object.Instantiate(theIcon.gameObject);
|
|
gameObject.name = "Flag";
|
|
gameObject.transform.parent = itsContainerFlags;
|
|
gameObject.transform.position = theWorldPoint;
|
|
return gameObject.GetComponent<KGFMapIcon>();
|
|
}
|
|
|
|
private GameObject GenerateMinimapPlane()
|
|
{
|
|
GameObject gameObject = new GameObject("output_plane");
|
|
gameObject.layer = itsLayerMinimap;
|
|
gameObject.transform.parent = base.transform;
|
|
itsMinimapMeshFilter = gameObject.AddComponent<MeshFilter>();
|
|
itsMinimapMeshFilter.mesh = GeneratePlaneMeshXZ();
|
|
itsMeshRendererMinimapPlane = gameObject.gameObject.AddComponent<MeshRenderer>();
|
|
itsMeshRendererMinimapPlane.material = new Material(itsDataModuleMinimap.itsShaders.itsShaderMapMask);
|
|
itsMeshRendererMinimapPlane.material.SetTexture("_Mask", itsDataModuleMinimap.itsAppearanceMiniMap.itsMask);
|
|
itsMaterialMaskedMinimap = itsMeshRendererMinimapPlane.material;
|
|
return gameObject;
|
|
}
|
|
|
|
public void SetMask(Texture2D theMinimapMask, Texture2D theMapMask)
|
|
{
|
|
if (!(itsMeshRendererMinimapPlane.material == null))
|
|
{
|
|
itsDataModuleMinimap.itsAppearanceMiniMap.itsMask = theMinimapMask;
|
|
itsDataModuleMinimap.itsAppearanceMap.itsMask = theMapMask;
|
|
UpdateMaskTexture();
|
|
}
|
|
}
|
|
|
|
public void SetMinimapHorizontalAlignment(KGFAlignmentHorizontal theAlignmentHorizontal)
|
|
{
|
|
itsDataModuleMinimap.itsAppearanceMiniMap.itsAlignmentHorizontal = theAlignmentHorizontal;
|
|
}
|
|
|
|
public void SetMinimapVerticalAlignment(KGFAlignmentVertical theAlignmentVertical)
|
|
{
|
|
itsDataModuleMinimap.itsAppearanceMiniMap.itsAlignmentVertical = theAlignmentVertical;
|
|
}
|
|
|
|
public void SetMinimapHorizontalMargin(float theMargin)
|
|
{
|
|
itsDataModuleMinimap.itsAppearanceMiniMap.itsMarginHorizontal = theMargin;
|
|
}
|
|
|
|
public void SetMinimapVerticalMargin(float theMargin)
|
|
{
|
|
itsDataModuleMinimap.itsAppearanceMiniMap.itsMarginVertical = theMargin;
|
|
}
|
|
|
|
public void SetGlobalHideGui(bool theHideGui)
|
|
{
|
|
itsDataModuleMinimap.itsGlobalSettings.itsHideGUI = theHideGui;
|
|
}
|
|
|
|
public void SetMapSize(float theSize)
|
|
{
|
|
itsDataModuleMinimap.itsAppearanceMap.itsSize = theSize;
|
|
UpdateOrthographicSize();
|
|
}
|
|
|
|
public void SetMinimapButtonSize(float theSize)
|
|
{
|
|
itsDataModuleMinimap.itsAppearanceMiniMap.itsButtonSize = theSize;
|
|
}
|
|
|
|
public void SetMapButtonSize(float theSize)
|
|
{
|
|
itsDataModuleMinimap.itsAppearanceMap.itsButtonSize = theSize;
|
|
}
|
|
|
|
public void SetMinimapButtonPadding(float thePadding)
|
|
{
|
|
itsDataModuleMinimap.itsAppearanceMiniMap.itsButtonPadding = thePadding;
|
|
}
|
|
|
|
public void SetMapButtonPadding(float thePadding)
|
|
{
|
|
itsDataModuleMinimap.itsAppearanceMap.itsButtonPadding = thePadding;
|
|
}
|
|
|
|
public void SetMapButtonSpace(float theSpace)
|
|
{
|
|
itsDataModuleMinimap.itsAppearanceMap.itsButtonSpace = theSpace;
|
|
}
|
|
|
|
public void SetMinimapIconScale(float theScale)
|
|
{
|
|
itsDataModuleMinimap.itsAppearanceMiniMap.itsScaleIcons = theScale;
|
|
}
|
|
|
|
public void SetMapIconScale(float theScale)
|
|
{
|
|
itsDataModuleMinimap.itsAppearanceMap.itsScaleIcons = theScale;
|
|
}
|
|
|
|
public void SetMinimapArrowScale(float theScale)
|
|
{
|
|
itsDataModuleMinimap.itsAppearanceMiniMap.itsScaleArrows = theScale;
|
|
}
|
|
|
|
public void SetMinimapArrowRadius(float theRadius)
|
|
{
|
|
itsDataModuleMinimap.itsAppearanceMiniMap.itsRadiusArrows = theRadius;
|
|
}
|
|
|
|
public void SetMapButtonOrientation(KGFOrientation theOrientation)
|
|
{
|
|
itsDataModuleMinimap.itsAppearanceMap.itsOrientation = theOrientation;
|
|
}
|
|
|
|
public void SetMapButtonAlighmentHorizontal(KGFAlignmentHorizontal theAlignment)
|
|
{
|
|
itsDataModuleMinimap.itsAppearanceMap.itsAlignmentHorizontal = theAlignment;
|
|
}
|
|
|
|
public void SetMapButtonAlighmentVertical(KGFAlignmentVertical theAlignment)
|
|
{
|
|
itsDataModuleMinimap.itsAppearanceMap.itsAlignmentVertical = theAlignment;
|
|
}
|
|
|
|
public static GameObject GenerateTexturePlane(Texture2D theTexture, Shader theShader)
|
|
{
|
|
GameObject gameObject = new GameObject("MapIconPlane");
|
|
MeshFilter meshFilter = gameObject.AddComponent<MeshFilter>();
|
|
meshFilter.transform.eulerAngles = new Vector3(0f, 0f, 0f);
|
|
meshFilter.mesh = GeneratePlaneMeshXZCentered();
|
|
MeshRenderer meshRenderer = meshFilter.gameObject.AddComponent<MeshRenderer>();
|
|
meshRenderer.material = new Material(theShader);
|
|
meshRenderer.material.mainTexture = theTexture;
|
|
meshRenderer.castShadows = false;
|
|
meshRenderer.receiveShadows = false;
|
|
return gameObject;
|
|
}
|
|
|
|
private GameObject GeneratePhotoPlane(KGFPhotoData thePhotoData)
|
|
{
|
|
GameObject gameObject = new GameObject("photo_plane");
|
|
gameObject.layer = itsLayerMinimap;
|
|
gameObject.transform.parent = base.transform;
|
|
MeshFilter meshFilter = gameObject.AddComponent<MeshFilter>();
|
|
meshFilter.transform.eulerAngles = Vector3.zero;
|
|
meshFilter.transform.position = Vector3.zero;
|
|
meshFilter.mesh = GeneratePlaneMeshXZ();
|
|
MeshRenderer meshRenderer = meshFilter.gameObject.AddComponent<MeshRenderer>();
|
|
meshRenderer.castShadows = false;
|
|
meshRenderer.receiveShadows = false;
|
|
Material material = new Material(itsDataModuleMinimap.itsShaders.itsShaderPhotoPlane);
|
|
material.mainTexture = thePhotoData.itsTexture;
|
|
meshRenderer.material = material;
|
|
thePhotoData.itsPhotoPlaneMaterial = material;
|
|
return gameObject;
|
|
}
|
|
|
|
private void UpdateMinimapOutputPlane()
|
|
{
|
|
Camera camera = itsCameraOutput;
|
|
if (camera != null && itsMinimapPlane != null && !(itsMinimapMeshFilter == null))
|
|
{
|
|
Mesh mesh = itsMinimapMeshFilter.mesh;
|
|
if (!(mesh == null))
|
|
{
|
|
Rect rect = itsTargetRect;
|
|
rect.y = (float)Screen.height - rect.y;
|
|
Vector3 vector = camera.ScreenToWorldPoint(new Vector3(rect.center.x, rect.center.y - rect.height, camera.nearClipPlane + 0.01f));
|
|
itsMinimapPlaneTransform.position = vector + new Vector3(0f, 500f, 0f);
|
|
itsMinimapPlaneTransform.localRotation = Quaternion.Euler(itsDataModuleMinimap.itsAppearanceMiniMap.itsRotation);
|
|
Vector3[] vertices = mesh.vertices;
|
|
vertices[0] = camera.ScreenToWorldPoint(new Vector3(rect.x, rect.y - rect.height, camera.nearClipPlane + 0.01f)) - vector;
|
|
vertices[1] = camera.ScreenToWorldPoint(new Vector3(rect.x + rect.width, rect.y - rect.height, camera.nearClipPlane + 0.01f)) - vector;
|
|
vertices[2] = camera.ScreenToWorldPoint(new Vector3(rect.x + rect.width, rect.y, camera.nearClipPlane + 0.01f)) - vector;
|
|
vertices[3] = camera.ScreenToWorldPoint(new Vector3(rect.x, rect.y, camera.nearClipPlane + 0.01f)) - vector;
|
|
mesh.vertices = vertices;
|
|
mesh.RecalculateBounds();
|
|
Vector3 forward = camera.transform.forward;
|
|
Vector3[] normals = mesh.normals;
|
|
normals[0] = forward;
|
|
normals[1] = forward;
|
|
normals[2] = forward;
|
|
normals[3] = forward;
|
|
mesh.normals = normals;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void CleanClickIconsList()
|
|
{
|
|
for (int num = itsListClickIcons.Count - 1; num >= 0; num--)
|
|
{
|
|
if (itsListClickIcons[num] == null)
|
|
{
|
|
itsListClickIcons.RemoveAt(num);
|
|
}
|
|
else if (itsListClickIcons[num] is MonoBehaviour && (MonoBehaviour)itsListClickIcons[num] == null)
|
|
{
|
|
itsListClickIcons.RemoveAt(num);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void UpdateIconLayer(KGFIMapIcon theMapIcon)
|
|
{
|
|
GameObject representation = theMapIcon.GetRepresentation();
|
|
MeshRenderer[] componentsInChildren = representation.GetComponentsInChildren<MeshRenderer>();
|
|
CleanClickIconsList();
|
|
MeshRenderer[] array = componentsInChildren;
|
|
foreach (MeshRenderer meshRenderer in array)
|
|
{
|
|
if (itsDataModuleMinimap.itsFogOfWar.itsHideMapIcons && !itsListClickIcons.Contains(theMapIcon))
|
|
{
|
|
meshRenderer.sharedMaterial.renderQueue = 3000;
|
|
}
|
|
else
|
|
{
|
|
meshRenderer.sharedMaterial.renderQueue = 3200;
|
|
}
|
|
}
|
|
}
|
|
|
|
private Vector3 GetGameObjectSize(GameObject theGO)
|
|
{
|
|
MeshRenderer[] componentsInChildren = theGO.GetComponentsInChildren<MeshRenderer>(true);
|
|
if (componentsInChildren.Length == 0)
|
|
{
|
|
Debug.LogError("found not meshrenderers on mapicon:" + theGO.name);
|
|
return Vector3.zero;
|
|
}
|
|
Bounds bounds = componentsInChildren[0].bounds;
|
|
for (int i = 1; i < componentsInChildren.Length; i++)
|
|
{
|
|
bounds.Encapsulate(componentsInChildren[i].bounds);
|
|
}
|
|
return bounds.size;
|
|
}
|
|
|
|
private void RegisterIcon(KGFIMapIcon theMapIcon)
|
|
{
|
|
GameObject gameObject = null;
|
|
GameObject gameObject2 = null;
|
|
gameObject2 = theMapIcon.GetRepresentation();
|
|
if (gameObject2 == null)
|
|
{
|
|
LogError("missing icon representation for: " + theMapIcon.GetGameObjectName(), base.name, this);
|
|
return;
|
|
}
|
|
UpdateIconLayer(theMapIcon);
|
|
if (theMapIcon.GetTextureArrow() != null)
|
|
{
|
|
gameObject = GenerateTexturePlane(theMapIcon.GetTextureArrow(), itsDataModuleMinimap.itsShaders.itsShaderMapIcon);
|
|
gameObject.transform.parent = itsContainerIconArrows;
|
|
gameObject.transform.localPosition = Vector3.zero;
|
|
gameObject.transform.localScale = Vector3.one;
|
|
gameObject.GetComponent<MeshRenderer>().material.renderQueue = 3200;
|
|
SetLayerRecursively(gameObject.gameObject, itsLayerMinimap);
|
|
}
|
|
gameObject2.transform.parent = itsContainerIcons;
|
|
gameObject2.transform.position = Vector3.zero;
|
|
SetLayerRecursively(gameObject2.gameObject, itsLayerMinimap);
|
|
mapicon_listitem_script mapicon_listitem_script2 = new mapicon_listitem_script();
|
|
mapicon_listitem_script2.itsModule = this;
|
|
mapicon_listitem_script2.itsMapIcon = theMapIcon;
|
|
mapicon_listitem_script2.itsRepresentationInstance = gameObject2;
|
|
mapicon_listitem_script2.itsRepresentationInstanceTransform = gameObject2.transform;
|
|
mapicon_listitem_script2.itsRotate = theMapIcon.GetRotate();
|
|
mapicon_listitem_script2.itsRepresentationArrowInstance = gameObject;
|
|
mapicon_listitem_script2.itsMapIconTransform = theMapIcon.GetTransform();
|
|
mapicon_listitem_script2.SetVisibility(true);
|
|
if (gameObject != null)
|
|
{
|
|
mapicon_listitem_script2.itsRepresentationArrowInstanceTransform = gameObject.transform;
|
|
}
|
|
mapicon_listitem_script2.itsCachedRepresentationSize = GetGameObjectSize(gameObject2);
|
|
itsListMapIcons.Add(mapicon_listitem_script2);
|
|
itsListMapIcons.Sort(CompareMapIcons);
|
|
mapicon_listitem_script2.UpdateIcon();
|
|
UpdateIconScale();
|
|
LogInfo(string.Format("Added icon of category '{0}' for '{1}'", theMapIcon.GetCategory(), theMapIcon.GetTransform().name), base.name, this);
|
|
}
|
|
|
|
private int CompareMapIcons(mapicon_listitem_script theMapIcon1, mapicon_listitem_script theMapIcon2)
|
|
{
|
|
return theMapIcon1.itsMapIcon.GetDepth().CompareTo(theMapIcon2.itsMapIcon.GetDepth());
|
|
}
|
|
|
|
private void UnregisterMapIcon(KGFIMapIcon theMapIcon)
|
|
{
|
|
mapicon_listitem_script mapicon_listitem_script2 = null;
|
|
for (int i = 0; i < itsListMapIcons.Count; i++)
|
|
{
|
|
mapicon_listitem_script mapicon_listitem_script3 = itsListMapIcons[i];
|
|
if (mapicon_listitem_script3.itsMapIcon == theMapIcon)
|
|
{
|
|
mapicon_listitem_script2 = mapicon_listitem_script3;
|
|
break;
|
|
}
|
|
}
|
|
if (mapicon_listitem_script2 != null)
|
|
{
|
|
LogInfo("Removed map icon of " + mapicon_listitem_script2.itsMapIconTransform.gameObject.GetObjectPath(), base.name, this);
|
|
mapicon_listitem_script2.Destroy();
|
|
itsListMapIcons.Remove(mapicon_listitem_script2);
|
|
}
|
|
}
|
|
|
|
private void UpdateIconScale()
|
|
{
|
|
float scaleIcons = GetScaleIcons();
|
|
float scaleArrows = GetScaleArrows();
|
|
foreach (mapicon_listitem_script itsListMapIcon in itsListMapIcons)
|
|
{
|
|
if (itsListMapIcon.itsRepresentationInstanceTransform != null)
|
|
{
|
|
if (itsListMapIcon.itsMapIcon != null)
|
|
{
|
|
itsListMapIcon.itsRepresentationInstanceTransform.localScale = Vector3.one * scaleIcons * itsListMapIcon.itsMapIcon.GetIconScale();
|
|
}
|
|
else
|
|
{
|
|
itsListMapIcon.itsRepresentationInstanceTransform.localScale = Vector3.one * scaleIcons;
|
|
}
|
|
}
|
|
if (itsListMapIcon.itsRepresentationArrowInstanceTransform != null)
|
|
{
|
|
itsListMapIcon.itsRepresentationArrowInstanceTransform.localScale = Vector3.one * scaleArrows;
|
|
}
|
|
}
|
|
}
|
|
|
|
private float GetScaleArrows()
|
|
{
|
|
if (GetFullscreen() || GetPanningActive())
|
|
{
|
|
return 0f;
|
|
}
|
|
return GetCurrentZoom() * itsDataModuleMinimap.itsAppearanceMiniMap.itsScaleArrows * 2f;
|
|
}
|
|
|
|
private float GetScaleIcons()
|
|
{
|
|
if (GetFullscreen())
|
|
{
|
|
return GetCurrentZoom() * itsDataModuleMinimap.itsAppearanceMap.itsScaleIcons * 2f * (itsSavedResolution.Value.y / GetHeight());
|
|
}
|
|
return GetCurrentZoom() * itsDataModuleMinimap.itsAppearanceMiniMap.itsScaleIcons * 2f;
|
|
}
|
|
|
|
private void UpdateMaskTexture()
|
|
{
|
|
if (GetFullscreen())
|
|
{
|
|
itsTextureRenderMaskCurrent = itsDataModuleMinimap.itsAppearanceMap.itsMask;
|
|
}
|
|
else
|
|
{
|
|
itsTextureRenderMaskCurrent = itsDataModuleMinimap.itsAppearanceMiniMap.itsMask;
|
|
}
|
|
if (itsTextureRenderMaskCurrent != null && itsMeshRendererMinimapPlane != null)
|
|
{
|
|
itsMeshRendererMinimapPlane.material.SetTexture("_Mask", itsTextureRenderMaskCurrent);
|
|
}
|
|
if (GetOutputPlaneActive())
|
|
{
|
|
if (itsMeshRendererMinimapPlane != null)
|
|
{
|
|
itsMeshRendererMinimapPlane.enabled = true;
|
|
}
|
|
itsCameraOutput.enabled = true;
|
|
itsCamera.targetTexture = itsRendertexture;
|
|
itsCamera.rect = new Rect(0f, 0f, 1f, 1f);
|
|
}
|
|
else
|
|
{
|
|
if (itsMeshRendererMinimapPlane != null)
|
|
{
|
|
itsMeshRendererMinimapPlane.enabled = false;
|
|
}
|
|
itsCameraOutput.enabled = false;
|
|
itsCamera.targetTexture = null;
|
|
itsCamera.pixelRect = new Rect(itsTargetRect.x, (float)Screen.height - itsTargetRect.y - itsTargetRect.height, itsTargetRect.width, itsTargetRect.height);
|
|
}
|
|
}
|
|
|
|
private void UpdateCameraLayer()
|
|
{
|
|
itsCamera.cullingMask = (int)itsDataModuleMinimap.itsGlobalSettings.itsRenderLayers | (1 << itsLayerMinimap);
|
|
}
|
|
|
|
private void SetColors()
|
|
{
|
|
if (itsMaterialMaskedMinimap != null)
|
|
{
|
|
itsMaterialMaskedMinimap.SetColor("_Color", itsDataModuleMinimap.itsGlobalSettings.itsColorAll);
|
|
}
|
|
if (itsArrayOfPhotoData == null)
|
|
{
|
|
return;
|
|
}
|
|
KGFPhotoData[] array = itsArrayOfPhotoData;
|
|
foreach (KGFPhotoData kGFPhotoData in array)
|
|
{
|
|
if (kGFPhotoData != null)
|
|
{
|
|
kGFPhotoData.itsPhotoPlaneMaterial.SetColor("_Color", itsDataModuleMinimap.itsGlobalSettings.itsColorMap);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (itsErrorMode)
|
|
{
|
|
return;
|
|
}
|
|
UpdateCameraLayer();
|
|
UpdateZoom();
|
|
UpdateIconScale();
|
|
UpdateOrthographicSize();
|
|
SetColors();
|
|
if (itsTargetTransform == null)
|
|
{
|
|
base.enabled = false;
|
|
return;
|
|
}
|
|
ScrollWheelZooming();
|
|
UpdatePanning();
|
|
UpdateMaskTexture();
|
|
bool theClickOnIcon;
|
|
UpdateMapIconHover(out theClickOnIcon);
|
|
if (!theClickOnIcon)
|
|
{
|
|
CheckForClicksOnMinimap();
|
|
}
|
|
UpdateMapIconRotation();
|
|
UpdateViewPortCube();
|
|
}
|
|
|
|
private void ScrollWheelZooming()
|
|
{
|
|
if (GetHoverWithoutButtons())
|
|
{
|
|
SetZoom(GetZoom() - Input.GetAxis("Mouse ScrollWheel") * 50f);
|
|
}
|
|
}
|
|
|
|
private bool GetPanningActive()
|
|
{
|
|
if (!itsDataModuleMinimap.itsPanning.itsActive)
|
|
{
|
|
return false;
|
|
}
|
|
return itsMapPanning != Vector2.zero;
|
|
}
|
|
|
|
private bool GetPanningMoveActive()
|
|
{
|
|
if (!itsDataModuleMinimap.itsPanning.itsActive)
|
|
{
|
|
return false;
|
|
}
|
|
return Input.GetMouseButton(itsPanningButton);
|
|
}
|
|
|
|
private void ForcePanningStart()
|
|
{
|
|
itsMapPanning = new Vector2(0.01f, 0.01f);
|
|
UpdateIconScale();
|
|
}
|
|
|
|
public void StopMapPanning()
|
|
{
|
|
itsMapPanningDest = Vector2.zero;
|
|
}
|
|
|
|
private void UpdatePanning()
|
|
{
|
|
if (!itsDataModuleMinimap.itsPanning.itsActive)
|
|
{
|
|
itsMapPanning = Vector2.zero;
|
|
itsMapPanningDest = Vector2.zero;
|
|
return;
|
|
}
|
|
if (GetHover())
|
|
{
|
|
if (Input.GetMouseButtonDown(itsPanningButton))
|
|
{
|
|
itsMapPanningMousePosLast = Input.mousePosition;
|
|
}
|
|
if (!GetPanningActive() && Input.GetMouseButton(itsPanningButton) && Vector2.Distance(Input.mousePosition, itsMapPanningMousePosLast) > itsPanningMinMouseDistanceStart)
|
|
{
|
|
ForcePanningStart();
|
|
}
|
|
}
|
|
if (!GetPanningActive())
|
|
{
|
|
return;
|
|
}
|
|
if (Input.GetMouseButton(itsPanningButton))
|
|
{
|
|
float num = itsCamera.orthographicSize * 1f * itsCamera.aspect / itsTargetRect.width;
|
|
float num2 = itsCamera.orthographicSize * 1f / itsTargetRect.height;
|
|
Vector2 vector = (Vector2)Input.mousePosition - itsMapPanningMousePosLast;
|
|
itsMapPanning -= new Vector2(vector.x * num, vector.y * num2) * 2f;
|
|
itsMapPanningDest = itsMapPanning;
|
|
itsMapPanningMousePosLast = Input.mousePosition;
|
|
}
|
|
if (Input.GetMouseButtonUp(itsPanningButton) && !GetFullscreen())
|
|
{
|
|
StopMapPanning();
|
|
}
|
|
if (itsMapPanning != itsMapPanningDest)
|
|
{
|
|
float x = Mathf.SmoothDamp(itsMapPanning.x, itsMapPanningDest.x, ref itsVelX, 0.1f);
|
|
float y = Mathf.SmoothDamp(itsMapPanning.y, itsMapPanningDest.y, ref itsVelY, 0.1f);
|
|
itsMapPanning = new Vector2(x, y);
|
|
if (itsMapPanning.magnitude < 0.1f)
|
|
{
|
|
itsMapPanning = Vector2.zero;
|
|
itsMapPanningDest = itsMapPanning;
|
|
UpdateIconScale();
|
|
}
|
|
}
|
|
}
|
|
|
|
private bool GetOutputPlaneActive()
|
|
{
|
|
return GetHasProVersion() && itsTextureRenderMaskCurrent != null;
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if (GetOutputPlaneActive())
|
|
{
|
|
UpdateMinimapOutputPlane();
|
|
}
|
|
}
|
|
|
|
private Vector3? GetMouseToWorldPointOnMap()
|
|
{
|
|
Vector2 point = Input.mousePosition;
|
|
point.y = (float)Screen.height - point.y;
|
|
if (itsTargetRect.Contains(point))
|
|
{
|
|
if (itsRectFullscreen.Contains(point) || itsRectStatic.Contains(point) || itsRectZoomIn.Contains(point) || itsRectZoomOut.Contains(point))
|
|
{
|
|
return null;
|
|
}
|
|
Vector2 vector = new Vector2((point.x - itsTargetRect.x) / itsTargetRect.width, (point.y - itsTargetRect.y) / itsTargetRect.height);
|
|
Vector2 vector2 = vector - new Vector2(0.5f, 0.5f);
|
|
return (itsDataModuleMinimap.itsGlobalSettings.itsOrientation != KGFMapSystemOrientation.XZDefault) ? (itsCameraTransform.position + itsCameraTransform.up * vector2.y * itsCamera.orthographicSize * -2f + itsCameraTransform.right * vector2.x * itsCamera.orthographicSize * 2f * itsCamera.aspect) : (itsCameraTransform.position + itsCameraTransform.up * vector2.y * itsCamera.orthographicSize * -2f + itsCameraTransform.right * vector2.x * itsCamera.orthographicSize * 2f * itsCamera.aspect);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
private void CheckForClicksOnMinimap()
|
|
{
|
|
CheckDeferedClickList();
|
|
if (Input.GetMouseButtonDown(0))
|
|
{
|
|
itsSavedMouseDownPoint = Input.mousePosition;
|
|
}
|
|
if (!Input.GetMouseButtonUp(0) || !(Vector3.Distance(Input.mousePosition, itsSavedMouseDownPoint) < 2f))
|
|
{
|
|
return;
|
|
}
|
|
Vector3? mouseToWorldPointOnMap = GetMouseToWorldPointOnMap();
|
|
if (mouseToWorldPointOnMap.HasValue)
|
|
{
|
|
Vector3 value = mouseToWorldPointOnMap.Value;
|
|
value = ChangeVectorHeight(value, GetHeightFlags());
|
|
if (itsDataModuleMinimap.itsGlobalSettings.itsOrientation == KGFMapSystemOrientation.XZDefault)
|
|
{
|
|
EventClickedOnMinimap.Trigger(this, new KGFClickEventArgs(new Vector3(value.x, 0f, value.z)));
|
|
}
|
|
else
|
|
{
|
|
EventClickedOnMinimap.Trigger(this, new KGFClickEventArgs(new Vector3(value.x, value.y, 0f)));
|
|
}
|
|
if (itsDataModuleMinimap.itsUserFlags.itsActive)
|
|
{
|
|
itsDeferedClickList.Add(value);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void SetClickUsed()
|
|
{
|
|
itsClickUsedInFrame = Time.frameCount;
|
|
}
|
|
|
|
private bool GetClickUsed()
|
|
{
|
|
return Math.Abs(itsClickUsedInFrame - Time.frameCount) <= 1;
|
|
}
|
|
|
|
private void CheckDeferedClickList()
|
|
{
|
|
if (!GetClickUsed())
|
|
{
|
|
for (int i = 0; i < itsDeferedClickList.Count; i++)
|
|
{
|
|
Vector3 vector = itsDeferedClickList[i];
|
|
if (itsDataModuleMinimap.itsUserFlags.itsMapIcon != null)
|
|
{
|
|
EventUserFlagCreated.Trigger(this, new KGFFlagEventArgs(vector));
|
|
LogInfo(string.Format("Added user flag at {0}", vector), base.name, this);
|
|
KGFMapIcon kGFMapIcon = CreateIconInternal(vector, itsDataModuleMinimap.itsUserFlags.itsMapIcon, itsContainerFlags);
|
|
itsListClickIcons.Add(kGFMapIcon);
|
|
UpdateIconLayer(kGFMapIcon);
|
|
}
|
|
}
|
|
}
|
|
itsDeferedClickList.Clear();
|
|
}
|
|
|
|
private void UpdateMapIconHover(out bool theClickOnIcon)
|
|
{
|
|
theClickOnIcon = false;
|
|
Vector2 point = Input.mousePosition;
|
|
point.y = (float)Screen.height - point.y;
|
|
if (itsTargetRect.Contains(point) && !itsMouseEnteredMap)
|
|
{
|
|
itsMouseEnteredMap = true;
|
|
EventMouseMapEntered.Trigger(this);
|
|
LogInfo("Mouse entered map", base.name, this);
|
|
}
|
|
else if (!itsTargetRect.Contains(point) && itsMouseEnteredMap)
|
|
{
|
|
itsMouseEnteredMap = false;
|
|
EventMouseMapLeft.Trigger(this);
|
|
LogInfo("Mouse left map", base.name, this);
|
|
}
|
|
if (itsMapIconHoveredCurrent != null && (MonoBehaviour)itsMapIconHoveredCurrent.itsMapIcon == null)
|
|
{
|
|
itsMapIconHoveredCurrent = null;
|
|
}
|
|
Vector3? mouseToWorldPointOnMap = GetMouseToWorldPointOnMap();
|
|
if (!mouseToWorldPointOnMap.HasValue)
|
|
{
|
|
return;
|
|
}
|
|
bool flag = false;
|
|
for (int i = 0; i < itsListMapIcons.Count; i++)
|
|
{
|
|
Vector3 value = mouseToWorldPointOnMap.Value;
|
|
value = ChangeVectorHeight(value, GetHeightIcons(i));
|
|
mapicon_listitem_script mapicon_listitem_script2 = itsListMapIcons[i];
|
|
float num = mapicon_listitem_script2.GetRepresentationSize().magnitude / 2f;
|
|
if (Vector3.Distance(mapicon_listitem_script2.itsRepresentationInstanceTransform.position, value) < num)
|
|
{
|
|
MapIconEnter(mapicon_listitem_script2);
|
|
flag = true;
|
|
break;
|
|
}
|
|
}
|
|
if (itsMapIconHoveredCurrent != null && Input.GetMouseButtonUp(0))
|
|
{
|
|
theClickOnIcon = true;
|
|
MapIconClick(itsMapIconHoveredCurrent);
|
|
}
|
|
if (!flag && itsMapIconHoveredCurrent != null)
|
|
{
|
|
MapIconLeave(itsMapIconHoveredCurrent);
|
|
}
|
|
}
|
|
|
|
private void MapIconEnter(mapicon_listitem_script theMapIcon)
|
|
{
|
|
if (itsMapIconHoveredCurrent != theMapIcon)
|
|
{
|
|
LogInfo("Mouse entered map icon:" + theMapIcon.itsMapIcon.GetGameObjectName(), base.name, this);
|
|
itsMapIconHoveredCurrent = theMapIcon;
|
|
EventMouseMapIconEntered.Trigger(this, new KGFMarkerEventArgs(theMapIcon.itsMapIcon));
|
|
}
|
|
}
|
|
|
|
private void MapIconLeave(mapicon_listitem_script theMapIcon)
|
|
{
|
|
if (theMapIcon != null)
|
|
{
|
|
LogInfo("Mouse left map icon:" + theMapIcon.itsMapIcon.GetGameObjectName(), base.name, this);
|
|
itsMapIconHoveredCurrent = null;
|
|
EventMouseMapIconLeft.Trigger(this, new KGFMarkerEventArgs(theMapIcon.itsMapIcon));
|
|
}
|
|
}
|
|
|
|
private void MapIconClick(mapicon_listitem_script theMapIcon)
|
|
{
|
|
if (itsListClickIcons.Contains(theMapIcon.itsMapIcon))
|
|
{
|
|
RemoveClickMarker(theMapIcon);
|
|
return;
|
|
}
|
|
LogInfo("Click on map icon:" + theMapIcon.itsMapIcon.GetGameObjectName(), base.name, this);
|
|
EventMouseMapIconClicked.Trigger(this, new KGFMarkerEventArgs(theMapIcon.itsMapIcon));
|
|
}
|
|
|
|
private void RemoveClickMarker(mapicon_listitem_script theMapIcon)
|
|
{
|
|
UnityEngine.Object.Destroy(((MonoBehaviour)theMapIcon.itsMapIcon).gameObject);
|
|
}
|
|
|
|
private Rect GetBounds2DPanning()
|
|
{
|
|
if (itsDataModuleMinimap.itsGlobalSettings.itsOrientation == KGFMapSystemOrientation.XZDefault)
|
|
{
|
|
return new Rect(itsTerrainBoundsPanning.min.x, itsTerrainBoundsPanning.min.z, itsTerrainBoundsPanning.size.x, itsTerrainBoundsPanning.size.z);
|
|
}
|
|
return new Rect(itsTerrainBoundsPanning.min.x, itsTerrainBoundsPanning.min.y, itsTerrainBoundsPanning.size.x, itsTerrainBoundsPanning.size.y);
|
|
}
|
|
|
|
private Vector2 ClampPoint(Vector2 thePoint, Rect theArea, float theBorderX, float theBorderY)
|
|
{
|
|
if (thePoint.x < theArea.x + theBorderX)
|
|
{
|
|
thePoint.x = theArea.x + theBorderX;
|
|
}
|
|
if (thePoint.y < theArea.y + theBorderY)
|
|
{
|
|
thePoint.y = theArea.y + theBorderY;
|
|
}
|
|
if (thePoint.x > theArea.xMax - theBorderX)
|
|
{
|
|
thePoint.x = theArea.xMax - theBorderX;
|
|
}
|
|
if (thePoint.y > theArea.yMax - theBorderY)
|
|
{
|
|
thePoint.y = theArea.yMax - theBorderY;
|
|
}
|
|
return thePoint;
|
|
}
|
|
|
|
private Vector2 GetCurrentCameraPoint2D()
|
|
{
|
|
Vector2 vector = ((itsDataModuleMinimap.itsGlobalSettings.itsOrientation != KGFMapSystemOrientation.XZDefault) ? new Vector2(itsTargetTransform.position.x, itsTargetTransform.position.y) : new Vector2(itsTargetTransform.position.x, itsTargetTransform.position.z));
|
|
if (!itsDataModuleMinimap.itsPanning.itsActive)
|
|
{
|
|
return vector;
|
|
}
|
|
float num = 0f;
|
|
if (itsDataModuleMinimap.itsGlobalSettings.itsIsStatic)
|
|
{
|
|
num = ((!itsModeFullscreen) ? itsCurrentZoomMiniMap : itsCurrentZoomMap);
|
|
}
|
|
if (itsDataModuleMinimap.itsPanning.itsUseBounds)
|
|
{
|
|
Rect bounds2DPanning = GetBounds2DPanning();
|
|
vector = ClampPoint(vector, bounds2DPanning, num * itsCamera.aspect, num);
|
|
Vector2 vector2 = RotateVector2(itsMapPanning, itsRotation);
|
|
Vector2 thePoint = vector + vector2;
|
|
Vector2 vector3 = ClampPoint(thePoint, bounds2DPanning, num * itsCamera.aspect, num);
|
|
Vector2 theVector = vector3 - vector;
|
|
itsMapPanning = RotateVector2(theVector, 0f - itsRotation);
|
|
return vector3;
|
|
}
|
|
Vector2 vector4 = RotateVector2(itsMapPanning, itsRotation);
|
|
return vector + vector4;
|
|
}
|
|
|
|
private Vector2 RotateVector2(Vector2 theVector, float theRotation)
|
|
{
|
|
Vector2 zero = Vector2.zero;
|
|
zero.x = theVector.x * Mathf.Cos(theRotation) - theVector.y * Mathf.Sin(theRotation);
|
|
zero.y = theVector.x * Mathf.Sin(theRotation) + theVector.y * Mathf.Cos(theRotation);
|
|
return zero;
|
|
}
|
|
|
|
private Vector3 GetCurrentCameraPoint3D()
|
|
{
|
|
Vector2 currentCameraPoint2D = GetCurrentCameraPoint2D();
|
|
return CreateVector(currentCameraPoint2D.x, currentCameraPoint2D.y, GetTerrainHeight(5f));
|
|
}
|
|
|
|
private void UpdateMapIconRotation()
|
|
{
|
|
if (itsDataModuleMinimap.itsGlobalSettings.itsOrientation == KGFMapSystemOrientation.XZDefault)
|
|
{
|
|
if (itsDataModuleMinimap.itsGlobalSettings.itsIsStatic)
|
|
{
|
|
itsCameraTransform.eulerAngles = CreateVector(0f, 0f, itsDataModuleMinimap.itsGlobalSettings.itsStaticNorth);
|
|
itsCameraTransform.Rotate(90f, 0f, 0f);
|
|
}
|
|
else
|
|
{
|
|
Vector3 forward = itsTargetTransform.forward;
|
|
forward.y = 0f;
|
|
forward.Normalize();
|
|
itsCameraTransform.rotation = Quaternion.LookRotation(forward, Vector3.up);
|
|
itsCameraTransform.Rotate(90f, 0f, 0f);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
itsCameraTransform.eulerAngles = new Vector3(0f, 0f, 0f);
|
|
}
|
|
itsRotation = -1f * itsCameraTransform.eulerAngles.y * ((float)Math.PI / 180f);
|
|
itsCameraTransform.position = GetCurrentCameraPoint3D();
|
|
for (int num = itsListMapIcons.Count - 1; num >= 0; num--)
|
|
{
|
|
mapicon_listitem_script mapicon_listitem_script2 = itsListMapIcons[num];
|
|
if (mapicon_listitem_script2.itsMapIconTransform == null || mapicon_listitem_script2.itsRepresentationInstanceTransform == null)
|
|
{
|
|
itsListMapIcons.RemoveAt(num);
|
|
}
|
|
else if (mapicon_listitem_script2.GetMapIconVisibilityEffective())
|
|
{
|
|
if (itsDataModuleMinimap.itsGlobalSettings.itsOrientation == KGFMapSystemOrientation.XZDefault)
|
|
{
|
|
if (mapicon_listitem_script2.itsRotate)
|
|
{
|
|
mapicon_listitem_script2.itsRepresentationInstanceTransform.eulerAngles = new Vector3(0f, mapicon_listitem_script2.itsMapIconTransform.eulerAngles.y, 0f);
|
|
}
|
|
else
|
|
{
|
|
mapicon_listitem_script2.itsRepresentationInstanceTransform.eulerAngles = new Vector3(0f, itsCameraTransform.eulerAngles.y, 0f);
|
|
}
|
|
}
|
|
else if (mapicon_listitem_script2.itsRotate)
|
|
{
|
|
mapicon_listitem_script2.itsRepresentationInstanceTransform.eulerAngles = new Vector3(mapicon_listitem_script2.itsMapIconTransform.eulerAngles.z - 90f, 270f, 270f);
|
|
}
|
|
else
|
|
{
|
|
mapicon_listitem_script2.itsRepresentationInstanceTransform.eulerAngles = new Vector3(270f, 0f, 0f);
|
|
}
|
|
mapicon_listitem_script2.itsRepresentationInstanceTransform.position = ChangeVectorHeight(mapicon_listitem_script2.itsMapIconTransform.position, GetHeightIcons(num));
|
|
if (mapicon_listitem_script2.itsRepresentationArrowInstance != null)
|
|
{
|
|
Vector3 theVector = itsTargetTransform.position - mapicon_listitem_script2.itsRepresentationInstanceTransform.position;
|
|
theVector = ChangeVectorHeight(theVector, 0f);
|
|
bool flag = theVector.magnitude > GetCurrentZoom();
|
|
if (flag != mapicon_listitem_script2.GetIsArrowVisible())
|
|
{
|
|
mapicon_listitem_script2.ShowArrow(flag);
|
|
if (flag)
|
|
{
|
|
LogInfo(string.Format("Icon '{0}' got invisible", mapicon_listitem_script2.itsMapIconTransform.name), base.name, this);
|
|
}
|
|
else
|
|
{
|
|
LogInfo(string.Format("Icon '{0}' got visible", mapicon_listitem_script2.itsMapIconTransform.name), base.name, this);
|
|
}
|
|
EventVisibilityOnMinimapChanged.Trigger(this, new KGFMarkerEventArgs(mapicon_listitem_script2.itsMapIcon));
|
|
}
|
|
if (mapicon_listitem_script2.GetIsArrowVisible())
|
|
{
|
|
float num2 = 0f;
|
|
num2 = ((itsDataModuleMinimap.itsGlobalSettings.itsOrientation != KGFMapSystemOrientation.XZDefault) ? Vector3.Angle(Vector3.up, theVector) : Vector3.Angle(Vector3.forward, theVector));
|
|
if (Vector3.Dot(Vector3.right, theVector) < 0f)
|
|
{
|
|
num2 = 360f - num2;
|
|
}
|
|
num2 += 180f;
|
|
float num3 = GetCurrentZoom() * itsDataModuleMinimap.itsAppearanceMiniMap.itsRadiusArrows;
|
|
float num4 = num2 - itsCameraTransform.localEulerAngles.y;
|
|
Vector3 theVector2 = itsCameraTransform.position + itsCameraTransform.right * num3 * itsCamera.aspect * Mathf.Sin(num4 * ((float)Math.PI / 180f)) + itsCameraTransform.up * num3 * Mathf.Cos(num4 * ((float)Math.PI / 180f));
|
|
theVector2 = ChangeVectorHeight(theVector2, GetHeightArrows(num));
|
|
mapicon_listitem_script2.itsRepresentationArrowInstanceTransform.position = theVector2;
|
|
if (itsDataModuleMinimap.itsGlobalSettings.itsOrientation == KGFMapSystemOrientation.XZDefault)
|
|
{
|
|
mapicon_listitem_script2.itsRepresentationArrowInstanceTransform.eulerAngles = new Vector3(0f, num2, 0f);
|
|
}
|
|
else
|
|
{
|
|
mapicon_listitem_script2.itsRepresentationArrowInstanceTransform.eulerAngles = new Vector3(num2 - 90f, 90f, 90f);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public bool GetHover()
|
|
{
|
|
Vector2 point = Input.mousePosition;
|
|
point.y = (float)Screen.height - point.y;
|
|
if (itsTargetRect.Contains(point))
|
|
{
|
|
return true;
|
|
}
|
|
if (itsRectZoomIn.Contains(point))
|
|
{
|
|
return true;
|
|
}
|
|
if (itsRectZoomOut.Contains(point))
|
|
{
|
|
return true;
|
|
}
|
|
if (itsRectStatic.Contains(point))
|
|
{
|
|
return true;
|
|
}
|
|
if (itsRectFullscreen.Contains(point))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public bool GetHoverWithoutButtons()
|
|
{
|
|
Vector2 point = Input.mousePosition;
|
|
point.y = (float)Screen.height - point.y;
|
|
if (itsRectZoomIn.Contains(point))
|
|
{
|
|
return false;
|
|
}
|
|
if (itsRectZoomOut.Contains(point))
|
|
{
|
|
return false;
|
|
}
|
|
if (itsRectStatic.Contains(point))
|
|
{
|
|
return false;
|
|
}
|
|
if (itsRectFullscreen.Contains(point))
|
|
{
|
|
return false;
|
|
}
|
|
if (itsTargetRect.Contains(point))
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public bool GetIsVisibleOnMap(KGFIMapIcon theMapIcon)
|
|
{
|
|
for (int num = itsListMapIcons.Count - 1; num >= 0; num--)
|
|
{
|
|
mapicon_listitem_script mapicon_listitem_script2 = itsListMapIcons[num];
|
|
if (mapicon_listitem_script2.itsMapIcon == theMapIcon)
|
|
{
|
|
return !mapicon_listitem_script2.GetIsArrowVisible() && mapicon_listitem_script2.GetMapIconVisibilityEffective();
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public KGFMapSystemOrientation GetOrientation()
|
|
{
|
|
return itsDataModuleMinimap.itsGlobalSettings.itsOrientation;
|
|
}
|
|
|
|
public void UpdateStyles()
|
|
{
|
|
itsGuiStyleBack = new GUIStyle();
|
|
itsGuiStyleBack.normal.background = itsDataModuleMinimap.itsAppearanceMiniMap.itsBackground;
|
|
itsGuiStyleButton = new GUIStyle();
|
|
itsGuiStyleButton.normal.background = itsDataModuleMinimap.itsAppearanceMiniMap.itsButton;
|
|
itsGuiStyleButton.hover.background = itsDataModuleMinimap.itsAppearanceMiniMap.itsButtonHover;
|
|
itsGuiStyleButton.active.background = itsDataModuleMinimap.itsAppearanceMiniMap.itsButtonDown;
|
|
itsGuiStyleButtonFullscreen = new GUIStyle();
|
|
itsGuiStyleButtonFullscreen.normal.background = itsDataModuleMinimap.itsAppearanceMap.itsButton;
|
|
itsGuiStyleButtonFullscreen.hover.background = itsDataModuleMinimap.itsAppearanceMap.itsButtonHover;
|
|
itsGuiStyleButtonFullscreen.active.background = itsDataModuleMinimap.itsAppearanceMap.itsButtonDown;
|
|
}
|
|
|
|
public string GetSaveString()
|
|
{
|
|
return SerializeFogOfWar();
|
|
}
|
|
|
|
public void LoadFromString(string theSavedString)
|
|
{
|
|
DeserializeFogOfWar(theSavedString);
|
|
}
|
|
|
|
public KGFMapIcon CreateIcon(Vector3 theWorldPoint, KGFMapIcon theMapIcon)
|
|
{
|
|
KGFMapIcon kGFMapIcon = CreateIconInternal(theWorldPoint, theMapIcon, itsContainerUser);
|
|
itsListUserIcons.Add(kGFMapIcon);
|
|
return kGFMapIcon;
|
|
}
|
|
|
|
public void RemoveIcon(KGFMapIcon theIcon)
|
|
{
|
|
if (itsListUserIcons.Contains(theIcon))
|
|
{
|
|
UnregisterMapIcon(theIcon);
|
|
itsListUserIcons.Remove(theIcon);
|
|
}
|
|
else
|
|
{
|
|
LogError("Not a user created icon", base.name, this);
|
|
}
|
|
}
|
|
|
|
public KGFMapIcon[] GetUserIcons()
|
|
{
|
|
return itsListUserIcons.ToArray();
|
|
}
|
|
|
|
public KGFMapIcon[] GetUserFlags()
|
|
{
|
|
List<KGFMapIcon> list = new List<KGFMapIcon>();
|
|
foreach (Transform item in itsContainerFlags.transform)
|
|
{
|
|
list.Add(item.GetComponent<KGFMapIcon>());
|
|
}
|
|
return list.ToArray();
|
|
}
|
|
|
|
public void SetMinimapEnabled(bool theEnable)
|
|
{
|
|
if (itsMinimapActive != theEnable)
|
|
{
|
|
itsMinimapActive = theEnable;
|
|
KGFSetChildrenActiveRecursively(base.gameObject, theEnable);
|
|
KGFSetChildrenActiveRecursively(itsMinimapPlane, theEnable);
|
|
LogInfo("New map system state:" + theEnable, base.name, this);
|
|
}
|
|
}
|
|
|
|
public bool GetMinimapEnabled()
|
|
{
|
|
return itsMinimapActive;
|
|
}
|
|
|
|
public void SetIconsVisibleByCategory(string theCategory, bool theVisible)
|
|
{
|
|
LogInfo(string.Format("Icon category '{0}' changed visibility to: {1}", theCategory, theVisible), base.name, this);
|
|
foreach (mapicon_listitem_script itsListMapIcon in itsListMapIcons)
|
|
{
|
|
if (itsListMapIcon.itsMapIcon.GetCategory() == theCategory)
|
|
{
|
|
itsListMapIcon.SetVisibility(theVisible);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void SetTooltipsByCategory(string theCategory, bool theVisible)
|
|
{
|
|
LogInfo(string.Format("Icon category '{0}' changed tooltip visibility to: {1}", theCategory, theVisible), base.name, this);
|
|
foreach (mapicon_listitem_script itsListMapIcon in itsListMapIcons)
|
|
{
|
|
if (itsListMapIcon.itsMapIcon.GetCategory() == theCategory)
|
|
{
|
|
itsListMapIcon.itsMapIcon.SetShowToolTip(theVisible);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void SetTarget(GameObject theTarget)
|
|
{
|
|
if (theTarget == null)
|
|
{
|
|
LogError("Assign your character to KGFMapsystem.itsTarget. KGFMapSystem will not work without a target.", base.name, this);
|
|
return;
|
|
}
|
|
itsDataModuleMinimap.itsGlobalSettings.itsTarget = theTarget;
|
|
itsTargetTransform = theTarget.transform;
|
|
}
|
|
|
|
public float GetCurrentZoom()
|
|
{
|
|
return itsCamera.orthographicSize;
|
|
}
|
|
|
|
public float GetZoom()
|
|
{
|
|
if (itsModeFullscreen)
|
|
{
|
|
return itsCurrentZoomDestMap;
|
|
}
|
|
return itsCurrentZoomDestMiniMap;
|
|
}
|
|
|
|
public void SetZoom(float theZoom)
|
|
{
|
|
SetZoom(theZoom, true);
|
|
}
|
|
|
|
public void SetZoom(float theZoom, bool theAnimate)
|
|
{
|
|
if (!theAnimate)
|
|
{
|
|
if (itsModeFullscreen)
|
|
{
|
|
itsCurrentZoomMap = theZoom;
|
|
}
|
|
else
|
|
{
|
|
itsCurrentZoomMiniMap = theZoom;
|
|
}
|
|
}
|
|
if (itsModeFullscreen)
|
|
{
|
|
itsCurrentZoomDestMap = theZoom;
|
|
}
|
|
else
|
|
{
|
|
itsCurrentZoomDestMiniMap = theZoom;
|
|
}
|
|
CorrectCurrentZoom();
|
|
UpdateOrthographicSize();
|
|
UpdateIconScale();
|
|
}
|
|
|
|
public void ZoomIn()
|
|
{
|
|
if (itsModeFullscreen)
|
|
{
|
|
SetZoom(GetZoom() - itsDataModuleMinimap.itsZoomMap.itsZoomChangeValue);
|
|
}
|
|
else
|
|
{
|
|
SetZoom(GetZoom() - itsDataModuleMinimap.itsZoomMiniMap.itsZoomChangeValue);
|
|
}
|
|
}
|
|
|
|
public void ZoomOut()
|
|
{
|
|
if (itsModeFullscreen)
|
|
{
|
|
SetZoom(GetZoom() + itsDataModuleMinimap.itsZoomMap.itsZoomChangeValue);
|
|
}
|
|
else
|
|
{
|
|
SetZoom(GetZoom() + itsDataModuleMinimap.itsZoomMiniMap.itsZoomChangeValue);
|
|
}
|
|
}
|
|
|
|
public void ZoomMin()
|
|
{
|
|
if (itsModeFullscreen)
|
|
{
|
|
SetZoom(itsDataModuleMinimap.itsZoomMap.itsZoomMin);
|
|
}
|
|
else
|
|
{
|
|
SetZoom(itsDataModuleMinimap.itsZoomMiniMap.itsZoomMin);
|
|
}
|
|
}
|
|
|
|
public void ZoomMax()
|
|
{
|
|
if (itsModeFullscreen)
|
|
{
|
|
SetZoom(itsDataModuleMinimap.itsZoomMap.itsZoomMax);
|
|
}
|
|
else
|
|
{
|
|
SetZoom(itsDataModuleMinimap.itsZoomMiniMap.itsZoomMax);
|
|
}
|
|
}
|
|
|
|
public void SetViewportEnabled(bool theEnable)
|
|
{
|
|
itsDataModuleMinimap.itsViewport.itsActive = theEnable;
|
|
}
|
|
|
|
public bool GetViewportEnabled()
|
|
{
|
|
return itsDataModuleMinimap.itsViewport.itsActive;
|
|
}
|
|
|
|
public float GetRevealedPercent()
|
|
{
|
|
float num = 0f;
|
|
if (itsMeshFilterFogOfWarPlane != null)
|
|
{
|
|
Color[] colors = itsMeshFilterFogOfWarPlane.mesh.colors;
|
|
for (int i = 0; i < colors.Length; i++)
|
|
{
|
|
Color color = colors[i];
|
|
num += color.a;
|
|
}
|
|
return 1f - num / (float)itsMeshFilterFogOfWarPlane.mesh.colors.Length;
|
|
}
|
|
return 0f;
|
|
}
|
|
|
|
public void SetModeStatic(bool theModeStatic)
|
|
{
|
|
itsDataModuleMinimap.itsGlobalSettings.itsIsStatic = theModeStatic;
|
|
}
|
|
|
|
public bool GetModeStatic()
|
|
{
|
|
return itsDataModuleMinimap.itsGlobalSettings.itsIsStatic;
|
|
}
|
|
|
|
public void SetMinimapSize(float theSize)
|
|
{
|
|
itsDataModuleMinimap.itsAppearanceMiniMap.itsSize = theSize;
|
|
UpdateOrthographicSize();
|
|
}
|
|
|
|
public bool GetFullscreen()
|
|
{
|
|
return itsModeFullscreen;
|
|
}
|
|
|
|
public void SetFullscreen(bool theFullscreenMode)
|
|
{
|
|
if (theFullscreenMode)
|
|
{
|
|
Vector2? vector = itsSavedResolution;
|
|
if (!vector.HasValue)
|
|
{
|
|
itsSavedResolution = new Vector2(GetWidth(), GetHeight());
|
|
goto IL_006b;
|
|
}
|
|
}
|
|
if (!theFullscreenMode)
|
|
{
|
|
Vector2? vector2 = itsSavedResolution;
|
|
if (vector2.HasValue)
|
|
{
|
|
itsSavedResolution = null;
|
|
goto IL_006b;
|
|
}
|
|
return;
|
|
}
|
|
return;
|
|
IL_006b:
|
|
itsModeFullscreen = theFullscreenMode;
|
|
if (itsModeFullscreen)
|
|
{
|
|
SetZoom(itsDataModuleMinimap.itsZoomMap.itsZoomStartValue);
|
|
}
|
|
else
|
|
{
|
|
SetZoom(itsDataModuleMinimap.itsZoomMiniMap.itsZoomStartValue);
|
|
}
|
|
UpdateTargetRect();
|
|
UpdateMaskTexture();
|
|
UpdateOrthographicSize();
|
|
UpdateIconScale();
|
|
EventFullscreenModeChanged.Trigger(this, EventArgs.Empty);
|
|
}
|
|
|
|
private GUIStyle GetButtonStyle()
|
|
{
|
|
if (GetFullscreen())
|
|
{
|
|
return itsGuiStyleButtonFullscreen;
|
|
}
|
|
return itsGuiStyleButton;
|
|
}
|
|
|
|
private bool DrawButton(Rect theRect, Texture2D theTexture)
|
|
{
|
|
if (theTexture == null)
|
|
{
|
|
return false;
|
|
}
|
|
return GUI.Button(theRect, theTexture, GetButtonStyle());
|
|
}
|
|
|
|
private void UpdateTargetRect()
|
|
{
|
|
if (GetFullscreen())
|
|
{
|
|
itsTargetRect.x = ((float)Screen.width - GetWidth()) / 2f;
|
|
itsTargetRect.y = ((float)Screen.height - GetHeight()) / 2f;
|
|
}
|
|
else
|
|
{
|
|
switch (itsDataModuleMinimap.itsAppearanceMiniMap.itsAlignmentHorizontal)
|
|
{
|
|
case KGFAlignmentHorizontal.Left:
|
|
itsTargetRect.x = 0f;
|
|
itsTargetRect.x += ((float)Screen.height - GetHeight()) * itsDataModuleMinimap.itsAppearanceMiniMap.itsMarginHorizontal;
|
|
break;
|
|
case KGFAlignmentHorizontal.Middle:
|
|
itsTargetRect.x = ((float)Screen.width - GetWidth()) / 2f;
|
|
break;
|
|
case KGFAlignmentHorizontal.Right:
|
|
itsTargetRect.x = (float)Screen.width - GetWidth();
|
|
itsTargetRect.x -= ((float)Screen.height - GetHeight()) * itsDataModuleMinimap.itsAppearanceMiniMap.itsMarginHorizontal;
|
|
break;
|
|
}
|
|
switch (itsDataModuleMinimap.itsAppearanceMiniMap.itsAlignmentVertical)
|
|
{
|
|
case KGFAlignmentVertical.Top:
|
|
itsTargetRect.y = 0f;
|
|
itsTargetRect.y += ((float)Screen.height - GetHeight()) * itsDataModuleMinimap.itsAppearanceMiniMap.itsMarginVertical;
|
|
break;
|
|
case KGFAlignmentVertical.Middle:
|
|
itsTargetRect.y = ((float)Screen.height - GetHeight()) / 2f;
|
|
break;
|
|
case KGFAlignmentVertical.Bottom:
|
|
itsTargetRect.y = (float)Screen.height - GetHeight();
|
|
itsTargetRect.y -= ((float)Screen.height - GetHeight()) * itsDataModuleMinimap.itsAppearanceMiniMap.itsMarginVertical;
|
|
break;
|
|
}
|
|
}
|
|
itsTargetRect.width = GetWidth();
|
|
itsTargetRect.height = GetHeight();
|
|
}
|
|
|
|
public void RenderGUI()
|
|
{
|
|
if (itsErrorMode)
|
|
{
|
|
GUIStyle gUIStyle = new GUIStyle();
|
|
gUIStyle.alignment = TextAnchor.MiddleCenter;
|
|
gUIStyle.wordWrap = true;
|
|
gUIStyle.normal.textColor = Color.red;
|
|
GUI.Label(new Rect(0f, 0f, Screen.width, Screen.height), "Please click on the KGFMapSystem gameobject and fix all the errors displayed in the inspector.", gUIStyle);
|
|
}
|
|
else if (itsMinimapActive)
|
|
{
|
|
UpdateTargetRect();
|
|
if (!itsDataModuleMinimap.itsGlobalSettings.itsHideGUI)
|
|
{
|
|
RenderMainGUI();
|
|
}
|
|
RenderToolTip();
|
|
}
|
|
}
|
|
|
|
private void RenderMainGUI()
|
|
{
|
|
float buttonSize = GetButtonSize();
|
|
float buttonPadding = GetButtonPadding();
|
|
if (GetFullscreen())
|
|
{
|
|
itsGuiStyleBack.normal.background = itsDataModuleMinimap.itsAppearanceMap.itsBackground;
|
|
itsGuiStyleBack.border = new RectOffset(itsDataModuleMinimap.itsAppearanceMap.itsBackgroundBorder, itsDataModuleMinimap.itsAppearanceMap.itsBackgroundBorder, itsDataModuleMinimap.itsAppearanceMap.itsBackgroundBorder, itsDataModuleMinimap.itsAppearanceMap.itsBackgroundBorder);
|
|
}
|
|
else
|
|
{
|
|
itsGuiStyleBack.normal.background = itsDataModuleMinimap.itsAppearanceMiniMap.itsBackground;
|
|
itsGuiStyleBack.border = new RectOffset(itsDataModuleMinimap.itsAppearanceMiniMap.itsBackgroundBorder, itsDataModuleMinimap.itsAppearanceMiniMap.itsBackgroundBorder, itsDataModuleMinimap.itsAppearanceMiniMap.itsBackgroundBorder, itsDataModuleMinimap.itsAppearanceMiniMap.itsBackgroundBorder);
|
|
}
|
|
GUI.Box(itsTargetRect, string.Empty, itsGuiStyleBack);
|
|
if (GetFullscreen())
|
|
{
|
|
int num = (int)(itsDataModuleMinimap.itsAppearanceMap.itsButtonSpace * GetHeight());
|
|
int num2 = 4;
|
|
int num3 = (int)((float)((num2 - 1) * num) + GetButtonSize() * (float)num2);
|
|
int num4 = (int)GetButtonSize();
|
|
Rect rect = default(Rect);
|
|
switch (itsDataModuleMinimap.itsAppearanceMap.itsAlignmentHorizontal)
|
|
{
|
|
case KGFAlignmentHorizontal.Left:
|
|
rect.x = itsTargetRect.x + buttonPadding;
|
|
break;
|
|
case KGFAlignmentHorizontal.Middle:
|
|
if (itsDataModuleMinimap.itsAppearanceMap.itsOrientation == KGFOrientation.Horizontal)
|
|
{
|
|
rect.x = itsTargetRect.xMin + (itsTargetRect.xMax - itsTargetRect.xMin) / 2f - (float)(num3 / 2);
|
|
}
|
|
else
|
|
{
|
|
rect.x = itsTargetRect.xMin + (itsTargetRect.xMax - itsTargetRect.xMin) / 2f - (float)(num4 / 2);
|
|
}
|
|
break;
|
|
case KGFAlignmentHorizontal.Right:
|
|
if (itsDataModuleMinimap.itsAppearanceMap.itsOrientation == KGFOrientation.Horizontal)
|
|
{
|
|
rect.x = itsTargetRect.xMax - (float)num3 - buttonPadding;
|
|
}
|
|
else
|
|
{
|
|
rect.x = itsTargetRect.xMax - (float)num4 - buttonPadding;
|
|
}
|
|
break;
|
|
}
|
|
switch (itsDataModuleMinimap.itsAppearanceMap.itsAlignmentVertical)
|
|
{
|
|
case KGFAlignmentVertical.Top:
|
|
rect.y = itsTargetRect.y + buttonPadding;
|
|
break;
|
|
case KGFAlignmentVertical.Middle:
|
|
if (itsDataModuleMinimap.itsAppearanceMap.itsOrientation == KGFOrientation.Horizontal)
|
|
{
|
|
rect.y = itsTargetRect.yMin + (itsTargetRect.yMax - itsTargetRect.yMin) / 2f - (float)(num4 / 2);
|
|
}
|
|
else
|
|
{
|
|
rect.y = itsTargetRect.yMin + (itsTargetRect.yMax - itsTargetRect.yMin) / 2f - (float)(num3 / 2);
|
|
}
|
|
break;
|
|
case KGFAlignmentVertical.Bottom:
|
|
if (itsDataModuleMinimap.itsAppearanceMap.itsOrientation == KGFOrientation.Horizontal)
|
|
{
|
|
rect.y = itsTargetRect.yMax - (float)num4 - buttonPadding;
|
|
}
|
|
else
|
|
{
|
|
rect.y = itsTargetRect.yMax - (float)num3 - buttonPadding;
|
|
}
|
|
break;
|
|
}
|
|
rect.width = GetButtonSize();
|
|
rect.height = GetButtonSize();
|
|
itsRectZoomIn = (itsRectZoomOut = (itsRectStatic = (itsRectFullscreen = rect)));
|
|
if (itsDataModuleMinimap.itsAppearanceMap.itsOrientation == KGFOrientation.Horizontal)
|
|
{
|
|
itsRectZoomOut.x = itsRectZoomIn.x + (float)num + GetButtonSize();
|
|
itsRectStatic.x = itsRectZoomOut.x + (float)num + GetButtonSize();
|
|
itsRectFullscreen.x = itsRectStatic.x + (float)num + GetButtonSize();
|
|
}
|
|
else
|
|
{
|
|
itsRectZoomOut.y = itsRectZoomIn.y + (float)num + GetButtonSize();
|
|
itsRectStatic.y = itsRectZoomOut.y + (float)num + GetButtonSize();
|
|
itsRectFullscreen.y = itsRectStatic.y + (float)num + GetButtonSize();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
itsRectZoomIn = new Rect(itsTargetRect.x + buttonPadding, itsTargetRect.y + buttonPadding, buttonSize, buttonSize);
|
|
itsRectZoomOut = new Rect(itsTargetRect.x + buttonPadding, itsTargetRect.y + itsTargetRect.height - buttonSize - buttonPadding, buttonSize, buttonSize);
|
|
itsRectStatic = new Rect(itsTargetRect.x + itsTargetRect.width - buttonSize - buttonPadding, itsTargetRect.y + buttonPadding, buttonSize, buttonSize);
|
|
itsRectFullscreen = new Rect(itsTargetRect.x + itsTargetRect.width - buttonSize - buttonPadding, itsTargetRect.y + itsTargetRect.height - buttonSize - buttonPadding, buttonSize, buttonSize);
|
|
}
|
|
if (DrawButton(itsRectZoomIn, (!GetFullscreen()) ? itsDataModuleMinimap.itsAppearanceMiniMap.itsIconZoomIn : itsDataModuleMinimap.itsAppearanceMap.itsIconZoomIn))
|
|
{
|
|
ZoomIn();
|
|
}
|
|
if (DrawButton(itsRectZoomOut, (!GetFullscreen()) ? itsDataModuleMinimap.itsAppearanceMiniMap.itsIconZoomOut : itsDataModuleMinimap.itsAppearanceMap.itsIconZoomOut))
|
|
{
|
|
ZoomOut();
|
|
}
|
|
if (DrawButton(itsRectStatic, (!GetFullscreen()) ? itsDataModuleMinimap.itsAppearanceMiniMap.itsIconZoomLock : itsDataModuleMinimap.itsAppearanceMap.itsIconZoomLock))
|
|
{
|
|
SetModeStatic(!GetModeStatic());
|
|
}
|
|
if (DrawButton(itsRectFullscreen, (!GetFullscreen()) ? itsDataModuleMinimap.itsAppearanceMiniMap.itsIconFullscreen : itsDataModuleMinimap.itsAppearanceMap.itsIconFullscreen))
|
|
{
|
|
SetFullscreen(!GetFullscreen());
|
|
}
|
|
}
|
|
|
|
public void SetRenderToolTipMethod(RenderToolTipMethodType theMethod)
|
|
{
|
|
itsRenderToolTipMethod = theMethod;
|
|
}
|
|
|
|
public void ResetRenderToolTipMethod()
|
|
{
|
|
itsRenderToolTipMethod = null;
|
|
}
|
|
|
|
private void RenderToolTip()
|
|
{
|
|
if (GetHoverWithoutButtons() && !GetPanningMoveActive() && itsMapIconHoveredCurrent != null && itsDataModuleMinimap.itsToolTip.itsActive && itsMapIconHoveredCurrent.GetMapIconVisibilityEffective() && itsMapIconHoveredCurrent.itsMapIcon != null && itsMapIconHoveredCurrent.itsMapIcon.GetShowToolTip())
|
|
{
|
|
if (itsRenderToolTipMethod != null)
|
|
{
|
|
itsRenderToolTipMethod(itsMapIconHoveredCurrent.itsMapIcon.GetToolTipText());
|
|
}
|
|
else
|
|
{
|
|
RenderToolTipMethodDefault(itsMapIconHoveredCurrent.itsMapIcon.GetToolTipText());
|
|
}
|
|
}
|
|
}
|
|
|
|
private void RenderToolTipMethodDefault(string theText)
|
|
{
|
|
if (!string.IsNullOrEmpty(theText))
|
|
{
|
|
GUIStyle gUIStyle = new GUIStyle();
|
|
gUIStyle.normal.background = itsDataModuleMinimap.itsToolTip.itsTextureBackground;
|
|
gUIStyle.normal.textColor = itsDataModuleMinimap.itsToolTip.itsColorText;
|
|
gUIStyle.font = itsDataModuleMinimap.itsToolTip.itsFontText;
|
|
gUIStyle.border = itsDataModuleMinimap.itsToolTip.itsBackgroundBorder;
|
|
gUIStyle.padding = itsDataModuleMinimap.itsToolTip.itsBackgroundPadding;
|
|
Vector2 vector = Input.mousePosition;
|
|
Vector2 vector2 = gUIStyle.CalcSize(new GUIContent(theText)) + new Vector2(itsDataModuleMinimap.itsToolTip.itsBackgroundPadding.left + itsDataModuleMinimap.itsToolTip.itsBackgroundPadding.right, itsDataModuleMinimap.itsToolTip.itsBackgroundPadding.top + itsDataModuleMinimap.itsToolTip.itsBackgroundPadding.bottom);
|
|
GUI.Label(new Rect(vector.x - vector2.x / 2f, (float)Screen.height - vector.y + 15f, vector2.x, vector2.y), theText, gUIStyle);
|
|
}
|
|
}
|
|
|
|
private void UpdateOrthographicSize()
|
|
{
|
|
if (itsModeFullscreen)
|
|
{
|
|
itsCamera.orthographicSize = itsCurrentZoomMap;
|
|
}
|
|
else
|
|
{
|
|
itsCamera.orthographicSize = itsCurrentZoomMiniMap;
|
|
}
|
|
itsCamera.aspect = GetWidth() / GetHeight();
|
|
}
|
|
|
|
private void CorrectCurrentZoom()
|
|
{
|
|
if (itsModeFullscreen)
|
|
{
|
|
itsCurrentZoomMap = Mathf.Min(itsCurrentZoomMap, itsDataModuleMinimap.itsZoomMap.itsZoomMax);
|
|
itsCurrentZoomMap = Mathf.Max(itsCurrentZoomMap, itsDataModuleMinimap.itsZoomMap.itsZoomMin);
|
|
itsCurrentZoomDestMap = Mathf.Min(itsCurrentZoomDestMap, itsDataModuleMinimap.itsZoomMap.itsZoomMax);
|
|
itsCurrentZoomDestMap = Mathf.Max(itsCurrentZoomDestMap, itsDataModuleMinimap.itsZoomMap.itsZoomMin);
|
|
}
|
|
else
|
|
{
|
|
itsCurrentZoomMiniMap = Mathf.Min(itsCurrentZoomMiniMap, itsDataModuleMinimap.itsZoomMiniMap.itsZoomMax);
|
|
itsCurrentZoomMiniMap = Mathf.Max(itsCurrentZoomMiniMap, itsDataModuleMinimap.itsZoomMiniMap.itsZoomMin);
|
|
itsCurrentZoomDestMiniMap = Mathf.Min(itsCurrentZoomDestMiniMap, itsDataModuleMinimap.itsZoomMiniMap.itsZoomMax);
|
|
itsCurrentZoomDestMiniMap = Mathf.Max(itsCurrentZoomDestMiniMap, itsDataModuleMinimap.itsZoomMiniMap.itsZoomMin);
|
|
}
|
|
}
|
|
|
|
private void UpdateZoom()
|
|
{
|
|
if (itsModeFullscreen)
|
|
{
|
|
if (itsCurrentZoomDestMap != itsCurrentZoomMap)
|
|
{
|
|
itsCurrentZoomMap = Mathf.SmoothDamp(itsCurrentZoomMap, itsCurrentZoomDestMap, ref itsZoomChangeVelocity, 0.3f);
|
|
if (Mathf.Abs(itsCurrentZoomDestMap - itsCurrentZoomMap) < 0.05f)
|
|
{
|
|
itsCurrentZoomMap = itsCurrentZoomDestMap;
|
|
}
|
|
CorrectCurrentZoom();
|
|
UpdateOrthographicSize();
|
|
UpdateIconScale();
|
|
}
|
|
}
|
|
else if (itsCurrentZoomDestMiniMap != itsCurrentZoomMiniMap)
|
|
{
|
|
itsCurrentZoomMiniMap = Mathf.SmoothDamp(itsCurrentZoomMiniMap, itsCurrentZoomDestMiniMap, ref itsZoomChangeVelocity, 0.3f);
|
|
if (Mathf.Abs(itsCurrentZoomDestMiniMap - itsCurrentZoomMiniMap) < 0.05f)
|
|
{
|
|
itsCurrentZoomMiniMap = itsCurrentZoomDestMiniMap;
|
|
}
|
|
CorrectCurrentZoom();
|
|
UpdateOrthographicSize();
|
|
UpdateIconScale();
|
|
}
|
|
}
|
|
|
|
public override string GetName()
|
|
{
|
|
return base.name;
|
|
}
|
|
|
|
public string GetHeaderName()
|
|
{
|
|
return base.name;
|
|
}
|
|
|
|
public override Texture2D GetIcon()
|
|
{
|
|
return (Texture2D)Resources.Load("KGFMapSystem/textures/mapsystem_small", typeof(Texture2D));
|
|
}
|
|
|
|
private string[] GetNamesFromLayerMask(LayerMask theLayers)
|
|
{
|
|
List<string> list = new List<string>();
|
|
for (int i = 0; i < 32; i++)
|
|
{
|
|
if (((int)theLayers & (1 << i)) != 0)
|
|
{
|
|
string text = LayerMask.LayerToName(i);
|
|
if (text.Trim() != string.Empty)
|
|
{
|
|
list.Add(text);
|
|
}
|
|
}
|
|
}
|
|
return list.ToArray();
|
|
}
|
|
|
|
private void DrawCustomGuiMain()
|
|
{
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("itsTarget");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsGlobalSettings.itsTarget.gameObject.GetObjectPath());
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("itsStaticNorth");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsGlobalSettings.itsStaticNorth);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxBottom);
|
|
KGFGUIUtility.Label("Enabled");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsGlobalSettings.itsIsActive);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
}
|
|
|
|
private void DrawCustomGuiAppearanceMinimap()
|
|
{
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("itsSize");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsAppearanceMiniMap.itsSize);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("itsButtonSize");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsAppearanceMiniMap.itsButtonSize);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("itsButtonPadding");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsAppearanceMiniMap.itsButtonPadding);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("itsScaleIcons");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsAppearanceMiniMap.itsScaleIcons);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("itsScaleArrows");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsAppearanceMiniMap.itsScaleArrows);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxBottom);
|
|
KGFGUIUtility.Label("itsRadiusArrows");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsAppearanceMiniMap.itsRadiusArrows);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
}
|
|
|
|
private void DrawCustomGuiAppearanceMap()
|
|
{
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("itsButtonSize");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsAppearanceMap.itsButtonSize);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("itsButtonPadding");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsAppearanceMap.itsButtonPadding);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("itsButtonSpace");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsAppearanceMap.itsButtonSpace);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxBottom);
|
|
KGFGUIUtility.Label("itsScaleIcons");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsAppearanceMap.itsScaleIcons);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
}
|
|
|
|
private void DrawCustomGuiFogOfWar()
|
|
{
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("Enabled");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsFogOfWar.itsActive);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("itsResolutionX");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsFogOfWar.itsResolutionX);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("itsResolutionY");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsFogOfWar.itsResolutionY);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("itsRevealDistance");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsFogOfWar.itsRevealDistance);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("itsRevealedFullDistance");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsFogOfWar.itsRevealedFullDistance);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxBottom);
|
|
KGFGUIUtility.Label("Revealed");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Format("{0:0.00}%", GetRevealedPercent() * 100f));
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
}
|
|
|
|
private void DrawCustomGuiZoom()
|
|
{
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("Current zoom");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsCurrentZoomMiniMap);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("itsZoomStartValue");
|
|
GUILayout.FlexibleSpace();
|
|
if (itsModeFullscreen)
|
|
{
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsZoomMap.itsZoomStartValue);
|
|
}
|
|
else
|
|
{
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsZoomMiniMap.itsZoomStartValue);
|
|
}
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("itsZoomMin");
|
|
GUILayout.FlexibleSpace();
|
|
if (itsModeFullscreen)
|
|
{
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsZoomMap.itsZoomMin);
|
|
}
|
|
else
|
|
{
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsZoomMiniMap.itsZoomMin);
|
|
}
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("itsZoomMax");
|
|
GUILayout.FlexibleSpace();
|
|
if (itsModeFullscreen)
|
|
{
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsZoomMap.itsZoomMax);
|
|
}
|
|
else
|
|
{
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsZoomMiniMap.itsZoomMax);
|
|
}
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxBottom);
|
|
KGFGUIUtility.Label("itsZoomChangeValue");
|
|
GUILayout.FlexibleSpace();
|
|
if (itsModeFullscreen)
|
|
{
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsZoomMap.itsZoomChangeValue);
|
|
}
|
|
else
|
|
{
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsZoomMiniMap.itsZoomChangeValue);
|
|
}
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
}
|
|
|
|
private void DrawCustomGuiViewport()
|
|
{
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("Enabled");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsViewport.itsActive);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxBottom);
|
|
KGFGUIUtility.Label("itsCamera");
|
|
GUILayout.FlexibleSpace();
|
|
if (itsDataModuleMinimap.itsViewport.itsCamera != null)
|
|
{
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsViewport.itsCamera.gameObject.GetObjectPath());
|
|
}
|
|
else
|
|
{
|
|
KGFGUIUtility.Label("NONE");
|
|
}
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
}
|
|
|
|
private void DrawCustomGuiPhoto()
|
|
{
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("Enabled");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsPhoto.itsTakePhoto);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxBottom);
|
|
KGFGUIUtility.Label("itsPhotoLayers");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxInvisible);
|
|
string[] namesFromLayerMask = GetNamesFromLayerMask(itsDataModuleMinimap.itsPhoto.itsPhotoLayers);
|
|
foreach (string text in namesFromLayerMask)
|
|
{
|
|
GUILayout.Label(text);
|
|
}
|
|
KGFGUIUtility.EndVerticalBox();
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
}
|
|
|
|
private void DrawCustomGuiMapIcons()
|
|
{
|
|
int num = 0;
|
|
Dictionary<string, int> dictionary = new Dictionary<string, int>();
|
|
foreach (mapicon_listitem_script itsListMapIcon in itsListMapIcons)
|
|
{
|
|
if (itsListMapIcon.GetMapIconVisibilityEffective())
|
|
{
|
|
num++;
|
|
}
|
|
if (!dictionary.ContainsKey(itsListMapIcon.itsMapIcon.GetCategory()))
|
|
{
|
|
dictionary[itsListMapIcon.itsMapIcon.GetCategory()] = 1;
|
|
}
|
|
else
|
|
{
|
|
dictionary[itsListMapIcon.itsMapIcon.GetCategory()]++;
|
|
}
|
|
}
|
|
KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBox);
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("Icons");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsListMapIcons.Count);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("Icons visible");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + num);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("Icons by category");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxBottom);
|
|
KGFGUIUtility.Space();
|
|
KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBox);
|
|
int num2 = 0;
|
|
foreach (KeyValuePair<string, int> item in dictionary)
|
|
{
|
|
if (num2 == 0)
|
|
{
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxTop);
|
|
}
|
|
else if (num2 == dictionary.Count - 1)
|
|
{
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxBottom);
|
|
}
|
|
else
|
|
{
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
}
|
|
KGFGUIUtility.Label(string.Format("'{0}'", item.Key));
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + item.Value);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
num2++;
|
|
}
|
|
KGFGUIUtility.EndVerticalBox();
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.EndVerticalBox();
|
|
}
|
|
|
|
private void DrawCustomGuiUserFlags()
|
|
{
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("Enabled");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsUserFlags.itsActive);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxMiddleVertical);
|
|
KGFGUIUtility.Label("itsMapIcon");
|
|
GUILayout.FlexibleSpace();
|
|
if (itsDataModuleMinimap.itsUserFlags.itsMapIcon != null)
|
|
{
|
|
KGFGUIUtility.Label(string.Empty + itsDataModuleMinimap.itsUserFlags.itsMapIcon.gameObject.GetObjectPath());
|
|
}
|
|
else
|
|
{
|
|
KGFGUIUtility.Label("NONE");
|
|
}
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxBottom);
|
|
KGFGUIUtility.Label("Flag count");
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.Label(string.Empty + GetUserFlags().Length);
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
}
|
|
|
|
public void Render()
|
|
{
|
|
itsCustomGuiPosition = KGFGUIUtility.BeginScrollView(itsCustomGuiPosition, false, false);
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxInvisible);
|
|
KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxInvisible);
|
|
KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated);
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkTop);
|
|
KGFGUIUtility.Label("Main", GetIcon(), KGFGUIUtility.eStyleLabel.eLabelFitIntoBox);
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
DrawCustomGuiMain();
|
|
KGFGUIUtility.EndVerticalBox();
|
|
KGFGUIUtility.Space();
|
|
KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated);
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkTop);
|
|
KGFGUIUtility.Label("Appearance Minimap", GetIcon(), KGFGUIUtility.eStyleLabel.eLabelFitIntoBox);
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
DrawCustomGuiAppearanceMinimap();
|
|
KGFGUIUtility.EndVerticalBox();
|
|
KGFGUIUtility.Space();
|
|
KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated);
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkTop);
|
|
KGFGUIUtility.Label("Appearance Map", GetIcon(), KGFGUIUtility.eStyleLabel.eLabelFitIntoBox);
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
DrawCustomGuiAppearanceMap();
|
|
KGFGUIUtility.EndVerticalBox();
|
|
KGFGUIUtility.Space();
|
|
KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated);
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkTop);
|
|
KGFGUIUtility.Label("Fog of war", GetIcon(), KGFGUIUtility.eStyleLabel.eLabelFitIntoBox);
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
DrawCustomGuiFogOfWar();
|
|
KGFGUIUtility.EndVerticalBox();
|
|
KGFGUIUtility.Space();
|
|
KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated);
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkTop);
|
|
KGFGUIUtility.Label("Zoom", GetIcon(), KGFGUIUtility.eStyleLabel.eLabelFitIntoBox);
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
DrawCustomGuiZoom();
|
|
KGFGUIUtility.EndVerticalBox();
|
|
KGFGUIUtility.EndVerticalBox();
|
|
KGFGUIUtility.Space();
|
|
KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxInvisible);
|
|
KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated);
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkTop);
|
|
KGFGUIUtility.Label("Viewport", GetIcon(), KGFGUIUtility.eStyleLabel.eLabelFitIntoBox);
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
DrawCustomGuiViewport();
|
|
KGFGUIUtility.EndVerticalBox();
|
|
KGFGUIUtility.Space();
|
|
KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated);
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkTop);
|
|
KGFGUIUtility.Label("Photo", GetIcon(), KGFGUIUtility.eStyleLabel.eLabelFitIntoBox);
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
DrawCustomGuiPhoto();
|
|
KGFGUIUtility.EndVerticalBox();
|
|
KGFGUIUtility.Space();
|
|
KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated);
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkTop);
|
|
KGFGUIUtility.Label("Map Icons", GetIcon(), KGFGUIUtility.eStyleLabel.eLabelFitIntoBox);
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
DrawCustomGuiMapIcons();
|
|
KGFGUIUtility.EndVerticalBox();
|
|
KGFGUIUtility.Space();
|
|
KGFGUIUtility.BeginVerticalBox(KGFGUIUtility.eStyleBox.eBoxDecorated);
|
|
KGFGUIUtility.BeginHorizontalBox(KGFGUIUtility.eStyleBox.eBoxDarkTop);
|
|
KGFGUIUtility.Label("User flags", GetIcon(), KGFGUIUtility.eStyleLabel.eLabelFitIntoBox);
|
|
GUILayout.FlexibleSpace();
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
DrawCustomGuiUserFlags();
|
|
KGFGUIUtility.EndVerticalBox();
|
|
KGFGUIUtility.EndVerticalBox();
|
|
KGFGUIUtility.EndHorizontalBox();
|
|
KGFGUIUtility.EndScrollView();
|
|
}
|
|
|
|
private void NullError(ref KGFMessageList theMessageList, string theName, object theValue)
|
|
{
|
|
if (theValue == null)
|
|
{
|
|
theMessageList.AddError(string.Format("value of '{0}' must not be null", theName));
|
|
}
|
|
}
|
|
|
|
private void RegionError(ref KGFMessageList theMessageList, string theName, float theValue, float theMin, float theMax)
|
|
{
|
|
if (theValue < theMin || theValue > theMax)
|
|
{
|
|
theMessageList.AddError(string.Format("Value has to be between {0} and {1} ({2})", theMin, theMax, theName));
|
|
}
|
|
}
|
|
|
|
private void PositiveError(ref KGFMessageList theMessageList, string theName, float theValue)
|
|
{
|
|
if (theValue < 0f)
|
|
{
|
|
theMessageList.AddError(string.Format("{0} must be positive", theName));
|
|
}
|
|
}
|
|
|
|
public override KGFMessageList Validate()
|
|
{
|
|
KGFMessageList theMessageList = new KGFMessageList();
|
|
RegionError(ref theMessageList, "itsDataModuleMinimap.itsStaticNorth", itsDataModuleMinimap.itsGlobalSettings.itsStaticNorth, 0f, 360f);
|
|
if (itsDataModuleMinimap.itsGlobalSettings.itsTarget == null)
|
|
{
|
|
theMessageList.AddError("itsTarget must not be null. Please add a target that is always centered on the minimap (e.g.: the character).");
|
|
}
|
|
if (itsDataModuleMinimap.itsAppearanceMiniMap.itsMask != null && !GetHasProVersion())
|
|
{
|
|
theMessageList.AddWarning("Masking texture does only work in Unity Pro version. (itsAppearanceMiniMap.itsMask)");
|
|
}
|
|
RegionError(ref theMessageList, "itsAppearanceMiniMap.itsSize", itsDataModuleMinimap.itsAppearanceMiniMap.itsSize, 0f, 1f);
|
|
RegionError(ref theMessageList, "itsAppearanceMiniMap.itsButtonSize", itsDataModuleMinimap.itsAppearanceMiniMap.itsButtonSize, 0f, 1f);
|
|
RegionError(ref theMessageList, "itsAppearanceMiniMap.itsButtonPadding", itsDataModuleMinimap.itsAppearanceMiniMap.itsButtonPadding, 0f, 1f);
|
|
RegionError(ref theMessageList, "itsAppearanceMiniMap.itsScaleArrows", itsDataModuleMinimap.itsAppearanceMiniMap.itsScaleArrows, 0f, 1f);
|
|
RegionError(ref theMessageList, "itsAppearanceMiniMap.itsScaleIcons", itsDataModuleMinimap.itsAppearanceMiniMap.itsScaleIcons, 0f, 1f);
|
|
RegionError(ref theMessageList, "itsAppearanceMiniMap.itsRadiusArrows", itsDataModuleMinimap.itsAppearanceMiniMap.itsRadiusArrows, 0f, 1f);
|
|
PositiveError(ref theMessageList, "itsAppearanceMiniMap.itsBackgroundBorder", itsDataModuleMinimap.itsAppearanceMiniMap.itsBackgroundBorder);
|
|
if (itsDataModuleMinimap.itsAppearanceMiniMap.itsBackground == null)
|
|
{
|
|
theMessageList.AddWarning("Appearance texture should be set (itsAppearance.itsBackground)");
|
|
}
|
|
if (itsDataModuleMinimap.itsAppearanceMiniMap.itsButton == null)
|
|
{
|
|
theMessageList.AddWarning("Appearance texture should be set (itsAppearance.itsButton)");
|
|
}
|
|
if (itsDataModuleMinimap.itsAppearanceMiniMap.itsButtonDown == null)
|
|
{
|
|
theMessageList.AddWarning("Appearance texture should be set (itsAppearance.itsButtonDown)");
|
|
}
|
|
if (itsDataModuleMinimap.itsAppearanceMiniMap.itsButtonHover == null)
|
|
{
|
|
theMessageList.AddWarning("Appearance texture should be set (itsAppearance.itsButtonHover)");
|
|
}
|
|
if (itsDataModuleMinimap.itsAppearanceMiniMap.itsIconZoomIn == null)
|
|
{
|
|
theMessageList.AddWarning("Appearance texture should be set (itsAppearance.itsIconZoomIn)");
|
|
}
|
|
if (itsDataModuleMinimap.itsAppearanceMiniMap.itsIconZoomOut == null)
|
|
{
|
|
theMessageList.AddWarning("Appearance texture should be set (itsAppearance.itsIconZoomOut)");
|
|
}
|
|
if (itsDataModuleMinimap.itsAppearanceMiniMap.itsIconZoomLock == null)
|
|
{
|
|
theMessageList.AddWarning("Appearance texture should be set (itsAppearance.itsIconZoomLock)");
|
|
}
|
|
if (itsDataModuleMinimap.itsAppearanceMiniMap.itsIconFullscreen == null)
|
|
{
|
|
theMessageList.AddWarning("Appearance texture should be set (itsAppearance.itsIconFullscreen)");
|
|
}
|
|
RegionError(ref theMessageList, "itsAppearanceMap.itsButtonSize", itsDataModuleMinimap.itsAppearanceMap.itsButtonSize, 0f, 1f);
|
|
RegionError(ref theMessageList, "itsAppearanceMap.itsButtonPadding", itsDataModuleMinimap.itsAppearanceMap.itsButtonPadding, 0f, 1f);
|
|
RegionError(ref theMessageList, "itsAppearanceMap.itsButtonSpace", itsDataModuleMinimap.itsAppearanceMap.itsButtonSpace, 0f, 1f);
|
|
RegionError(ref theMessageList, "itsAppearanceMap.itsScaleIcons", itsDataModuleMinimap.itsAppearanceMap.itsScaleIcons, 0f, 1f);
|
|
PositiveError(ref theMessageList, "itsAppearanceMap.itsBackgroundBorder", itsDataModuleMinimap.itsAppearanceMap.itsBackgroundBorder);
|
|
if (itsDataModuleMinimap.itsGlobalSettings.itsColorAll != Color.white && !GetHasProVersion())
|
|
{
|
|
theMessageList.AddError("itsColorAll does only work in Unity Pro version. (itsColorAll)");
|
|
}
|
|
if (itsDataModuleMinimap.itsAppearanceMap.itsMask != null && !GetHasProVersion())
|
|
{
|
|
theMessageList.AddWarning("Masking texture does only work in Unity Pro version. (itsAppearanceMap.itsMask)");
|
|
}
|
|
if (itsDataModuleMinimap.itsAppearanceMap.itsButton == null)
|
|
{
|
|
theMessageList.AddWarning("Appearance texture should be set (itsAppearanceMap.itsButton)");
|
|
}
|
|
if (itsDataModuleMinimap.itsAppearanceMap.itsButtonDown == null)
|
|
{
|
|
theMessageList.AddWarning("Appearance texture should be set (itsAppearanceMap.itsButtonDown)");
|
|
}
|
|
if (itsDataModuleMinimap.itsAppearanceMap.itsButtonHover == null)
|
|
{
|
|
theMessageList.AddWarning("Appearance texture should be set (itsAppearanceMap.itsButtonHover)");
|
|
}
|
|
if (itsDataModuleMinimap.itsAppearanceMap.itsIconZoomIn == null)
|
|
{
|
|
theMessageList.AddWarning("Appearance texture should be set (itsAppearanceMap.itsIconZoomIn)");
|
|
}
|
|
if (itsDataModuleMinimap.itsAppearanceMap.itsIconZoomOut == null)
|
|
{
|
|
theMessageList.AddWarning("Appearance texture should be set (itsAppearanceMap.itsIconZoomOut)");
|
|
}
|
|
if (itsDataModuleMinimap.itsAppearanceMap.itsIconZoomLock == null)
|
|
{
|
|
theMessageList.AddWarning("Appearance texture should be set (itsAppearanceMap.itsIconZoomLock)");
|
|
}
|
|
if (itsDataModuleMinimap.itsAppearanceMap.itsIconFullscreen == null)
|
|
{
|
|
theMessageList.AddWarning("Appearance texture should be set (itsAppearanceMap.itsIconFullscreen)");
|
|
}
|
|
PositiveError(ref theMessageList, "itsFogOfWar.itsResolutionX", itsDataModuleMinimap.itsFogOfWar.itsResolutionX);
|
|
PositiveError(ref theMessageList, "itsFogOfWar.itsResolutionY", itsDataModuleMinimap.itsFogOfWar.itsResolutionY);
|
|
PositiveError(ref theMessageList, "itsFogOfWar.itsRevealDistance", itsDataModuleMinimap.itsFogOfWar.itsRevealDistance);
|
|
PositiveError(ref theMessageList, "itsFogOfWar.itsRevealedFullDistance", itsDataModuleMinimap.itsFogOfWar.itsRevealedFullDistance);
|
|
if (itsDataModuleMinimap.itsFogOfWar.itsRevealedFullDistance > itsDataModuleMinimap.itsFogOfWar.itsRevealDistance)
|
|
{
|
|
theMessageList.AddError("itsFogOfWar.itsRevealDistance must be bigger than itsFogOfWar.itsRevealedFullDistance");
|
|
}
|
|
PositiveError(ref theMessageList, "itsZoomMiniMap.itsZoomChangeValue", itsDataModuleMinimap.itsZoomMiniMap.itsZoomChangeValue);
|
|
PositiveError(ref theMessageList, "itsZoomMiniMap.itsZoomMax", itsDataModuleMinimap.itsZoomMiniMap.itsZoomMax);
|
|
PositiveError(ref theMessageList, "itsZoomMiniMap.itsZoomMin", itsDataModuleMinimap.itsZoomMiniMap.itsZoomMin);
|
|
PositiveError(ref theMessageList, "itsZoomMiniMap.itsZoomStartValue", itsDataModuleMinimap.itsZoomMiniMap.itsZoomStartValue);
|
|
if (itsDataModuleMinimap.itsZoomMiniMap.itsZoomMin > itsDataModuleMinimap.itsZoomMiniMap.itsZoomMax)
|
|
{
|
|
theMessageList.AddError("itsZoomMiniMap.itsZoomMax must be bigger than itsZoomMiniMap.itsZoomMin");
|
|
}
|
|
if (itsDataModuleMinimap.itsZoomMiniMap.itsZoomStartValue < itsDataModuleMinimap.itsZoomMiniMap.itsZoomMin || itsDataModuleMinimap.itsZoomMiniMap.itsZoomStartValue > itsDataModuleMinimap.itsZoomMiniMap.itsZoomMax)
|
|
{
|
|
theMessageList.AddError("itsZoomMiniMap.itsZoomStartValue has to be between itsZoomMiniMap.itsZoomMin and itsZoomMiniMap.itsZoomMin");
|
|
}
|
|
PositiveError(ref theMessageList, "itsZoomMap.itsZoomChangeValue", itsDataModuleMinimap.itsZoomMap.itsZoomChangeValue);
|
|
PositiveError(ref theMessageList, "itsZoomMap.itsZoomMax", itsDataModuleMinimap.itsZoomMap.itsZoomMax);
|
|
PositiveError(ref theMessageList, "itsZoomMap.itsZoomMin", itsDataModuleMinimap.itsZoomMap.itsZoomMin);
|
|
PositiveError(ref theMessageList, "itsZoomMap.itsZoomStartValue", itsDataModuleMinimap.itsZoomMap.itsZoomStartValue);
|
|
if (itsDataModuleMinimap.itsZoomMap.itsZoomMin > itsDataModuleMinimap.itsZoomMap.itsZoomMax)
|
|
{
|
|
theMessageList.AddError("itsZoomMap.itsZoomMax must be bigger than itsZoomMap.itsZoomMin");
|
|
}
|
|
if (itsDataModuleMinimap.itsZoomMap.itsZoomStartValue < itsDataModuleMinimap.itsZoomMap.itsZoomMin || itsDataModuleMinimap.itsZoomMap.itsZoomStartValue > itsDataModuleMinimap.itsZoomMap.itsZoomMax)
|
|
{
|
|
theMessageList.AddError("itsZoomMap.itsZoomStartValue has to be between itsZoomMap.itsZoomMin and itsZoomMap.itsZoomMin");
|
|
}
|
|
if (itsDataModuleMinimap.itsViewport.itsActive && itsDataModuleMinimap.itsViewport.itsCamera == null)
|
|
{
|
|
theMessageList.AddError("Active viewport needs a camera (itsViewport.itsCamera)");
|
|
}
|
|
if (itsDataModuleMinimap.itsViewport.itsActive && itsDataModuleMinimap.itsGlobalSettings.itsOrientation == KGFMapSystemOrientation.XYSideScroller)
|
|
{
|
|
theMessageList.AddError("Viewport display is not supported in SideScroller mode (itsViewport.itsCamera)");
|
|
}
|
|
if (itsDataModuleMinimap.itsViewport.itsColor.a == 0f)
|
|
{
|
|
theMessageList.AddError("Viewport will be invisible if itsColor.a == 0");
|
|
}
|
|
if (itsDataModuleMinimap.itsPhoto.itsTakePhoto && (int)itsDataModuleMinimap.itsPhoto.itsPhotoLayers == 0)
|
|
{
|
|
theMessageList.AddError("itsPhoto.itsPhotoLayers has to contain some layers for the photo not to be empty");
|
|
}
|
|
if (itsDataModuleMinimap.itsUserFlags.itsActive)
|
|
{
|
|
}
|
|
if (LayerMask.NameToLayer("mapsystem") < 0)
|
|
{
|
|
theMessageList.AddError(string.Format("The map system needs a layer with the name '{0}'", "mapsystem"));
|
|
}
|
|
if (itsDataModuleMinimap.itsPanning.itsActive && itsDataModuleMinimap.itsPanning.itsUseBounds && (int)itsDataModuleMinimap.itsPanning.itsBoundsLayers == 0)
|
|
{
|
|
theMessageList.AddError("itsPanning.itsBoundsLayers has to contain some layers for the panning bounds to work");
|
|
}
|
|
if (itsDataModuleMinimap.itsShaders.itsShaderMapIcon == null)
|
|
{
|
|
theMessageList.AddError(string.Format("itsDataModuleMinimap.itsShaders.itsShaderMapIcon is null"));
|
|
}
|
|
if (itsDataModuleMinimap.itsShaders.itsShaderPhotoPlane == null)
|
|
{
|
|
theMessageList.AddError(string.Format("itsDataModuleMinimap.itsShaders.itsShaderPhotoPlane is null"));
|
|
}
|
|
if (itsDataModuleMinimap.itsShaders.itsShaderMapMask == null)
|
|
{
|
|
theMessageList.AddError(string.Format("itsDataModuleMinimap.itsShaders.itsShaderMapMask is null"));
|
|
}
|
|
if (itsDataModuleMinimap.itsFogOfWar.itsActive && itsDataModuleMinimap.itsShaders.itsShaderFogOfWar == null)
|
|
{
|
|
theMessageList.AddWarning(string.Format("itsDataModuleMinimap.itsShaders.itsShaderFogOfWar is null, fog of war will not work"));
|
|
}
|
|
return theMessageList;
|
|
}
|
|
|
|
public override string GetForumPath()
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
public override string GetDocumentationPath()
|
|
{
|
|
return string.Empty;
|
|
}
|
|
}
|