|
@@ -8,8 +8,7 @@ public class MapLodCtrl : MonoBehaviour
|
|
|
public CameraBirdSec cameraBirdSec;
|
|
|
|
|
|
public List<LodLayer> MapList = new List<LodLayer>();
|
|
|
- public int currentMapIndex = 2;
|
|
|
-
|
|
|
+ private int currentMapIndex;
|
|
|
public List<LodStayLayer> MapStayList = new List<LodStayLayer>();
|
|
|
|
|
|
private void Awake()
|
|
@@ -19,7 +18,11 @@ public class MapLodCtrl : MonoBehaviour
|
|
|
|
|
|
private void Start()
|
|
|
{
|
|
|
+ currentMapIndex = MapList.Count - 1;
|
|
|
MapList[currentMapIndex].map.ShowMap();
|
|
|
+ cameraBirdSec.detailLod = false;
|
|
|
+ cameraBirdSec.currentDistance = MapList[currentMapIndex].cameraDistanceMax;
|
|
|
+ cameraBirdSec.SetRange(MapList[currentMapIndex].max_X_Range.x,MapList[currentMapIndex].max_X_Range.y,MapList[currentMapIndex].max_Y_Range.x,MapList[currentMapIndex].max_Y_Range.y);
|
|
|
}
|
|
|
|
|
|
private void OnDestroy()
|
|
@@ -29,40 +32,62 @@ public class MapLodCtrl : MonoBehaviour
|
|
|
|
|
|
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)
|
|
|
+ if (currentMapIndex == 0)
|
|
|
{
|
|
|
- MapList[currentMapIndex+1].map.ShowMap();
|
|
|
- MapList[currentMapIndex].map.Hide();
|
|
|
- currentMapIndex++;
|
|
|
- }
|
|
|
+ if (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);
|
|
|
- for (int i = 0; i < MapStayList.Count; i++)
|
|
|
+ cameraBirdSec.detailLod = false;
|
|
|
+ cameraBirdSec.currentDistance = MapList[currentMapIndex].cameraDistanceMax;
|
|
|
+ cameraBirdSec.SetRange(MapList[currentMapIndex].max_X_Range.x,MapList[currentMapIndex].max_X_Range.y,MapList[currentMapIndex].max_Y_Range.x,MapList[currentMapIndex].max_Y_Range.y);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var currentLayer = MapList[currentMapIndex];
|
|
|
+ float distanceRange = (value-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);
|
|
|
+ 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 >= MapStayList[i].cameraDistanceMin && value < MapStayList[i].cameraDistanceMax)
|
|
|
+ if (value>0)
|
|
|
{
|
|
|
- MapStayList[i].map.ShowMap();
|
|
|
+ MapList[currentMapIndex-1].map.ShowMap();
|
|
|
+ MapList[currentMapIndex].map.Hide();
|
|
|
+ currentMapIndex--;
|
|
|
+ if (currentMapIndex == 0)
|
|
|
+ {
|
|
|
+ cameraBirdSec.detailLod = true;
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- MapStayList[i].map.Hide();
|
|
|
+ if (currentMapIndex >= MapList.Count - 1)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ MapList[currentMapIndex+1].map.ShowMap();
|
|
|
+ MapList[currentMapIndex].map.Hide();
|
|
|
+ currentMapIndex++;
|
|
|
}
|
|
|
+ cameraBirdSec.currentDistance = MapList[currentMapIndex].cameraDistanceMax;
|
|
|
+ cameraBirdSec.SetRange(MapList[currentMapIndex].max_X_Range.x,MapList[currentMapIndex].max_X_Range.y,MapList[currentMapIndex].max_Y_Range.x,MapList[currentMapIndex].max_Y_Range.y);
|
|
|
}
|
|
|
}
|
|
|
}
|