From ea8e6a79f179b92fcdb2fc9c96176d5e74910dc8 Mon Sep 17 00:00:00 2001 From: Le Duc Anh Date: Thu, 29 Jan 2026 19:25:53 +0700 Subject: [PATCH] update mini map --- Assets/PerfectWorld/Prefab/UI/MiniMap.prefab | 38 ++++++++++++------- .../Scripts/UI/MiniMap/MiniMapUI.cs | 26 +++++++------ 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/Assets/PerfectWorld/Prefab/UI/MiniMap.prefab b/Assets/PerfectWorld/Prefab/UI/MiniMap.prefab index 4897a12dc7..ea62888b08 100644 --- a/Assets/PerfectWorld/Prefab/UI/MiniMap.prefab +++ b/Assets/PerfectWorld/Prefab/UI/MiniMap.prefab @@ -149,7 +149,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -115.97, y: 0} + m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &2662512916839275454 @@ -217,7 +217,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_Sprite: {fileID: 21300000, guid: e59d8ae2ed61a41b2a0437eddcb12c6e, type: 3} + m_Sprite: {fileID: 0} m_Type: 0 m_PreserveAspect: 0 m_FillCenter: 1 @@ -276,6 +276,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: dbb3be46f1d07224f90ade7b25776f34, type: 3} m_Name: m_EditorClassIdentifier: + _debugHostPlayerPos: {x: 902, y: 138, z: 208} _hostPlayerIcon: {fileID: 7794785241219751657} m_pA3DRadarBack: {fileID: 0} m_TexRadarBack: {fileID: 0} @@ -285,10 +286,21 @@ MonoBehaviour: pObjMiniMap: {fileID: 0} txtHostPos: {fileID: 4181830183982007782} m_TexMapParts: - - {fileID: 2800000, guid: 5a6dea9f8398a4fdbb65d7a36cff969d, type: 3} - - {fileID: 2800000, guid: e59d8ae2ed61a41b2a0437eddcb12c6e, type: 3} - - {fileID: 2800000, guid: 808bf4a367f33454ebcd807e4bf76a80, type: 3} - - {fileID: 2800000, guid: fef5a1848cea846c8b6e7a6ae91702da, type: 3} + - {fileID: 2800000, guid: 301ade9e872ca41b0af566abb2e46390, type: 3} + - {fileID: 2800000, guid: 329687e46624c4870a94f793afc501f2, type: 3} + - {fileID: 2800000, guid: 11f2157d89d3e4a668de99650da0956d, type: 3} + - {fileID: 2800000, guid: f2730c9ec0a84498a8c46129a3c94805, type: 3} + m_SpriteMapParts: + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + m_ImageMapParts: + - {fileID: 3845363629262670326} + - {fileID: 6391300263649697801} + - {fileID: 832989083214924840} + - {fileID: 1862429896836666507} + _spriteAtlas: {fileID: 100100200, guid: b764c7c6d08a20e41a8ebfb3435954db, type: 3} --- !u!1 &5439706710607590680 GameObject: m_ObjectHideFlags: 0 @@ -354,7 +366,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_Sprite: {fileID: 21300000, guid: 808bf4a367f33454ebcd807e4bf76a80, type: 3} + m_Sprite: {fileID: 0} m_Type: 0 m_PreserveAspect: 0 m_FillCenter: 1 @@ -490,7 +502,7 @@ MonoBehaviour: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 6204794853470406477} - m_Enabled: 1 + m_Enabled: 0 m_EditorHideFlags: 0 m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} m_Name: @@ -663,7 +675,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_text: 375, -17 + m_text: 490, 570, 13 m_isRightToLeft: 0 m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} @@ -799,7 +811,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_Sprite: {fileID: 21300000, guid: 5a6dea9f8398a4fdbb65d7a36cff969d, type: 3} + m_Sprite: {fileID: 0} m_Type: 0 m_PreserveAspect: 0 m_FillCenter: 1 @@ -843,8 +855,8 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: -25.9, y: -1.7} - m_SizeDelta: {x: 16, y: 16} + m_AnchoredPosition: {x: 141, y: 72} + m_SizeDelta: {x: 8, y: 8} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &1911266972102470756 CanvasRenderer: @@ -946,7 +958,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_Sprite: {fileID: 21300000, guid: fef5a1848cea846c8b6e7a6ae91702da, type: 3} + m_Sprite: {fileID: 0} m_Type: 0 m_PreserveAspect: 0 m_FillCenter: 1 diff --git a/Assets/PerfectWorld/Scripts/UI/MiniMap/MiniMapUI.cs b/Assets/PerfectWorld/Scripts/UI/MiniMap/MiniMapUI.cs index a23ff662d2..77cf415bef 100644 --- a/Assets/PerfectWorld/Scripts/UI/MiniMap/MiniMapUI.cs +++ b/Assets/PerfectWorld/Scripts/UI/MiniMap/MiniMapUI.cs @@ -41,23 +41,26 @@ namespace PerfectWorld.UI.MiniMap private const int MINIMAP_LL = 2; private const int MINIMAP_LR = 3; private const int MINIMAP_MAX = 4; + + [SerializeField] private Vector3 _debugHostPlayerPos; [SerializeField] private RectTransform _hostPlayerIcon; - [SerializeField] private Texture2D m_pA3DRadarBack; - [SerializeField] private Texture2D m_TexRadarBack; + [SerializeField] private Sprite m_pA3DRadarBack; + [SerializeField] private Sprite m_TexRadarBack; [SerializeField] private byte nRow, nCol; // number of rows and cols in the current map instances.txt [SerializeField] private string strSubPath; // path to the minimap textures folder "surfaces/minimaps/a61/{0}" [SerializeField] private RectTransform pObjMiniMap; [SerializeField] private TMP_Text txtHostPos; [SerializeField] private Texture2D[] m_TexMapParts = new Texture2D[MINIMAP_MAX]; [SerializeField] private Sprite[] m_SpriteMapParts = new Sprite[MINIMAP_MAX]; + [SerializeField] private Image[] m_ImageMapParts = new Image[MINIMAP_MAX]; // reference to unity sprite atlas [SerializeField] private SpriteAtlas _spriteAtlas; private List m_vecMark = new(); private List m_vecNPCMark = new(); - private Dictionary m_TexMap = new(); + private Dictionary m_TexMap = new(); private List _texToDelete = new(); // list of texture to delete from m_TexMap, use in update functions. private float m_fZoom = 1.0f; private bool m_bShowMark = true; @@ -89,8 +92,8 @@ namespace PerfectWorld.UI.MiniMap // if (m_pHostPlayer == null) return; // TODO: This should be the position of the host player, not hardcoded. - Vector3 vecPosHost = new Vector3(-259.4484f, 52.00275f, -17.2688f);//m_pHostPlayer.transform.position; - txtHostPos.text = $"{Mathf.RoundToInt(vecPosHost.x) / 10 + 400}, {Mathf.RoundToInt(vecPosHost.z)}"; + Vector3 vecPosHost = _debugHostPlayerPos;//m_pHostPlayer.transform.position; + txtHostPos.text = $"{Mathf.RoundToInt(vecPosHost.x) / 10 + 400}, {Mathf.RoundToInt(vecPosHost.z) / 10 + 550}, {Mathf.RoundToInt(vecPosHost.y) / 10}"; float fRatio = 512.0f / 1024.0f / m_fZoom; float fNormal = fRatio; @@ -101,7 +104,7 @@ namespace PerfectWorld.UI.MiniMap vecPosHost.z = Mathf.Floor(vecPosHost.z * fNormal) / fNormal; // TODO: This should be the size of the minimap texture, not hardcoded. - Rect rcMiniMap = new Rect(0, 0, 256, 256);//pObjMiniMap.rect; + Rect rcMiniMap = new Rect(0, 0, 119, 119);//pObjMiniMap.rect; //ASSERT(rcMiniMap.Width() == rcMiniMap.Height()); int W = (int)rcMiniMap.width; int H = (int)rcMiniMap.height; @@ -203,7 +206,6 @@ namespace PerfectWorld.UI.MiniMap //*/ string strIndex = string.Empty; bool bLoadNewMap = false; - Texture2D pA3DTex = m_TexRadarBack; Sprite pSprite = null; for( i = MINIMAP_UL; i < MINIMAP_MAX; i++ ) { @@ -247,13 +249,13 @@ namespace PerfectWorld.UI.MiniMap // else // { strFile = string.Format(strSubPath, strIndex); //"Surfaces\\MiniMaps\\" + strSubPath + "\\" + strIndex + ".dds"; - pA3DTex = Resources.Load(strFile); pSprite = _spriteAtlas.GetSprite(strIndex); // } } - m_TexMap[strIndex] = pA3DTex; - m_TexMapParts[i] = pA3DTex; + m_TexMap[strIndex] = pSprite; + m_SpriteMapParts[i] = pSprite; + m_ImageMapParts[i].sprite = pSprite; bLoadNewMap = true; } } @@ -329,13 +331,13 @@ namespace PerfectWorld.UI.MiniMap m_vertexMiniMap[3][3].x = +W / 2.0f; m_vertexMiniMap[3][3].y = +H / 2.0f; - pA3DTex = m_TexRadarBack; + pSprite = m_TexRadarBack; ushort[] a_wIndex = new ushort[6] { 0, 1, 2, 2, 1, 3 }; A3DVECTOR3 vecPos = new A3DVECTOR3(0); for (i = 0; i < MINIMAP_MAX; i++) { strIndex = string.Format("{0:D2}{1:D2}", idxCorner[i].y, idxCorner[i].x); - pA3DTex = m_TexMap[strIndex]; + pSprite = m_TexMap[strIndex]; // m_vertexMiniMap[i][0].tu = float(rcInter[i].left - rcCell[i].left) / fSide; // m_vertexMiniMap[i][0].tv = float(rcInter[i].top - rcCell[i].top) / fSide;