75 lines
2.3 KiB
C#
75 lines
2.3 KiB
C#
using Assets.Scenes.Ride.Scripts.Model;
|
|
using Assets.Scripts;
|
|
using DG.Tweening;
|
|
using System;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Assets.Scenes.Ride.Scripts
|
|
{
|
|
public class OnlinePlayerController : AbstractPlayer
|
|
{
|
|
public PlayerController _playerController;
|
|
RawImage head;
|
|
GameObject headPanel;
|
|
|
|
protected override void Init()
|
|
{
|
|
base.Init();
|
|
currentlatlong = mainController.GetCenterCoordinate();
|
|
_playerController = FindObjectOfType<PlayerController>();
|
|
var cuurentLocalPos = map.GeoToWorldPosition(currentlatlong);
|
|
cuurentLocalPos.y += transform.localScale.y;
|
|
transform.localPosition = cuurentLocalPos;
|
|
}
|
|
protected override bool GetStart()
|
|
{
|
|
return true;
|
|
}
|
|
protected override void Compute()
|
|
{
|
|
Debug.Log("31" + totalDistance.ToString());
|
|
currentlatlong = mainController.Along(totalDistance);//下一个坐标
|
|
}
|
|
|
|
public void SetDistance(double _distance)
|
|
{
|
|
}
|
|
|
|
public void SetTotalDistance(double _totalDistance, double _distance)
|
|
{
|
|
Debug.Log("41" + _totalDistance.ToString());
|
|
totalDistance = _totalDistance;
|
|
distance = _distance;
|
|
}
|
|
private string headUrl;
|
|
public void SetHead(string url )
|
|
{
|
|
headUrl = url;
|
|
}
|
|
public void MoveHead(Transform parent,Vector3 nextPosition)
|
|
{
|
|
if (headPanel == null)
|
|
{
|
|
headPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Ride/HeadPanel"));
|
|
headPanel.transform.parent = parent;
|
|
headPanel.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f);
|
|
}
|
|
if (head == null)
|
|
{
|
|
head = headPanel.GetComponentInChildren<RawImage>();
|
|
if (!string.IsNullOrEmpty(headUrl))
|
|
{
|
|
Utils.DisplayImage(head, headUrl, true);
|
|
}
|
|
}
|
|
headPanel.transform.DOMove(new Vector3(nextPosition.x, nextPosition.y, 0), 1);
|
|
}
|
|
|
|
public void RemoveSelf()
|
|
{
|
|
transform.gameObject.Destroy();
|
|
headPanel.Destroy();
|
|
}
|
|
}
|
|
} |