Axel Nordh 8 месяцев назад
Родитель
Сommit
68a1086791

+ 7 - 0
Assets/Scripts/Map/SimpleTeamPlacement.cs

@@ -347,6 +347,13 @@ public class SimpleTeamPlacement : MonoBehaviour
             StartBlinking();
         }
 
+        // Notify camera to center on the newly created team marker
+        var cameraController = FindFirstObjectByType<MMCameraController>();
+        if (cameraController != null)
+        {
+            cameraController.OnTeamMarkerCreated();
+        }
+
     }
 
     /// <summary>

+ 63 - 0
Assets/Scripts/Map/TeamTravelSystem.cs

@@ -1129,6 +1129,66 @@ public class TeamTravelSystem : MonoBehaviour
         currentPathVisualizations.Clear();
     }
 
+    /// <summary>
+    /// Shows only the selected route with transparency for better marker visibility during travel
+    /// </summary>
+    private void ShowTravelRouteOnly(TravelRoute route)
+    {
+        if (route == null || route.path.Count == 0)
+        {
+            if (showDebugLogs)
+            {
+                Debug.LogWarning("❌ Cannot show travel route: route is null or has no path");
+            }
+            return;
+        }
+
+        // Clear all existing route visualizations
+        ClearPathVisualization();
+
+        if (showDebugLogs)
+        {
+            Debug.Log($"🎯 Showing only {route.routeType} route with transparency for travel");
+        }
+
+        // Create a semi-transparent visualization of the selected route
+        var pathObject = new GameObject($"TravelPath_{route.routeType}_Traveling");
+        var lineRenderer = pathObject.AddComponent<LineRenderer>();
+
+        // Configure line renderer with semi-transparent material
+        var baseMaterial = pathLineMaterial ?? CreateDefaultPathMaterial();
+        var routeMaterial = new Material(baseMaterial);
+        var routeColor = GetRouteColor(route);
+
+        // Set to 50% transparency for better marker visibility
+        routeColor.a = 0.5f;
+        routeMaterial.color = routeColor;
+        lineRenderer.material = routeMaterial;
+
+        // Use a thinner line during travel to be less obtrusive
+        lineRenderer.startWidth = 1.2f;
+        lineRenderer.endWidth = 1.2f;
+        lineRenderer.positionCount = route.path.Count;
+
+        // Set sorting order to be below the team marker
+        lineRenderer.sortingOrder = 45; // Lower than team marker
+
+        // Set path points
+        for (int i = 0; i < route.path.Count; i++)
+        {
+            Vector3 worldPos = TileToWorldPosition(route.path[i]);
+            worldPos.y = pathLineHeight; // Keep consistent height
+            lineRenderer.SetPosition(i, worldPos);
+        }
+
+        currentPathVisualizations.Add(pathObject);
+
+        if (showDebugLogs)
+        {
+            Debug.Log($"✅ Travel route visualization created: {route.routeType} with 50% transparency");
+        }
+    }
+
     /// <summary>
     /// Cancels current travel planning
     /// </summary>
@@ -1163,6 +1223,9 @@ public class TeamTravelSystem : MonoBehaviour
         shouldCancelJourney = false;
         currentRoute = route;
 
+        // Show only the selected route with transparency for better marker visibility
+        ShowTravelRouteOnly(route);
+
         // Start the travel coroutine and store reference
         currentTravelCoroutine = StartCoroutine(ExecuteTravel(route));
     }

+ 20 - 10
Assets/Scripts/MapMaker2/Visualization/MMCameraController.cs

@@ -12,7 +12,8 @@ public class MMCameraController : MonoBehaviour
     public KeyCode centerOnTeamKey = KeyCode.C;
     public KeyCode zoomToFullMapKey = KeyCode.F;
     public float focusZoomLevel = 10f;
-    public float centeringSpeed = 2f;
+    public float centeringSpeed = 5f; // Increased for faster centering
+    public float teamMarkerZoomSize = 100f; // Zoom level when centering on team marker
 
     private Camera cam;
     private Vector3 lastMousePosition;
@@ -89,11 +90,14 @@ public class MMCameraController : MonoBehaviour
             transform.position = Vector3.Lerp(transform.position, targetPosition, Time.deltaTime * centeringSpeed);
             cam.orthographicSize = Mathf.Lerp(cam.orthographicSize, targetZoom, Time.deltaTime * centeringSpeed);
 
-            // Check if we're close enough to stop moving
-            if (Vector3.Distance(transform.position, targetPosition) < 0.1f &&
-                Mathf.Abs(cam.orthographicSize - targetZoom) < 0.1f)
+            // Check if we're close enough to stop moving (more lenient thresholds for faster completion)
+            if (Vector3.Distance(transform.position, targetPosition) < 0.5f &&
+                Mathf.Abs(cam.orthographicSize - targetZoom) < 0.5f)
             {
                 isMovingToTarget = false;
+                // Snap to final position to avoid endless lerping
+                transform.position = targetPosition;
+                cam.orthographicSize = targetZoom;
             }
         }
         else
@@ -108,7 +112,7 @@ public class MMCameraController : MonoBehaviour
         if (Input.GetKeyDown(KeyCode.H))
         {
             Debug.Log("💡 Camera Controls:\n" +
-                     $"- {centerOnTeamKey}: Center on team marker (preserves zoom)\n" +
+                     $"- {centerOnTeamKey}: Center on team marker (zoom to {teamMarkerZoomSize})\n" +
                      $"- {zoomToFullMapKey}: Zoom to full map\n" +
                      "- WASD/Arrows: Move camera\n" +
                      $"- Mouse wheel: Zoom (range: {minZoom}-{maxZoom})\n" +
@@ -138,11 +142,9 @@ public class MMCameraController : MonoBehaviour
                 // Set target position to center on team marker (keep Y position for camera height)
                 // For top-down view: X and Z are the map coordinates, Y is camera height
                 targetPosition = new Vector3(teamPos.x, transform.position.y, teamPos.z);
-                // Keep current zoom level instead of changing to focusZoomLevel
-                targetZoom = cam.orthographicSize;
+                // Use specific zoom level for team marker focus
+                targetZoom = teamMarkerZoomSize;
                 isMovingToTarget = true;
-
-                Debug.Log($"🎯 Centering camera on team marker at position: {teamPos}");
             }
             else
             {
@@ -154,7 +156,7 @@ public class MMCameraController : MonoBehaviour
                 {
                     Vector3 teamPos = foundMarker.transform.position;
                     targetPosition = new Vector3(teamPos.x, transform.position.y, teamPos.z);
-                    targetZoom = cam.orthographicSize;
+                    targetZoom = teamMarkerZoomSize;
                     isMovingToTarget = true;
                     Debug.Log($"🎯 Found team marker by name, centering at: {teamPos}");
                 }
@@ -215,6 +217,14 @@ public class MMCameraController : MonoBehaviour
         }
     }
 
+    /// <summary>
+    /// Automatically center and zoom to team marker when it's created
+    /// </summary>
+    public void OnTeamMarkerCreated()
+    {
+        CenterOnTeamMarker();
+    }
+
     private void HandleMovement()
     {
         float horizontal = Input.GetAxis("Horizontal");