| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 | 
							- using System;
 
- using System.Collections;
 
- using System.Collections.Generic;
 
- using UnityEngine;
 
- public class MapLodCtrl : MonoBehaviour
 
- {
 
-     public CameraBirdSec cameraBirdSec;
 
-     public List<LodLayer> MapList = new List<LodLayer>();
 
-     public int currentMapIndex = 0;
 
-     private void Awake()
 
-     {
 
-         cameraBirdSec.OnDistanceChange += OnCameraDistanceChange;
 
-     }
 
-     private void Start()
 
-     {
 
-         MapList[currentMapIndex].map.ShowMap();
 
-         //cameraBirdSec.currentDistance = MapList[currentMapIndex].cameraDistanceMax;
 
-         //OnCameraDistanceChange(cameraBirdSec.currentDistance);
 
-     }
 
-     private void OnDestroy()
 
-     {
 
-         cameraBirdSec.OnDistanceChange -= OnCameraDistanceChange;
 
-     }
 
-     private void OnCameraDistanceChange(float value)
 
-     {
 
-         if (currentMapIndex>0&&value < MapList[currentMapIndex].cameraDistanceMin)
 
-         {
 
-             MapList[currentMapIndex-1].map.ShowMap();
 
-             MapList[currentMapIndex].map.Hide();
 
-             currentMapIndex--;
 
-         }
 
-         if (currentMapIndex < MapList.Count - 1 && value > MapList[currentMapIndex].cameraDistanceMax)
 
-         {
 
-             MapList[currentMapIndex+1].map.ShowMap();
 
-             MapList[currentMapIndex].map.Hide();
 
-             currentMapIndex++;
 
-         }
 
-         var currentLayer = MapList[currentMapIndex];
 
-         
 
-         float distanceRange = (value-currentLayer.cameraDistanceMin)/(currentLayer.cameraDistanceMax-currentLayer.cameraDistanceMin);//27-3
 
-         
 
-         float minX =currentLayer.min_X_Range.x+Mathf.Abs(currentLayer.min_X_Range.x-currentLayer.max_X_Range.x)*distanceRange; 
 
-         float maxX =currentLayer.min_X_Range.y-Mathf.Abs(currentLayer.min_X_Range.y-currentLayer.max_X_Range.y)*distanceRange; 
 
-         float minY =currentLayer.min_Y_Range.y+Mathf.Abs(currentLayer.min_Y_Range.y-currentLayer.max_Y_Range.y)*distanceRange; 
 
-         float maxY =currentLayer.min_Y_Range.x-Mathf.Abs(currentLayer.min_Y_Range.x-currentLayer.max_Y_Range.x)*distanceRange; 
 
-         
 
- //        Debug.Log($"dis:{value} disRange:{distanceRange} minX:{minX} maxX:{maxX} minY:{minY} maxY:{maxY}");
 
-         cameraBirdSec.SetRange(minX,maxX,minY,maxY);
 
-     }
 
- }
 
- [Serializable]
 
- public class LodLayer
 
- {
 
-     public MapGenerator map;
 
-     public float cameraDistanceMin;
 
-     public float cameraDistanceMax;
 
-     public Vector2 min_X_Range;//最短距离时候的X范围
 
-     public Vector2 max_X_Range;//最大距离时候的X范围
 
-     public Vector2 min_Y_Range;
 
-     public Vector2 max_Y_Range;
 
- }
 
 
  |