在线用户和影子选手信息面板,小地图已经骑行路线
This commit is contained in:
1 parent
53ec9c60ac
commit
87d581291b
25 files changed
+4332
-3675
No files matched your search
@@ -42,6 +42,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
}
|
||||
}
|
||||
float timer = 0;
|
||||
private void Update()
|
||||
{
|
||||
if (playerController != null)
|
||||
@@ -51,8 +52,44 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
((RectTransform)tr.transform).position = _minicamera.WorldToScreenPoint(_player.transform.localPosition);
|
||||
//((RectTransform)tr).localPosition = _minicamera.WorldToViewportPoint(_player.transform.localPosition);
|
||||
}
|
||||
timer += Time.deltaTime;
|
||||
|
||||
while (timer>=1)
|
||||
{
|
||||
CreateMiniPath();
|
||||
timer = 0;
|
||||
}
|
||||
}
|
||||
private bool init = false;
|
||||
void CreateMiniPath()
|
||||
{
|
||||
if (playerController == null)
|
||||
return;
|
||||
var dat = new List<Vector3>();
|
||||
var mapData = cyclingCotroller.GetMapData();
|
||||
if (mapData != null)
|
||||
{
|
||||
var count = mapData.List.Count;
|
||||
var interval = Math.Max(Math.Ceiling(count / 100D), 1f);
|
||||
for (int i = 0; i < mapData.List.Count; i++)
|
||||
{
|
||||
if (i % interval == 0)
|
||||
{
|
||||
var point = mapData.List[i].Point;
|
||||
Vector3 item = _map.GeoToWorldPosition(new Vector2d(point[0], point[1]));
|
||||
item.y += 5f;
|
||||
if (playerController.CurrentIndex >= i-1)
|
||||
{
|
||||
dat.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
var feat = new VectorFeatureUnity();
|
||||
feat.Points.Add(dat);
|
||||
CreateRedLineRender(feat);//创建小地图路线
|
||||
}
|
||||
}
|
||||
|
||||
private bool init = false;
|
||||
private void _map_OnInitialized()
|
||||
{
|
||||
init = true;
|
||||
@@ -161,6 +198,31 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
lineRender.loop = false;
|
||||
_mipMapRoute.layer = 9;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
GameObject _mipMapPath;
|
||||
void CreateRedLineRender(VectorFeatureUnity feat)
|
||||
{
|
||||
if (_mipMapPath != null)
|
||||
{
|
||||
_mipMapPath.Destroy();
|
||||
}
|
||||
_mipMapPath = new GameObject("MiniMapPath");
|
||||
_mipMapPath.transform.parent = transform;
|
||||
var lineRender = _mipMapPath.AddComponent<LineRenderer>();
|
||||
|
||||
lineRender.material = Instantiate(Resources.Load<Material>("UI/Material/2"));
|
||||
var dat = feat.Points[0];
|
||||
lineRender.endColor = Color.red;
|
||||
lineRender.startColor = Color.red;
|
||||
//设置宽度
|
||||
lineRender.startWidth = 10f;
|
||||
lineRender.endWidth = 10f;
|
||||
lineRender.positionCount = dat.Count;
|
||||
lineRender.SetPositions(feat.Points[0].ToArray());
|
||||
lineRender.numCornerVertices = 20;
|
||||
lineRender.numCapVertices = 20;
|
||||
lineRender.loop = false;
|
||||
_mipMapPath.layer = 9;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user