新版骑行页面前备份

This commit is contained in:
lishuo committed 2021-04-21 14:08:45 +08:00
1 parent 4896fab824
commit e7ad9473a5
85 files changed
+6816 -5424

No files matched your search

@@ -12,7 +12,21 @@ namespace Assets.Scenes.Ride.Scripts
{
public class InitMiniMapProvider : MonoBehaviour
{
[SerializeField]
[SerializeField]
GameObject cude1;
[SerializeField]
GameObject cude2;
[SerializeField]
GameObject cude3;
[SerializeField]
GameObject cude4;
[SerializeField]
GameObject center;
[SerializeField]
AbstractMap _map;
[SerializeField]
Camera _minicamera;
@@ -27,18 +41,18 @@ namespace Assets.Scenes.Ride.Scripts
playerController = FindObjectOfType<PlayerController>();
if (cyclingCotroller != null)
{
var mapdata = cyclingCotroller.GetMapData();
//初始化map
//var point = cyclingCotroller.GetCenterCoordinate();
if (_map != null && mapdata !=null)
var mapdata = cyclingCotroller.GetMapData();
//初始化map
//var point = cyclingCotroller.GetCenterCoordinate();
if (_map != null && mapdata !=null)
{
_map.OnInitialized += _map_OnInitialized;
_map.OnUpdated += _map_OnUpdated;
_map.Initialize(new Vector2d(mapdata.Center[0], mapdata.Center[1]), 12);
var bbox = mapdata.Bbox;
var targetbounds = new Vector2dBounds(new Vector2d(bbox[0], bbox[1]), new Vector2d(bbox[2], bbox[3]));
var targetbounds = new Vector2dBounds(new Vector2d(bbox[1], bbox[0]), new Vector2d(bbox[3], bbox[2]));
var screenBounds = GetScreenBounds();
SetZoomToFitBounds(targetbounds, screenBounds);
var z = SetZoomToFitBounds(targetbounds, screenBounds);
}
}
}
@@ -53,7 +67,15 @@ namespace Assets.Scenes.Ride.Scripts
private void _map_OnInitialized()
{
init = true;
var visualizer = _map.MapVisualizer;
visualizer.OnMapVisualizerStateChanged += (s) =>
{
if (s == ModuleState.Finished)
{
}
};
}
#region Camera 自适应
@@ -62,7 +84,7 @@ namespace Assets.Scenes.Ride.Scripts
/// </summary>
/// <param name="targetBounds">路线的边界</param>
/// <param name="screenBounds">小地图边界</param>
private void SetZoomToFitBounds(Vector2dBounds targetBounds, Vector2dBounds screenBounds)
private int SetZoomToFitBounds(Vector2dBounds targetBounds, Vector2dBounds screenBounds)
{
var targetLonDelta = targetBounds.East - targetBounds.West;
var targetLatDelta = targetBounds.North - targetBounds.South;
@@ -78,18 +100,18 @@ namespace Assets.Scenes.Ride.Scripts
var zoom = (float)(_map.Zoom + Math.Min(latZoom, lonZoom));
_map.SetZoom((float)Math.Floor(zoom));
_map.UpdateMap();
_map.SetZoom((float)Math.Floor(zoom));
_map.UpdateMap();
return (int)Math.Floor(zoom);
}
private Vector2dBounds GetScreenBounds()
{
var screenWidth = UnityEngine.Screen.width;
var screenHeight = UnityEngine.Screen.height;
var sw_world = _minicamera.ViewportToWorldPoint(new Vector3(0, 0, 180));
var sw_world = _minicamera.ViewportToWorldPoint(new Vector3(0, 0, 90));
var sw = _map.WorldToGeoPosition(sw_world);
var ne_world = _minicamera.ViewportToWorldPoint(new Vector3(1f, 1f, 180));
var ne_world = _minicamera.ViewportToWorldPoint(new Vector3(1f, 1f, 90));
var ne = _map.WorldToGeoPosition(ne_world);
return new Vector2dBounds(new Vector2d(sw.x, sw.y), new Vector2d(ne.x, ne.y));
@@ -135,16 +157,17 @@ namespace Assets.Scenes.Ride.Scripts
_mipMapRoute = new GameObject("MiniMapRoute");
_mipMapRoute.transform.parent = transform;
var lineRender = _mipMapRoute.AddComponent<LineRenderer>();
lineRender.material = new Material(Shader.Find("Sprites/Default"));
lineRender.material = Instantiate(Resources.Load<Material>("UI/Material/Round10"));
var dat = feat.Points[0];
lineRender.endColor = Color.white;
lineRender.startColor = Color.white;
//设置宽度
lineRender.startWidth = 1f;
lineRender.endWidth = 1f;
lineRender.startWidth = 5f;
lineRender.endWidth = 5f;
lineRender.positionCount = dat.Count;
lineRender.SetPositions(feat.Points[0].ToArray());
lineRender.numCornerVertices = 0;
lineRender.numCornerVertices = 60;
lineRender.loop = false;
_mipMapRoute.layer = 9;
}