TeamMarkerCameraTest.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. using UnityEngine;
  2. /// <summary>
  3. /// Test script to verify team marker camera functionality.
  4. /// Attach this to any GameObject to test the camera system.
  5. /// </summary>
  6. public class TeamMarkerCameraTest : MonoBehaviour
  7. {
  8. [Header("Test Controls")]
  9. [Tooltip("Key to run all camera tests")]
  10. public KeyCode testAllKey = KeyCode.T;
  11. [Tooltip("Key to test team marker centering")]
  12. public KeyCode testCenterKey = KeyCode.Y;
  13. [Tooltip("Key to test full map view")]
  14. public KeyCode testFullMapKey = KeyCode.U;
  15. void Update()
  16. {
  17. if (Input.GetKeyDown(testAllKey))
  18. {
  19. RunAllTests();
  20. }
  21. if (Input.GetKeyDown(testCenterKey))
  22. {
  23. TestTeamMarkerCentering();
  24. }
  25. if (Input.GetKeyDown(testFullMapKey))
  26. {
  27. TestFullMapView();
  28. }
  29. }
  30. public void RunAllTests()
  31. {
  32. Debug.Log("🧪 Running Team Marker Camera Tests...");
  33. // Test 1: Check if team placement exists
  34. TestTeamPlacementExists();
  35. // Test 2: Check if camera controllers exist
  36. TestCameraControllersExist();
  37. // Test 3: Test team marker centering
  38. TestTeamMarkerCentering();
  39. // Test 4: Test full map view
  40. TestFullMapView();
  41. Debug.Log("✅ Team Marker Camera Tests Complete!");
  42. }
  43. private void TestTeamPlacementExists()
  44. {
  45. SimpleTeamPlacement teamPlacement = FindFirstObjectByType<SimpleTeamPlacement>();
  46. if (teamPlacement == null)
  47. {
  48. Debug.LogError("❌ SimpleTeamPlacement not found in scene!");
  49. return;
  50. }
  51. Debug.Log("✅ SimpleTeamPlacement found");
  52. if (!teamPlacement.IsTeamPlaced())
  53. {
  54. Debug.LogWarning("⚠️ Team not yet placed, attempting to place...");
  55. teamPlacement.RandomlyPlaceTeam();
  56. }
  57. else
  58. {
  59. Debug.Log("✅ Team is placed");
  60. }
  61. GameObject teamMarker = teamPlacement.GetTeamMarker();
  62. if (teamMarker != null)
  63. {
  64. Debug.Log($"✅ Team marker found at position: {teamMarker.transform.position}");
  65. }
  66. else
  67. {
  68. Debug.LogError("❌ Team marker object not found!");
  69. }
  70. }
  71. private void TestCameraControllersExist()
  72. {
  73. // Check for enhanced camera controllers
  74. MapCameraController mapCameraController = FindFirstObjectByType<MapCameraController>();
  75. MMCameraController mmCameraController = FindFirstObjectByType<MMCameraController>();
  76. TeamMarkerCameraController teamMarkerController = FindFirstObjectByType<TeamMarkerCameraController>();
  77. int controllerCount = 0;
  78. if (mapCameraController != null)
  79. {
  80. Debug.Log("✅ MapCameraController found (enhanced with team marker support)");
  81. controllerCount++;
  82. }
  83. if (mmCameraController != null)
  84. {
  85. Debug.Log("✅ MMCameraController found (enhanced with team marker support)");
  86. controllerCount++;
  87. }
  88. if (teamMarkerController != null)
  89. {
  90. Debug.Log("✅ TeamMarkerCameraController found (universal component)");
  91. controllerCount++;
  92. }
  93. if (controllerCount == 0)
  94. {
  95. Debug.LogWarning("⚠️ No enhanced camera controllers found. You may need to add TeamMarkerCameraController to your camera.");
  96. }
  97. else
  98. {
  99. Debug.Log($"✅ Found {controllerCount} camera controller(s) with team marker support");
  100. }
  101. }
  102. private void TestTeamMarkerCentering()
  103. {
  104. Debug.Log("🎯 Testing team marker centering...");
  105. // Try to find any camera controller that supports team marker centering
  106. TeamMarkerCameraController teamMarkerController = FindFirstObjectByType<TeamMarkerCameraController>();
  107. if (teamMarkerController != null)
  108. {
  109. teamMarkerController.CenterOnTeamMarker();
  110. Debug.Log("✅ Called CenterOnTeamMarker() on TeamMarkerCameraController");
  111. return;
  112. }
  113. MapCameraController mapCameraController = FindFirstObjectByType<MapCameraController>();
  114. if (mapCameraController != null)
  115. {
  116. mapCameraController.CenterOnTeamMarker();
  117. Debug.Log("✅ Called CenterOnTeamMarker() on MapCameraController");
  118. return;
  119. }
  120. MMCameraController mmCameraController = FindFirstObjectByType<MMCameraController>();
  121. if (mmCameraController != null)
  122. {
  123. mmCameraController.CenterOnTeamMarker();
  124. Debug.Log("✅ Called CenterOnTeamMarker() on MMCameraController");
  125. return;
  126. }
  127. Debug.LogWarning("⚠️ No camera controller with CenterOnTeamMarker() method found!");
  128. }
  129. private void TestFullMapView()
  130. {
  131. Debug.Log("🗺️ Testing full map view...");
  132. // Try to find any camera controller that supports full map view
  133. TeamMarkerCameraController teamMarkerController = FindFirstObjectByType<TeamMarkerCameraController>();
  134. if (teamMarkerController != null)
  135. {
  136. teamMarkerController.ZoomToFullMap();
  137. Debug.Log("✅ Called ZoomToFullMap() on TeamMarkerCameraController");
  138. return;
  139. }
  140. MapCameraController mapCameraController = FindFirstObjectByType<MapCameraController>();
  141. if (mapCameraController != null)
  142. {
  143. mapCameraController.ZoomToFullMap();
  144. Debug.Log("✅ Called ZoomToFullMap() on MapCameraController");
  145. return;
  146. }
  147. MMCameraController mmCameraController = FindFirstObjectByType<MMCameraController>();
  148. if (mmCameraController != null)
  149. {
  150. mmCameraController.ZoomToFullMap();
  151. Debug.Log("✅ Called ZoomToFullMap() on MMCameraController");
  152. return;
  153. }
  154. Debug.LogWarning("⚠️ No camera controller with ZoomToFullMap() method found!");
  155. }
  156. void OnEnable()
  157. {
  158. Debug.Log($"🧪 Team Marker Camera Test script enabled!\n" +
  159. $"- {testAllKey}: Run all tests\n" +
  160. $"- {testCenterKey}: Test team marker centering\n" +
  161. $"- {testFullMapKey}: Test full map view");
  162. }
  163. }