继续骑行海图初始位置,地图属性调整
This commit is contained in:
1 parent
724e43f392
commit
3757ae6e6c
10 files changed
+3279
-3274
No files matched your search
@@ -14,15 +14,10 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
public PlayerController _playerController;
|
||||
RawImage head;
|
||||
GameObject headPanel;
|
||||
|
||||
Image arrowImage;
|
||||
GameObject infoPanel;
|
||||
Transform uiObject;
|
||||
|
||||
GraphChartBase graph;
|
||||
ChartDataSourceScript chartDataSourceScript;
|
||||
|
||||
string nickName;
|
||||
string weightKgStr;
|
||||
|
||||
@@ -31,15 +26,10 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
base.Init();
|
||||
currentlatlong = mainController.GetCenterCoordinate();
|
||||
_playerController = FindObjectOfType<PlayerController>();
|
||||
graph = transform.parent.Find("SingleUI/Panel/GraphChart").GetComponent<GraphChartBase>();
|
||||
chartDataSourceScript = transform.parent.Find("SingleUI/Panel/GraphChart").GetComponent<ChartDataSourceScript>();
|
||||
|
||||
//创建UI
|
||||
uiObject = transform.parent.Find("SingleUI/Panel/ArrowList");
|
||||
arrowImage = Instantiate(Resources.Load<Image>("UI/Prefab/Ride/ReviewArrow"), uiObject);
|
||||
arrowImage.color = new Color(0.1529412f, 0.8745098f, 0.8901961f);
|
||||
|
||||
|
||||
}
|
||||
public override bool GetStart()
|
||||
{
|
||||
@@ -50,80 +40,23 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
currentlatlong = mainController.Along(totalDistance);//下一个坐标
|
||||
|
||||
diff = Math.Round((totalDistance - _playerController.TotalDistance) * 1000, 0);
|
||||
|
||||
MoveHead(graph.transform);
|
||||
}
|
||||
double diff = 0;
|
||||
public void SetDataSource(double _totalDistance, double _distance,string Name,double weightKg)
|
||||
public void SetDataSource(double _totalDistance, double _distance,string Name,double weightKg,int index=0)
|
||||
{
|
||||
totalDistance = _totalDistance;
|
||||
distance = _distance;
|
||||
speed = distance*3600;
|
||||
nickName = Name;
|
||||
weightKgStr = weightKg.ToString("f2") + "W/KG";
|
||||
CurrentIndex = index;
|
||||
}
|
||||
|
||||
public int GetCurrentIndex(double endistance,MapDataModel mapDataModel)
|
||||
{
|
||||
var pointList = mapDataModel.List;
|
||||
int onIndex = 0;
|
||||
var sumDistance = 0D;
|
||||
for (int i = 0; i < pointList.Count; i++)
|
||||
{
|
||||
sumDistance += pointList[i].Distance;
|
||||
if (endistance * 1000 <= sumDistance)
|
||||
{
|
||||
onIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (endistance > mapDataModel.TotalDistance)
|
||||
{
|
||||
onIndex = pointList.Count-2;
|
||||
}
|
||||
return onIndex;
|
||||
}
|
||||
|
||||
private string headUrl;
|
||||
public void SetHead(string url )
|
||||
{
|
||||
headUrl = url;
|
||||
}
|
||||
public void MoveHead(Transform parent)
|
||||
{
|
||||
var itemIndex = chartDataSourceScript.GetViewIndex(GetCurrentIndex(TotalDistance, mainController.GetMapData()))+1;
|
||||
var m = graph.DataSource.GetPoint("Player 2", itemIndex);
|
||||
Debug.Log(itemIndex.ToString() + "=" + TotalDistance.ToString());
|
||||
graph.PointToWorldSpace(out Vector3 itemPosition, m.x, m.y, "Player 2");
|
||||
itemPosition.x -= 12f;
|
||||
itemPosition.y += 5f;
|
||||
|
||||
if (headPanel == null)
|
||||
{
|
||||
headPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Ride/OnlineHeadPanel"));
|
||||
headPanel.transform.SetParent(parent);
|
||||
headPanel.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f);
|
||||
headPanel.transform.position = itemPosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
headPanel.transform.DOMove(new Vector3(itemPosition.x, itemPosition.y, 0), 1);
|
||||
}
|
||||
if (head == null)
|
||||
{
|
||||
head = headPanel.GetComponentInChildren<RawImage>();
|
||||
if (!string.IsNullOrEmpty(headUrl))
|
||||
{
|
||||
Utils.DisplayImage(head, headUrl, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
headPanel.transform.Find("DefaultHead").gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void ShowInfoPanel(Vector3 playerScreenPos)
|
||||
{
|
||||
@@ -157,13 +90,10 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
|
||||
public void RemoveSelf()
|
||||
{
|
||||
//headPanel?.SetActive(false);
|
||||
arrowImage.gameObject?.Destroy();
|
||||
headPanel?.Destroy();
|
||||
infoPanel?.Destroy();
|
||||
transform.gameObject.Destroy();
|
||||
//infoPanel?.SetActive(false);
|
||||
//transform.DestroyChildren();
|
||||
}
|
||||
|
||||
protected override void AfterExcute()
|
||||
@@ -215,5 +145,40 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
lineRender.numCapVertices = 10;
|
||||
lineRender.numCornerVertices = 10;
|
||||
}
|
||||
|
||||
protected override void MoveGraphHead()
|
||||
{
|
||||
var itemIndex = chartDataSourceScript.GetViewIndex(CurrentIndex);
|
||||
var m = graph.DataSource.GetPoint("Player 2", itemIndex);
|
||||
|
||||
graph.PointToWorldSpace(out Vector3 itemPosition, m.x, m.y, "Player 2");
|
||||
itemPosition.x -= 12f;
|
||||
itemPosition.y += 5f;
|
||||
|
||||
if (headPanel == null)
|
||||
{
|
||||
headPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Ride/OnlineHeadPanel"));
|
||||
headPanel.transform.SetParent(graph.transform);
|
||||
headPanel.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f);
|
||||
headPanel.transform.position = itemPosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
headPanel.transform.DOMove(new Vector3(itemPosition.x, itemPosition.y, 0), 1);
|
||||
}
|
||||
|
||||
if (head == null)
|
||||
{
|
||||
head = headPanel.GetComponentInChildren<RawImage>();
|
||||
if (!string.IsNullOrEmpty(headUrl))
|
||||
{
|
||||
Utils.DisplayImage(head, headUrl, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
headPanel.transform.Find("DefaultHead").gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user