| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 | 
							- 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>();
 
-     private int currentMapIndex;
 
-     public List<LodStayLayer> MapStayList = new List<LodStayLayer>();
 
-     
 
-     private void Awake()
 
-     {
 
-         cameraBirdSec.OnDistanceChange += OnCameraDistanceChange;
 
-     }
 
-     private void Start()
 
-     {
 
-         currentMapIndex = MapList.Count - 1;
 
-         MapList[currentMapIndex].map.ShowMap();
 
-         cameraBirdSec.detailLod = false;
 
-         cameraBirdSec.currentDistance = MapList[currentMapIndex].cameraDistanceMax;
 
-         SetCameraRange(cameraBirdSec.currentDistance);
 
-     }
 
-     private void OnDestroy()
 
-     {
 
-         cameraBirdSec.OnDistanceChange -= OnCameraDistanceChange;
 
-     }
 
-     private void OnCameraDistanceChange(float value)
 
-     {
 
-         if (currentMapIndex == 0)
 
-         {
 
-             if (value > MapList[currentMapIndex].cameraDistanceMax)
 
-             {
 
-                 MapList[currentMapIndex+1].map.ShowMap();
 
-                 MapList[currentMapIndex].map.Hide();
 
-                 currentMapIndex++;
 
-                 cameraBirdSec.detailLod = false;
 
-                 cameraBirdSec.currentDistance = MapList[currentMapIndex].cameraDistanceMax;
 
-                 SetCameraRange(MapList[currentMapIndex].cameraDistanceMax);
 
-                 return;
 
-             }
 
-             SetCameraRange(value);
 
-             for (int i = 0; i < MapStayList.Count; i++)
 
-             {
 
-                 if (value >= MapStayList[i].cameraDistanceMin && value < MapStayList[i].cameraDistanceMax)
 
-                 {
 
-                     MapStayList[i].map.ShowMap();
 
-                 }
 
-                 else
 
-                 {
 
-                     MapStayList[i].map.Hide();
 
-                 }
 
-             }
 
-         }
 
-         else
 
-         {
 
-             if (value>0)
 
-             {
 
-                 MapList[currentMapIndex-1].map.ShowMap();
 
-                 MapList[currentMapIndex].map.Hide();
 
-                 currentMapIndex--;
 
-                 if (currentMapIndex == 0)
 
-                 {
 
-                     cameraBirdSec.detailLod = true;
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 if (currentMapIndex >= MapList.Count - 1)
 
-                 {
 
-                     return;
 
-                 }
 
-                 MapList[currentMapIndex+1].map.ShowMap();
 
-                 MapList[currentMapIndex].map.Hide();
 
-                 currentMapIndex++;
 
-             }
 
-             cameraBirdSec.currentDistance = MapList[currentMapIndex].cameraDistanceMax;
 
-             SetCameraRange(MapList[currentMapIndex].cameraDistanceMax);
 
-         }
 
-     }
 
-     private void SetCameraRange(float cameraDistance)
 
-     {
 
-         var currentLayer = MapList[currentMapIndex];
 
-         float distanceRange = (cameraDistance-currentLayer.cameraDistanceMin)/(currentLayer.cameraDistanceMax-currentLayer.cameraDistanceMin);
 
-         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; 
 
-         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;
 
- }
 
- [Serializable]
 
- public class LodStayLayer
 
- {
 
-     public MapGenerator map;
 
-     public float cameraDistanceMin;
 
-     public float cameraDistanceMax;
 
- }
 
 
  |