MapMaker2.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  1. using UnityEngine;
  2. using System.Collections.Generic;
  3. public class MapMaker2 : MonoBehaviour
  4. {
  5. [Header("Map Settings")]
  6. public int initialMapSize = 150;
  7. public int expansionSize = 50;
  8. public float playerDistanceThreshold = 20f;
  9. [Header("Simple Mode")]
  10. [Tooltip("Use simple static map generation (no exploration/expansion)")]
  11. public bool useSimpleMode = true;
  12. [Header("Exploration Settings")]
  13. [Tooltip("Use exploration system instead of expansion")]
  14. public bool useExplorationSystem = true;
  15. public void SetMapData(MapData newMapData)
  16. {
  17. mapData = newMapData;
  18. // Update the visualization
  19. if (mapVisualizer != null)
  20. {
  21. mapVisualizer.VisualizeMap(mapData);
  22. }
  23. else
  24. {
  25. Debug.LogWarning("⚠️ MapVisualizer is null, cannot update visualization");
  26. }
  27. }
  28. public MapData GetMapData()
  29. {
  30. return mapData;
  31. }
  32. [Header("Exploration Settings")]
  33. public int explorationMapSize = 300;
  34. public int explorationInitialVisible = 80;
  35. [Header("Expansion Settings")]
  36. [Tooltip("Cooldown time between map expansions in seconds")]
  37. public float expansionCooldown = 5f;
  38. [Tooltip("Chance for terrain to continue from existing edge (0-1)")]
  39. [Range(0f, 1f)]
  40. public float terrainContinuityChance = 0.7f;
  41. [Header("Generation Settings")]
  42. public int seed = 12345;
  43. [Header("Visualization")]
  44. public MapVisualizer mapVisualizer;
  45. [Header("Debug")]
  46. public bool debugMode = false;
  47. private MapData mapData;
  48. private TerrainGenerator terrainGenerator;
  49. private FeatureGenerator featureGenerator;
  50. private ExpansionManager expansionManager;
  51. private ExplorationManager explorationManager;
  52. private Transform player;
  53. private float lastExpansionTime = 0f;
  54. void Start()
  55. {
  56. InitializeMap();
  57. if (useSimpleMode)
  58. {
  59. GenerateCompleteMapWithTeamMarker();
  60. }
  61. else if (useExplorationSystem)
  62. {
  63. InitializeExplorationSystem();
  64. }
  65. else
  66. {
  67. GenerateInitialMap();
  68. }
  69. }
  70. void Update()
  71. {
  72. // In simple mode, no expansion or exploration updates needed
  73. if (useSimpleMode)
  74. {
  75. // Only handle finding the player reference if missing
  76. if (player == null)
  77. {
  78. GameObject teamMarker = GameObject.Find("TeamMarker");
  79. if (teamMarker != null)
  80. {
  81. player = teamMarker.transform;
  82. }
  83. }
  84. return;
  85. }
  86. // Only handle finding the player reference, not continuous exploration checks
  87. if (player == null)
  88. {
  89. // Debug log every few seconds to show player reference status
  90. if (Time.time % 3f < Time.deltaTime)
  91. {
  92. Debug.LogWarning($"🚫 MapMaker2 Update: Player reference is null! useExplorationSystem: {useExplorationSystem}");
  93. // Try to find TeamMarker if not found
  94. GameObject teamMarker = GameObject.Find("TeamMarker");
  95. if (teamMarker != null)
  96. {
  97. player = teamMarker.transform;
  98. }
  99. }
  100. }
  101. else if (!useExplorationSystem)
  102. {
  103. // Only run expansion checks for the old system
  104. CheckForExpansion();
  105. }
  106. // Exploration system is now event-driven, no Update checks needed!
  107. }
  108. private void InitializeMap()
  109. {
  110. Random.InitState(seed);
  111. mapData = new MapData(initialMapSize, initialMapSize);
  112. terrainGenerator = new TerrainGenerator();
  113. featureGenerator = new FeatureGenerator();
  114. expansionManager = new ExpansionManager(this);
  115. explorationManager = new ExplorationManager(this);
  116. // Find player object - try multiple approaches
  117. GameObject playerObj = GameObject.FindGameObjectWithTag("Player");
  118. // If no "Player" tag found, try finding by name patterns
  119. if (playerObj == null)
  120. {
  121. // Try common player names
  122. string[] playerNames = { "TeamMarker", "Player", "PlayerCharacter", "Team", "MainCharacter" };
  123. foreach (string name in playerNames)
  124. {
  125. playerObj = GameObject.Find(name);
  126. if (playerObj != null)
  127. {
  128. Debug.LogWarning($"Found player object by name '{name}' but it doesn't have 'Player' tag. Consider adding the tag.");
  129. break;
  130. }
  131. }
  132. }
  133. if (playerObj != null)
  134. {
  135. player = playerObj.transform;
  136. }
  137. else
  138. {
  139. Debug.LogWarning("No player object found! Trying to find any object that might be the player...");
  140. }
  141. // Initialize visualizer if not set
  142. if (mapVisualizer == null)
  143. mapVisualizer = GetComponent<MapVisualizer>();
  144. }
  145. private void GenerateInitialMap()
  146. {
  147. // Generate base terrain
  148. terrainGenerator.GenerateTerrain(mapData);
  149. // Generate features
  150. featureGenerator.GenerateFeatures(mapData);
  151. // Visualize the map
  152. VisualizeMap();
  153. }
  154. /// <summary>
  155. /// Generate complete map with team marker placement - Simple Mode
  156. /// </summary>
  157. private void GenerateCompleteMapWithTeamMarker()
  158. {
  159. // Generate the full beautiful map using original generators
  160. terrainGenerator.GenerateTerrain(mapData);
  161. featureGenerator.GenerateFeatures(mapData);
  162. // Find a good settlement for team marker placement
  163. Vector2Int? settlementPos = FindBestSettlementForTeamMarker();
  164. if (!settlementPos.HasValue)
  165. {
  166. // Fallback to center if no settlements found
  167. Vector2Int centerPos = new Vector2Int(mapData.Width / 2, mapData.Height / 2);
  168. // PlaceTeamMarkerAt(centerPos);
  169. Debug.LogWarning($"⚠️ No settlements found, placed team marker at center: {centerPos}");
  170. }
  171. // Visualize the map
  172. VisualizeMap();
  173. }
  174. /// <summary>
  175. /// Find the best settlement position for team marker placement
  176. /// </summary>
  177. private Vector2Int? FindBestSettlementForTeamMarker()
  178. {
  179. List<Vector2Int> settlements = new List<Vector2Int>();
  180. // Find all towns and villages
  181. for (int x = 0; x < mapData.Width; x++)
  182. {
  183. for (int y = 0; y < mapData.Height; y++)
  184. {
  185. MapTile tile = mapData.GetTile(x, y);
  186. if (tile != null && (tile.featureType == FeatureType.Town || tile.featureType == FeatureType.Village))
  187. {
  188. settlements.Add(new Vector2Int(x, y));
  189. }
  190. }
  191. }
  192. if (settlements.Count == 0) return null;
  193. // Prefer towns over villages, and those closer to center
  194. Vector2 center = new Vector2(mapData.Width / 2f, mapData.Height / 2f);
  195. Vector2Int bestSettlement = settlements[0];
  196. float bestScore = float.MinValue;
  197. foreach (Vector2Int settlement in settlements)
  198. {
  199. MapTile tile = mapData.GetTile(settlement.x, settlement.y);
  200. float score = 0;
  201. // Prefer towns (higher score)
  202. if (tile.featureType == FeatureType.Town) score += 100;
  203. else score += 50; // Village
  204. // Prefer locations closer to center (but not exactly center)
  205. float distanceToCenter = Vector2.Distance(settlement, center);
  206. score += Mathf.Max(0, 50 - distanceToCenter); // Closer to center = higher score
  207. if (score > bestScore)
  208. {
  209. bestScore = score;
  210. bestSettlement = settlement;
  211. }
  212. }
  213. return bestSettlement;
  214. }
  215. /// <summary>
  216. /// Place team marker at specified map coordinates
  217. /// </summary>
  218. private void PlaceTeamMarkerAt(Vector2Int mapPos)
  219. {
  220. // Remove existing team marker
  221. GameObject existingMarker = GameObject.Find("TeamMarker");
  222. if (existingMarker != null)
  223. {
  224. DestroyImmediate(existingMarker);
  225. }
  226. // Create new team marker
  227. GameObject teamMarker = new GameObject("TeamMarkerMapMaker2");
  228. // Position it correctly in world space
  229. teamMarker.transform.position = new Vector3(mapPos.x, 0.5f, mapPos.y);
  230. // Add visual representation
  231. GameObject visualMarker = GameObject.CreatePrimitive(PrimitiveType.Sphere);
  232. visualMarker.transform.SetParent(teamMarker.transform);
  233. visualMarker.transform.localPosition = Vector3.zero;
  234. visualMarker.transform.localScale = Vector3.one * 0.8f;
  235. // Make it green and distinctive
  236. Renderer renderer = visualMarker.GetComponent<Renderer>();
  237. if (renderer != null)
  238. {
  239. renderer.material.color = Color.green;
  240. }
  241. // Add a tag for easy finding
  242. teamMarker.tag = "Player";
  243. // Update player reference
  244. player = teamMarker.transform;
  245. }
  246. private void CheckForExpansion()
  247. {
  248. // Check if mapVisualizer is available and has valid tileSize
  249. if (mapVisualizer == null)
  250. {
  251. Debug.LogWarning("MapVisualizer is null! Cannot check for expansion.");
  252. return;
  253. }
  254. float tileSize = mapVisualizer.tileSize;
  255. if (tileSize <= 0)
  256. {
  257. Debug.LogWarning($"Invalid tile size: {tileSize}. Using default value of 1.");
  258. tileSize = 1f;
  259. }
  260. // Debug player position
  261. Vector2 playerPos = new Vector2(player.position.x / tileSize, player.position.z / tileSize);
  262. // Debug log every few seconds
  263. if (Time.time % 2f < Time.deltaTime) // Log every 2 seconds
  264. {
  265. }
  266. // Check cooldown to prevent rapid expansions
  267. if (Time.time - lastExpansionTime < expansionCooldown)
  268. return;
  269. if (expansionManager.ShouldExpand(playerPos, mapData))
  270. {
  271. ExpandMap(playerPos);
  272. }
  273. }
  274. private void ExpandMap(Vector2 playerPos)
  275. {
  276. lastExpansionTime = Time.time;
  277. expansionManager.ExpandMap(mapData, playerPos, expansionSize);
  278. VisualizeMap(); // Update visualization
  279. }
  280. private void VisualizeMap()
  281. {
  282. if (mapVisualizer != null)
  283. {
  284. mapVisualizer.VisualizeMap(mapData);
  285. }
  286. }
  287. public TerrainGenerator GetTerrainGenerator() => terrainGenerator;
  288. public FeatureGenerator GetFeatureGenerator() => featureGenerator;
  289. public ExplorationManager GetExplorationManager() => explorationManager;
  290. // Public method to manually set player reference if automatic detection fails
  291. public void SetPlayer(Transform playerTransform)
  292. {
  293. player = playerTransform;
  294. }
  295. /// <summary>
  296. /// Enable Simple Mode - Beautiful map generation without exploration/expansion
  297. /// </summary>
  298. [ContextMenu("🎮 Enable Simple Mode (Beautiful Map + Team Marker)")]
  299. public void EnableSimpleMode()
  300. {
  301. useSimpleMode = true;
  302. useExplorationSystem = false;
  303. // Clear existing map visualization
  304. if (mapVisualizer != null)
  305. mapVisualizer.ClearAllTiles();
  306. // Regenerate with simple mode
  307. mapData = new MapData(initialMapSize, initialMapSize);
  308. GenerateCompleteMapWithTeamMarker();
  309. }
  310. // For debugging - regenerate map
  311. [ContextMenu("Regenerate Map")]
  312. public void RegenerateMap()
  313. {
  314. if (mapVisualizer != null)
  315. mapVisualizer.ClearAllTiles();
  316. // Preserve current map size instead of resetting to initial size
  317. int currentWidth = mapData != null ? mapData.Width : initialMapSize;
  318. int currentHeight = mapData != null ? mapData.Height : initialMapSize;
  319. Random.InitState(seed);
  320. mapData = new MapData(currentWidth, currentHeight);
  321. terrainGenerator = new TerrainGenerator();
  322. featureGenerator = new FeatureGenerator();
  323. GenerateInitialMap();
  324. }
  325. // For debugging - reset to original size
  326. [ContextMenu("Reset to Original Size")]
  327. public void ResetToOriginalSize()
  328. {
  329. if (mapVisualizer != null)
  330. mapVisualizer.ClearAllTiles();
  331. InitializeMap();
  332. GenerateInitialMap();
  333. }
  334. // For debugging - force map expansion
  335. [ContextMenu("Force Map Expansion")]
  336. public void ForceExpansion()
  337. {
  338. Vector2 playerPos;
  339. if (player != null)
  340. {
  341. float tileSize = mapVisualizer != null && mapVisualizer.tileSize > 0 ? mapVisualizer.tileSize : 1f;
  342. playerPos = new Vector2(player.position.x / tileSize, player.position.z / tileSize);
  343. }
  344. else
  345. {
  346. // If no player, expand from center-right edge to test the system
  347. playerPos = new Vector2(mapData.Width - 10, mapData.Height / 2);
  348. Debug.LogWarning("No player found, using test position for forced expansion");
  349. }
  350. lastExpansionTime = 0f; // Reset cooldown
  351. ExpandMap(playerPos);
  352. }
  353. // For debugging - manually set TeamMarker as player
  354. [ContextMenu("Set TeamMarker as Player")]
  355. public void SetTeamMarkerAsPlayer()
  356. {
  357. GameObject teamMarker = GameObject.Find("TeamMarker");
  358. if (teamMarker != null)
  359. {
  360. SetPlayer(teamMarker.transform);
  361. }
  362. else
  363. {
  364. Debug.LogError("TeamMarker object not found!");
  365. }
  366. }
  367. // === Exploration System Methods ===
  368. private void InitializeExplorationSystem()
  369. {
  370. if (explorationManager == null)
  371. {
  372. Debug.LogError("❌ ExplorationManager is null! Cannot initialize exploration system.");
  373. return;
  374. }
  375. explorationManager.fullMapWidth = explorationMapSize;
  376. explorationManager.fullMapHeight = explorationMapSize;
  377. explorationManager.initialVisibleSize = explorationInitialVisible;
  378. explorationManager.InitializeExploration();
  379. }
  380. private void ExploreNewAreas(Vector2 playerPos)
  381. {
  382. lastExpansionTime = Time.time;
  383. explorationManager.ExploreNewAreas(playerPos, mapData);
  384. VisualizeMap(); // Update visualization
  385. }
  386. // === Public Methods for Event-Driven Exploration ===
  387. /// <summary>
  388. /// Check for exploration when team position changes (event-driven)
  389. /// </summary>
  390. public void OnTeamPositionChanged(Vector2Int newPosition)
  391. {
  392. if (!useExplorationSystem || explorationManager == null)
  393. return;
  394. // Optimization: Only check if team moved a significant distance or cooldown passed
  395. if (Time.time - lastExpansionTime < expansionCooldown)
  396. return;
  397. // Convert tile position to world position for exploration system
  398. Vector2 worldPos = new Vector2(newPosition.x, newPosition.y);
  399. if (explorationManager.ShouldExplore(worldPos, mapData))
  400. {
  401. ExploreNewAreas(worldPos);
  402. }
  403. }
  404. // === Methods needed by ExplorationManager ===
  405. public void GenerateCompleteMap(MapData targetMapData)
  406. {
  407. // Generate base terrain
  408. terrainGenerator.GenerateTerrain(targetMapData);
  409. // Generate features
  410. featureGenerator.GenerateFeatures(targetMapData);
  411. }
  412. [ContextMenu("Enable Exploration System")]
  413. public void EnableExplorationSystem()
  414. {
  415. useExplorationSystem = true;
  416. }
  417. [ContextMenu("Test Exploration Now")]
  418. public void TestExplorationNow()
  419. {
  420. if (!useExplorationSystem)
  421. {
  422. Debug.LogWarning("⚠️ Exploration system is not enabled! Enable it first.");
  423. return;
  424. }
  425. // Debug player detection
  426. if (player == null)
  427. {
  428. // Try to find player again
  429. GameObject playerObj = GameObject.FindGameObjectWithTag("Player");
  430. if (playerObj == null)
  431. {
  432. playerObj = GameObject.Find("TeamMarker");
  433. }
  434. if (playerObj != null)
  435. {
  436. player = playerObj.transform;
  437. }
  438. else
  439. {
  440. Debug.LogError("❌ Cannot find player object! Make sure TeamMarker has 'Player' tag or is named 'TeamMarker'");
  441. return;
  442. }
  443. }
  444. if (explorationManager == null)
  445. {
  446. Debug.LogError("❌ ExplorationManager is null! This should be created in InitializeMap()");
  447. return;
  448. }
  449. float tileSize = mapVisualizer != null && mapVisualizer.tileSize > 0 ? mapVisualizer.tileSize : 1f;
  450. Vector2 playerPos = new Vector2(player.position.x / tileSize, player.position.z / tileSize);
  451. // Force exploration regardless of cooldown
  452. lastExpansionTime = 0f;
  453. ExploreNewAreas(playerPos);
  454. }
  455. [ContextMenu("DEBUG: Show Full 300x300 Map")]
  456. public void ShowFullMap()
  457. {
  458. if (!useExplorationSystem || explorationManager == null)
  459. {
  460. Debug.LogError("❌ Exploration system not enabled or null!");
  461. return;
  462. }
  463. explorationManager.ShowFullMap();
  464. }
  465. [ContextMenu("DEBUG: Show Exploration State")]
  466. public void DebugExplorationState()
  467. {
  468. if (!useExplorationSystem || explorationManager == null)
  469. {
  470. Debug.LogError("❌ Exploration system not enabled or null!");
  471. return;
  472. }
  473. if (player == null)
  474. {
  475. GameObject teamMarker = GameObject.Find("TeamMarker");
  476. if (teamMarker != null) player = teamMarker.transform;
  477. }
  478. if (player == null)
  479. {
  480. Debug.LogError("❌ No player/team marker found!");
  481. return;
  482. }
  483. float tileSize = mapVisualizer != null && mapVisualizer.tileSize > 0 ? mapVisualizer.tileSize : 1f;
  484. Vector2 playerPos = new Vector2(player.position.x / tileSize, player.position.z / tileSize);
  485. explorationManager.DebugExplorationState(playerPos, mapData);
  486. }
  487. [ContextMenu("Disable Exploration System")]
  488. public void DisableExplorationSystem()
  489. {
  490. useExplorationSystem = false;
  491. }
  492. [ContextMenu("PERF: Toggle Performance Mode")]
  493. public void TogglePerformanceMode()
  494. {
  495. if (explorationManager != null)
  496. {
  497. explorationManager.TogglePerformanceMode();
  498. }
  499. else
  500. {
  501. Debug.LogError("❌ Exploration manager not available!");
  502. }
  503. }
  504. [ContextMenu("PERF: Test 500x500 Map")]
  505. public void TestLargeMap500()
  506. {
  507. if (explorationManager != null)
  508. {
  509. explorationManager.SetMapSize(500, 500);
  510. }
  511. else
  512. {
  513. Debug.LogError("❌ Exploration manager not available!");
  514. }
  515. }
  516. [ContextMenu("PERF: Test 1000x1000 Map")]
  517. public void TestMassiveMap1000()
  518. {
  519. if (explorationManager != null)
  520. {
  521. explorationManager.SetMapSize(1000, 1000);
  522. }
  523. else
  524. {
  525. Debug.LogError("❌ Exploration manager not available!");
  526. }
  527. }
  528. [ContextMenu("PERF: Reset to 300x300")]
  529. public void ResetToStandardSize()
  530. {
  531. if (explorationManager != null)
  532. {
  533. explorationManager.SetMapSize(300, 300);
  534. }
  535. else
  536. {
  537. Debug.LogError("❌ Exploration manager not available!");
  538. }
  539. }
  540. [ContextMenu("FIX: Synchronize Team Marker Position")]
  541. public void SynchronizeTeamMarkerPosition()
  542. {
  543. if (explorationManager != null)
  544. {
  545. explorationManager.SynchronizeTeamMarkerPosition();
  546. }
  547. else
  548. {
  549. Debug.LogError("❌ Exploration manager not available!");
  550. }
  551. }
  552. [ContextMenu("TEST: Debug Full Map Coordinate Fix")]
  553. public void TestFullMapCoordinateFix()
  554. {
  555. if (!useExplorationSystem || explorationManager == null)
  556. {
  557. Debug.LogError("❌ Exploration system not enabled or null!");
  558. return;
  559. }
  560. GameObject teamMarker = GameObject.Find("TeamMarker");
  561. if (teamMarker == null)
  562. {
  563. Debug.LogError("❌ Team marker not found!");
  564. return;
  565. }
  566. Vector3 worldPos = teamMarker.transform.position;
  567. Vector2Int worldTilePos = new Vector2Int(
  568. Mathf.RoundToInt(worldPos.x),
  569. Mathf.RoundToInt(worldPos.y)
  570. );
  571. // Show full map and check if position is preserved
  572. explorationManager.ShowFullMap();
  573. // Check position after full map is shown
  574. Vector3 newWorldPos = teamMarker.transform.position;
  575. Vector2Int newWorldTilePos = new Vector2Int(
  576. Mathf.RoundToInt(newWorldPos.x),
  577. Mathf.RoundToInt(newWorldPos.y)
  578. );
  579. if (worldTilePos != newWorldTilePos)
  580. {
  581. Debug.LogError($"❌ COORDINATE FIX FAILED: Position changed from {worldTilePos} to {newWorldTilePos}");
  582. }
  583. else
  584. {
  585. }
  586. }
  587. [ContextMenu("FIX: Reset Team Marker to Map Center")]
  588. public void ResetTeamMarkerToCenter()
  589. {
  590. if (!useExplorationSystem || explorationManager == null)
  591. {
  592. Debug.LogError("❌ Exploration system not enabled or null!");
  593. return;
  594. }
  595. explorationManager.ResetTeamMarkerToMapCenter();
  596. }
  597. [ContextMenu("FIX: Clear Saved Team Position")]
  598. public void ClearSavedTeamPosition()
  599. {
  600. // Clear saved position from PlayerPrefs
  601. string keyX = $"TeamPosition_{seed}_X";
  602. string keyY = $"TeamPosition_{seed}_Y";
  603. if (PlayerPrefs.HasKey(keyX)) PlayerPrefs.DeleteKey(keyX);
  604. if (PlayerPrefs.HasKey(keyY)) PlayerPrefs.DeleteKey(keyY);
  605. PlayerPrefs.Save();
  606. }
  607. [ContextMenu("DEBUG: Show Coordinate State")]
  608. public void DebugCoordinateState()
  609. {
  610. if (explorationManager != null)
  611. {
  612. explorationManager.DebugCoordinateState();
  613. }
  614. else
  615. {
  616. Debug.LogError("❌ Exploration manager not available!");
  617. }
  618. }
  619. [ContextMenu("FIX: Force Coordinate Sync")]
  620. public void ForceCoordinateSync()
  621. {
  622. if (explorationManager != null)
  623. {
  624. explorationManager.ForceCoordinateSync();
  625. }
  626. else
  627. {
  628. Debug.LogError("❌ Exploration manager not available!");
  629. }
  630. }
  631. [ContextMenu("TEST: Simple Coordinate Conversion")]
  632. public void TestSimpleCoordinateConversion()
  633. {
  634. if (!useExplorationSystem || explorationManager == null)
  635. {
  636. Debug.LogError("❌ Exploration system not enabled or null!");
  637. return;
  638. }
  639. explorationManager.TestSimpleCoordinateConversion();
  640. }
  641. [ContextMenu("TEST: Positioning After Fix")]
  642. public void TestPositioningAfterFix()
  643. {
  644. if (!useExplorationSystem || explorationManager == null)
  645. {
  646. Debug.LogError("❌ Exploration system not enabled or null!");
  647. return;
  648. }
  649. explorationManager.TestPositioningAfterFix();
  650. }
  651. [ContextMenu("TEST: Full Map Tile Coverage")]
  652. public void TestFullMapTileCoverage()
  653. {
  654. if (!useExplorationSystem || explorationManager == null)
  655. {
  656. Debug.LogError("❌ Exploration system not enabled or null!");
  657. return;
  658. }
  659. explorationManager.TestFullMapTileCoverage();
  660. }
  661. [ContextMenu("TEST: Visual Tile Rendering")]
  662. public void TestVisualTileRendering()
  663. {
  664. if (!useExplorationSystem || explorationManager == null)
  665. {
  666. Debug.LogError("❌ Exploration system not enabled or null!");
  667. return;
  668. }
  669. explorationManager.TestVisualTileRendering();
  670. }
  671. [ContextMenu("TEST: Detailed Coordinate Conversion")]
  672. public void TestDetailedCoordinateConversion()
  673. {
  674. if (!useExplorationSystem || explorationManager == null)
  675. {
  676. Debug.LogError("❌ Exploration system not enabled or null!");
  677. return;
  678. }
  679. explorationManager.TestCoordinateConversion();
  680. }
  681. /// <summary>
  682. /// Public method to synchronize team position - can be called by travel system
  683. /// </summary>
  684. public void SyncTeamPosition()
  685. {
  686. if (useExplorationSystem && explorationManager != null)
  687. {
  688. explorationManager.SynchronizeTeamMarkerPosition();
  689. }
  690. }
  691. // Expose map size properties for ExplorationManager
  692. public int mapWidth
  693. {
  694. get => mapData?.Width ?? initialMapSize;
  695. set { /* Can be used by exploration system */ }
  696. }
  697. public int mapHeight
  698. {
  699. get => mapData?.Height ?? initialMapSize;
  700. set { /* Can be used by exploration system */ }
  701. }
  702. }