骑行部分代码重构
This commit is contained in:
parent
21d54a8a1a
commit
fa5a9961a8
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 6cae07749732f9d4aa6831e43ea65d68
|
guid: 04b83335f962c2745900aa55d8b8072c
|
||||||
PrefabImporter:
|
PrefabImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData:
|
||||||
|
|||||||
22512
Assets/Resources/UI/Prefab/Match/onlinePlayerNoScriptNv.prefab
Normal file
22512
Assets/Resources/UI/Prefab/Match/onlinePlayerNoScriptNv.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 94a353e3a43182d4c81a470b4765b1e0
|
guid: 21aee99f3e4d49040837bc6b626cac95
|
||||||
PrefabImporter:
|
PrefabImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData:
|
||||||
File diff suppressed because it is too large
Load Diff
22537
Assets/Resources/UI/Prefab/Match/onlinePlayerNv.prefab
Normal file
22537
Assets/Resources/UI/Prefab/Match/onlinePlayerNv.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 2fe2d472537f7874797d676190b7255a
|
guid: b1ca9edfdf2a0c14b9088b4d0c401294
|
||||||
PrefabImporter:
|
PrefabImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData:
|
||||||
File diff suppressed because it is too large
Load Diff
@ -51,6 +51,7 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
protected double power;
|
protected double power;
|
||||||
protected double elevation;
|
protected double elevation;
|
||||||
protected double cadance;
|
protected double cadance;
|
||||||
|
public int Sex { get; set; }
|
||||||
protected int? heartRate { get; set; }
|
protected int? heartRate { get; set; }
|
||||||
public int ticks { get; set; }
|
public int ticks { get; set; }
|
||||||
protected double totalDistance;
|
protected double totalDistance;
|
||||||
|
|||||||
@ -31,25 +31,115 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
public AbstractMap map;
|
public AbstractMap map;
|
||||||
public GameObject player { get; set; }
|
public GameObject player { get; set; }
|
||||||
public GameObject UIObject;
|
public GameObject UIObject;
|
||||||
|
public GameObject minicamera;
|
||||||
|
GameObject loadingcanvas;
|
||||||
|
GameObject miniMap { get; set; }
|
||||||
|
GameObject resultPanel;
|
||||||
|
GameObject watcher;
|
||||||
|
|
||||||
|
GameObject uipanel { get; set; }
|
||||||
|
GameObject onlineUserPrefab3d { get; set; }
|
||||||
|
GameObject onlineUserPrefab3dNv { get; set; }
|
||||||
|
GameObject OnlineHeadPanel { get; set; }
|
||||||
|
|
||||||
|
public GameObject GetOnlineheadPanel()
|
||||||
|
{
|
||||||
|
if (OnlineHeadPanel == null)
|
||||||
|
{
|
||||||
|
OnlineHeadPanel = Resources.Load<GameObject>("UI/Prefab/Ride/OnlineHeadPanel");
|
||||||
|
}
|
||||||
|
|
||||||
|
return OnlineHeadPanel;
|
||||||
|
}
|
||||||
|
|
||||||
|
Transform target;
|
||||||
|
Transform uiParent;
|
||||||
|
|
||||||
|
Material Graph3d { get; set; }
|
||||||
|
Material Graph4 { get; set; }
|
||||||
|
Material Graph1 { get; set; }
|
||||||
|
|
||||||
|
public Material Get3dGraph2()
|
||||||
|
{
|
||||||
|
if (Graph3d == null)
|
||||||
|
{
|
||||||
|
Graph3d = Resources.Load<Material>("UI/Material/3dGraph2");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Graph3d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material GetMaterial4()
|
||||||
|
{
|
||||||
|
if (Graph4 == null)
|
||||||
|
{
|
||||||
|
Graph4 = Resources.Load<Material>("UI/Material/4");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Graph4;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Material GetMaterial1()
|
||||||
|
{
|
||||||
|
if (Graph1 == null)
|
||||||
|
{
|
||||||
|
Graph1 = Resources.Load<Material>("UI/Material/1");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Graph1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Image CompetitionArrow { get; set; }
|
||||||
|
|
||||||
|
public Image GetCompetitionArrow()
|
||||||
|
{
|
||||||
|
if (CompetitionArrow == null)
|
||||||
|
{
|
||||||
|
CompetitionArrow = Resources.Load<Image>("UI/Prefab/Match/CompetitionArrow");
|
||||||
|
}
|
||||||
|
|
||||||
|
return CompetitionArrow;
|
||||||
|
}
|
||||||
|
|
||||||
|
Image CompetitionMobileArrow { get; set; }
|
||||||
|
|
||||||
|
public Image GetCompetitionMobileArrow()
|
||||||
|
{
|
||||||
|
if (CompetitionMobileArrow == null)
|
||||||
|
{
|
||||||
|
CompetitionMobileArrow = Resources.Load<Image>("UI/Prefab/Match/Mobile/CompetitionArrow");
|
||||||
|
}
|
||||||
|
|
||||||
|
return CompetitionMobileArrow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChartDataSourceScript chartDataSourceScript { get; set; }
|
||||||
|
public GraphChartBase graph { get; set; }
|
||||||
public RouteResultParam selectParamModel;
|
public RouteResultParam selectParamModel;
|
||||||
public RouteResult routeResult;
|
public RouteResult routeResult;
|
||||||
|
|
||||||
public GameObject minicamera;
|
public Dictionary<int, SeletedPlayerScript> selectPlayerDic { set; get; } =
|
||||||
|
new Dictionary<int, SeletedPlayerScript>();
|
||||||
public Dictionary<int, SeletedPlayerScript> selectPlayerDic { set; get; } = new Dictionary<int, SeletedPlayerScript>();
|
|
||||||
|
|
||||||
public int preticks { get; set; }
|
public int preticks { get; set; }
|
||||||
|
private float activeSeconds { get; set; } //移动端用户进入骑行超过2min,界面进入沉浸状态
|
||||||
|
public int RankingId;
|
||||||
|
public string recordId;
|
||||||
|
public bool RotateLock = true;
|
||||||
|
private bool touchLock = true;
|
||||||
|
|
||||||
#region 参数
|
#region 参数
|
||||||
public MapRoute mapRoute { get; set; }//当前路书数据
|
|
||||||
public MapCompetition competition { get; set; }//当前赛事数据
|
|
||||||
private MapDataModel mapData { get; set; }//当前路书数据
|
|
||||||
private Route route { get; set; }//当前路书综合数据
|
|
||||||
public List<MapRouteRanking> mapRouteRankingList { get; set; }
|
|
||||||
private Vector2d coordiantes;//当前地图中心
|
|
||||||
|
|
||||||
public bool isStart { get; set; }//当前游戏是否开始
|
public MapRoute mapRoute { get; set; } //当前路书数据
|
||||||
public CyclingModel cyclingModel { get; set; }//当前骑行模式
|
public MapCompetition competition { get; set; } //当前赛事数据
|
||||||
|
private MapDataModel mapData { get; set; } //当前路书数据
|
||||||
|
private Route route { get; set; } //当前路书综合数据
|
||||||
|
public List<MapRouteRanking> mapRouteRankingList { get; set; }
|
||||||
|
private Vector2d coordiantes; //当前地图中心
|
||||||
|
|
||||||
|
public bool isStart { get; set; } //当前游戏是否开始
|
||||||
|
public CyclingModel cyclingModel { get; set; } //当前骑行模式
|
||||||
public BaseCycling cyclingController { get; set; }
|
public BaseCycling cyclingController { get; set; }
|
||||||
private int routeId;
|
private int routeId;
|
||||||
public int competitionId { get; set; }
|
public int competitionId { get; set; }
|
||||||
@ -59,8 +149,9 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
public DateTime endTime;
|
public DateTime endTime;
|
||||||
public bool isQuit;
|
public bool isQuit;
|
||||||
public bool isPause;
|
public bool isPause;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
GameObject loadingcanvas;
|
|
||||||
AbstratctLoadingController loadingController;
|
AbstratctLoadingController loadingController;
|
||||||
|
|
||||||
private async Task Login()
|
private async Task Login()
|
||||||
@ -68,14 +159,7 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
var result = await new UserApi().Login("15261826280", "123456", "");
|
var result = await new UserApi().Login("15261826280", "123456", "");
|
||||||
App.CurrentUser = result.data;
|
App.CurrentUser = result.data;
|
||||||
}
|
}
|
||||||
GameObject miniMap { get; set; }
|
|
||||||
GameObject resultPanel;
|
|
||||||
public ChartDataSourceScript chartDataSourceScript { get; set; }
|
|
||||||
public GraphChartBase graph { get; set; }
|
|
||||||
|
|
||||||
private float activeSeconds { get; set; }//移动端用户进入骑行超过2min,界面进入沉浸状态
|
|
||||||
public int RankingId;
|
|
||||||
public string recordId;
|
|
||||||
protected override void Awake()
|
protected override void Awake()
|
||||||
{
|
{
|
||||||
base.Awake();
|
base.Awake();
|
||||||
@ -90,98 +174,29 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
mapApi = ConfigHelper.mapApi;
|
mapApi = ConfigHelper.mapApi;
|
||||||
routeId = App.RouteIdParam > 0 ? App.RouteIdParam : 2633;
|
routeId = App.RouteIdParam > 0 ? App.RouteIdParam : 2633;
|
||||||
competitionId = App.CompetionId;
|
competitionId = App.CompetionId;
|
||||||
roomId = App.gameRoomDetail?.RoomId ??0;
|
roomId = App.gameRoomDetail?.RoomId ?? 0;
|
||||||
App.CompetionId = 0;//清空比赛参数
|
App.CompetionId = 0; //清空比赛参数
|
||||||
|
|
||||||
|
HandleTempData();
|
||||||
|
CreateCurrentPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
//处理异常中断的骑行
|
//处理异常中断的骑行
|
||||||
if (App.tempRecordData != null)
|
private void HandleTempData()
|
||||||
{
|
{
|
||||||
|
if (App.tempRecordData == null) return;
|
||||||
selectParamModel = App.tempRecordData.selectParam;
|
selectParamModel = App.tempRecordData.selectParam;
|
||||||
competitionId = App.tempRecordData.CompetitionId;
|
competitionId = App.tempRecordData.CompetitionId;
|
||||||
routeId = App.tempRecordData.RouteId;
|
routeId = App.tempRecordData.RouteId;
|
||||||
}
|
}
|
||||||
CreateCurrentPlayer();
|
|
||||||
Resources.UnloadUnusedAssets();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnDestroy()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
App.RouteIdParam = 0;
|
App.RouteIdParam = 0;
|
||||||
App.tempRecordData = null;
|
App.tempRecordData = null;
|
||||||
TouchKit.removeAllGestureRecognizers();
|
TouchKit.removeAllGestureRecognizers();
|
||||||
Resources.UnloadUnusedAssets();
|
Resources.UnloadUnusedAssets();
|
||||||
}
|
}
|
||||||
Transform target;
|
|
||||||
GameObject watcher;
|
|
||||||
Transform uiParent;
|
|
||||||
|
|
||||||
GameObject uipanel { get; set; }
|
|
||||||
GameObject onlineUserPrefab3d { get; set; }
|
|
||||||
|
|
||||||
GameObject OnlineHeadPanel { get; set; }
|
|
||||||
|
|
||||||
public GameObject GetOnlineheadPanel()
|
|
||||||
{
|
|
||||||
if (OnlineHeadPanel == null)
|
|
||||||
{
|
|
||||||
OnlineHeadPanel = Resources.Load<GameObject>("UI/Prefab/Ride/OnlineHeadPanel");
|
|
||||||
}
|
|
||||||
return OnlineHeadPanel;
|
|
||||||
}
|
|
||||||
Material Graph3d { get; set; }
|
|
||||||
Material Graph4 { get; set; }
|
|
||||||
Material Graph1 { get; set; }
|
|
||||||
public Material Get3dGraph2()
|
|
||||||
{
|
|
||||||
if (Graph3d == null)
|
|
||||||
{
|
|
||||||
Graph3d = Resources.Load<Material>("UI/Material/3dGraph2");
|
|
||||||
}
|
|
||||||
return Graph3d;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Material GetMaterial4()
|
|
||||||
{
|
|
||||||
if (Graph4 == null)
|
|
||||||
{
|
|
||||||
Graph4 = Resources.Load<Material>("UI/Material/4");
|
|
||||||
}
|
|
||||||
return Graph4;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Material GetMaterial1()
|
|
||||||
{
|
|
||||||
if (Graph1 == null)
|
|
||||||
{
|
|
||||||
Graph1 = Resources.Load<Material>("UI/Material/1");
|
|
||||||
}
|
|
||||||
return Graph1;
|
|
||||||
}
|
|
||||||
|
|
||||||
Image CompetitionArrow { get; set; }
|
|
||||||
public Image GetCompetitionArrow()
|
|
||||||
{
|
|
||||||
if (CompetitionArrow == null)
|
|
||||||
{
|
|
||||||
CompetitionArrow = Resources.Load<Image>("UI/Prefab/Match/CompetitionArrow");
|
|
||||||
}
|
|
||||||
return CompetitionArrow;
|
|
||||||
}
|
|
||||||
|
|
||||||
Image CompetitionMobileArrow { get; set; }
|
|
||||||
public Image GetCompetitionMobileArrow()
|
|
||||||
{
|
|
||||||
if (CompetitionMobileArrow == null)
|
|
||||||
{
|
|
||||||
CompetitionMobileArrow = Resources.Load<Image>("UI/Prefab/Match/Mobile/CompetitionArrow");
|
|
||||||
}
|
|
||||||
return CompetitionMobileArrow;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool RotateLock = true;
|
|
||||||
|
|
||||||
private bool touchLock = true;
|
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
@ -195,6 +210,7 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
uipanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Ride/Panel"), UIObject.transform);
|
uipanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Ride/Panel"), UIObject.transform);
|
||||||
uicanvasScaler.referenceResolution = App.PcResolution;
|
uicanvasScaler.referenceResolution = App.PcResolution;
|
||||||
loadingcanvasScaler.referenceResolution = App.PcResolution;
|
loadingcanvasScaler.referenceResolution = App.PcResolution;
|
||||||
|
|
||||||
var modalRect = transform.Find("UI/ModalPanel").GetComponent<RectTransform>();
|
var modalRect = transform.Find("UI/ModalPanel").GetComponent<RectTransform>();
|
||||||
modalRect.anchorMin = new Vector2(0.5f, 0.5f);
|
modalRect.anchorMin = new Vector2(0.5f, 0.5f);
|
||||||
modalRect.anchorMax = new Vector2(0.5f, 0.5f);
|
modalRect.anchorMax = new Vector2(0.5f, 0.5f);
|
||||||
@ -213,17 +229,75 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
|
|
||||||
UIManager.Instance.MainPanel = uipanel.GetComponent<PFUIPanel>();
|
UIManager.Instance.MainPanel = uipanel.GetComponent<PFUIPanel>();
|
||||||
UIManager.Instance.ModalsPanel = this.transform.Find("UI/ModalPanel").GetComponent<PFUIPanel>();
|
UIManager.Instance.ModalsPanel = this.transform.Find("UI/ModalPanel").GetComponent<PFUIPanel>();
|
||||||
|
|
||||||
onlineUserPrefab = Resources.Load<GameObject>("UI/Prefab/Ride/EmptyOnlinePlayer");
|
onlineUserPrefab = Resources.Load<GameObject>("UI/Prefab/Ride/EmptyOnlinePlayer");
|
||||||
onlineUserPrefab3d = Resources.Load<GameObject>("UI/Prefab/Match/onlinePlayerNoScript");
|
onlineUserPrefab3d = Resources.Load<GameObject>("UI/Prefab/Match/onlinePlayerNoScript");
|
||||||
|
onlineUserPrefab3dNv = Resources.Load<GameObject>("UI/Prefab/Match/onlinePlayerNoScriptNv");
|
||||||
|
|
||||||
miniMapPlayerPrefab = Resources.Load<GameObject>("UI/Prefab/Ride/MiniMapPlayer");
|
miniMapPlayerPrefab = Resources.Load<GameObject>("UI/Prefab/Ride/MiniMapPlayer");
|
||||||
watcher = Resources.Load<GameObject>("UI/Prefab/Match/Watcher");
|
watcher = Resources.Load<GameObject>("UI/Prefab/Match/Watcher");
|
||||||
target = transform.Find("Target");
|
target = transform.Find("Target");
|
||||||
miniMap = transform.Find("MiniMap").gameObject;//小地图
|
miniMap = transform.Find("MiniMap").gameObject; //小地图
|
||||||
minicamera = transform.Find("MiniCamera").gameObject;
|
minicamera = transform.Find("MiniCamera").gameObject;
|
||||||
//进入倒计时
|
//进入倒计时
|
||||||
singleUIManager = UIObject.GetComponent<BaseUIManager>();
|
singleUIManager = UIObject.GetComponent<BaseUIManager>();
|
||||||
|
SceneManager.activeSceneChanged += SceneManager_activeSceneChanged;
|
||||||
|
|
||||||
|
InitLoading();
|
||||||
|
HandleTouchAndInput();
|
||||||
|
StartCoroutine(Ping());
|
||||||
|
HandleRideMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
float timer = 1f;
|
||||||
|
bool clearLock = false;
|
||||||
|
bool _dragStartedOnUI = false;
|
||||||
|
float touchTimer = 0.1f;
|
||||||
|
public bool isWatch { get; set; }
|
||||||
|
private Vector3 currentCameraPos { get; set; }
|
||||||
|
Vector3 far = new Vector3(-17, 52, -48);
|
||||||
|
Vector3 medium = new Vector3(-14.5f, 45, -40);
|
||||||
|
Vector3 plane = new Vector3(-10.5f, 35, -30); //new Vector3(-11.4f, 31, -30);
|
||||||
|
Vector3 near = new Vector3(-7.3f, 24, -20);
|
||||||
|
Vector3 neareast = new Vector3(-5.4f, 18, -15);
|
||||||
|
List<Vector3> cameraList { get; set; }
|
||||||
|
DateTime startTimpStamp = DateTime.Now;
|
||||||
|
PlayerController playerController;
|
||||||
|
public AbstractPlayer currentPlayer { get; set; }
|
||||||
|
private GameObject onlinePlayer { get; set; }
|
||||||
|
private Vector3 mapPos = Vector3.zero;
|
||||||
|
Vector3 MAX_SIZE = new Vector3(3f, 3f, 3f);
|
||||||
|
Vector3 MIN_SIZE = new Vector3(0.1f, 0.1f, 0.1f);
|
||||||
|
public BaseUIManager singleUIManager;
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
timer -= Time.deltaTime;
|
||||||
|
|
||||||
|
if (timer <= 0)
|
||||||
|
{
|
||||||
|
TcpHandler();
|
||||||
|
App.CurrentScene = "Ride";
|
||||||
|
if (competitionId == 0)
|
||||||
|
{
|
||||||
|
UIManager.SendCompetitionStartMessage("Ride");
|
||||||
|
}
|
||||||
|
|
||||||
|
timer += 1.0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FixedUpdate()
|
||||||
|
{
|
||||||
|
HandleTouch();
|
||||||
|
HandleMouseScrollWheel();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitLoading()
|
||||||
|
{
|
||||||
if (competitionId > 0)
|
if (competitionId > 0)
|
||||||
{
|
{
|
||||||
loadingController = transform.Find("LoadingCanvas").gameObject.AddComponent<CompetitionLoadingController>();
|
loadingController = transform.Find("LoadingCanvas").gameObject.AddComponent<CompetitionLoadingController>();
|
||||||
@ -233,14 +307,14 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
loadingController = transform.Find("LoadingCanvas").gameObject.AddComponent<LoadingController>();
|
loadingController = transform.Find("LoadingCanvas").gameObject.AddComponent<LoadingController>();
|
||||||
}
|
}
|
||||||
|
|
||||||
//loadingController = FindObjectOfType<LoadingController>();
|
|
||||||
//
|
|
||||||
loadingController.InjectController(this);
|
loadingController.InjectController(this);
|
||||||
|
}
|
||||||
|
|
||||||
SceneManager.activeSceneChanged += SceneManager_activeSceneChanged;
|
/// <summary>
|
||||||
|
/// 设置当前骑行的模式
|
||||||
HandleTouchAndInput();
|
/// </summary>
|
||||||
StartCoroutine(Ping());
|
private void HandleRideMode()
|
||||||
|
{
|
||||||
//进入对战房间
|
//进入对战房间
|
||||||
if (App.gameRoomDetail != null)
|
if (App.gameRoomDetail != null)
|
||||||
{
|
{
|
||||||
@ -248,17 +322,18 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
StartCoroutine(InitGameRoom());
|
StartCoroutine(InitGameRoom());
|
||||||
}
|
}
|
||||||
//进入比赛
|
//进入比赛
|
||||||
else if(competitionId > 0)
|
else if (competitionId > 0)
|
||||||
{
|
{
|
||||||
this.cyclingModel = CyclingModel.Competition;
|
this.cyclingModel = CyclingModel.Competition;
|
||||||
StartCoroutine(InitRace());
|
StartCoroutine(InitRace());
|
||||||
}
|
}
|
||||||
//进入单人骑行
|
//进入单人骑行
|
||||||
else if(routeId > 0)
|
else if (routeId > 0)
|
||||||
{
|
{
|
||||||
StartCoroutine(Init());
|
StartCoroutine(Init());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerator Ping()
|
private IEnumerator Ping()
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
@ -268,14 +343,13 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float timer = 1f;
|
|
||||||
bool clearLock = false;
|
|
||||||
|
|
||||||
private void SceneManager_activeSceneChanged(Scene arg0, Scene arg1)
|
private void SceneManager_activeSceneChanged(Scene arg0, Scene arg1)
|
||||||
{
|
{
|
||||||
ClearTempFile();
|
ClearTempFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 手势移动&PC鼠标的控制
|
#region 手势移动&PC鼠标的控制
|
||||||
|
|
||||||
private void HandleTouchAndInput()
|
private void HandleTouchAndInput()
|
||||||
{
|
{
|
||||||
var rotationRecognizer = new TKOneFingerRotationRecognizer
|
var rotationRecognizer = new TKOneFingerRotationRecognizer
|
||||||
@ -302,7 +376,8 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
timer.Stop();
|
timer.Stop();
|
||||||
};
|
};
|
||||||
|
|
||||||
rotationRecognizer.gestureCompleteEvent += (r) => {
|
rotationRecognizer.gestureCompleteEvent += (r) =>
|
||||||
|
{
|
||||||
UnityEngine.Debug.Log("gestureCompleteEvent");
|
UnityEngine.Debug.Log("gestureCompleteEvent");
|
||||||
timer.Start();
|
timer.Start();
|
||||||
};
|
};
|
||||||
@ -345,6 +420,7 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
cameraList.Add(medium);
|
cameraList.Add(medium);
|
||||||
cameraList.Add(far);
|
cameraList.Add(far);
|
||||||
}
|
}
|
||||||
|
|
||||||
var prePos = Camera.main.transform.localPosition;
|
var prePos = Camera.main.transform.localPosition;
|
||||||
var nextPos = Camera.main.transform.localPosition;
|
var nextPos = Camera.main.transform.localPosition;
|
||||||
if (r.deltaScale < 0)
|
if (r.deltaScale < 0)
|
||||||
@ -354,6 +430,7 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
Camera.main.transform.DOLocalMove(nextPos, 0.5f);
|
Camera.main.transform.DOLocalMove(nextPos, 0.5f);
|
||||||
//StartCoroutine(MoveCamera(prePos, nextPos));
|
//StartCoroutine(MoveCamera(prePos, nextPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r.deltaScale > 0)
|
if (r.deltaScale > 0)
|
||||||
{
|
{
|
||||||
nextPos = cameraList.Where(c => c.y < Camera.main.transform.localPosition.y).LastOrDefault();
|
nextPos = cameraList.Where(c => c.y < Camera.main.transform.localPosition.y).LastOrDefault();
|
||||||
@ -365,6 +442,7 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
};
|
};
|
||||||
TouchKit.addGestureRecognizer(PinchRecognizer);
|
TouchKit.addGestureRecognizer(PinchRecognizer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检测是否点击UI
|
/// 检测是否点击UI
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -380,7 +458,9 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
EventSystem.current.RaycastAll(eventData, raycastResults);
|
EventSystem.current.RaycastAll(eventData, raycastResults);
|
||||||
if (raycastResults.Count > 0)
|
if (raycastResults.Count > 0)
|
||||||
{
|
{
|
||||||
return !raycastResults.Where(c => c.gameObject.name == "NearPanel" || c.gameObject.name == "ToolBarPanel" || c.gameObject.name == "SettingPanel" || c.gameObject.name == "QuitPanel").Any();
|
return !raycastResults.Where(c =>
|
||||||
|
c.gameObject.name == "NearPanel" || c.gameObject.name == "ToolBarPanel" ||
|
||||||
|
c.gameObject.name == "SettingPanel" || c.gameObject.name == "QuitPanel").Any();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -389,52 +469,6 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
bool _dragStartedOnUI = false;
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
//CamControl();
|
|
||||||
timer -= Time.deltaTime;
|
|
||||||
if (timer <= 0)//定时器 一秒执行一次
|
|
||||||
{
|
|
||||||
TcpHandler();
|
|
||||||
App.CurrentScene = "Ride";
|
|
||||||
if (competitionId == 0)
|
|
||||||
{
|
|
||||||
UIManager.SendCompetitionStartMessage("Ride");
|
|
||||||
}
|
|
||||||
#if UNITY_IOS || UNITY_ANDROID
|
|
||||||
//if (isStart)
|
|
||||||
//{
|
|
||||||
// activeSeconds++;
|
|
||||||
//}
|
|
||||||
//if (activeSeconds >= App.autoClearTimes && !clearLock)
|
|
||||||
//{
|
|
||||||
// if (competitionId == 0)
|
|
||||||
// {
|
|
||||||
// clearLock = true;
|
|
||||||
// singleUIManager?.ClearPanel(null);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
#endif
|
|
||||||
timer += 1.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
float touchTimer = 0.1f;
|
|
||||||
private void FixedUpdate()
|
|
||||||
{
|
|
||||||
HandleTouch();
|
|
||||||
HandleMouseScrollWheel();
|
|
||||||
}
|
|
||||||
public bool isWatch { get; set; }
|
|
||||||
private Vector3 currentCameraPos { get; set; }
|
|
||||||
|
|
||||||
Vector3 far = new Vector3(-17, 52, -48);
|
|
||||||
Vector3 medium = new Vector3(-14.5f, 45, -40);
|
|
||||||
Vector3 plane = new Vector3(-10.5f, 35, -30); //new Vector3(-11.4f, 31, -30);
|
|
||||||
Vector3 near = new Vector3(-7.3f, 24, -20);
|
|
||||||
Vector3 neareast = new Vector3(-5.4f, 18, -15);
|
|
||||||
List<Vector3> cameraList { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 处理PC端
|
/// 处理PC端
|
||||||
@ -454,6 +488,7 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
cameraList.Add(medium);
|
cameraList.Add(medium);
|
||||||
cameraList.Add(far);
|
cameraList.Add(far);
|
||||||
}
|
}
|
||||||
|
|
||||||
var prePos = Camera.main.transform.localPosition;
|
var prePos = Camera.main.transform.localPosition;
|
||||||
var nextPos = Camera.main.transform.localPosition;
|
var nextPos = Camera.main.transform.localPosition;
|
||||||
if (scrollDelta < 0)
|
if (scrollDelta < 0)
|
||||||
@ -473,7 +508,6 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DateTime startTimpStamp = DateTime.Now;
|
|
||||||
private void HandleTouch()
|
private void HandleTouch()
|
||||||
{
|
{
|
||||||
if (singleUIManager == null)
|
if (singleUIManager == null)
|
||||||
@ -484,18 +518,20 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
UnityEngine.Debug.Log(Input.touches[0]);
|
UnityEngine.Debug.Log(Input.touches[0]);
|
||||||
UnityEngine.Debug.Log($"{Input.touches[0]}{Input.touches[0].phase }");
|
UnityEngine.Debug.Log($"{Input.touches[0]}{Input.touches[0].phase}");
|
||||||
if (Input.touches[0].tapCount == 1 && Input.touches[0].phase == TouchPhase.Began && isStart && singleUIManager.clearLock && competitionId == 0)
|
if (Input.touches[0].tapCount == 1 && Input.touches[0].phase == TouchPhase.Began && isStart &&
|
||||||
|
singleUIManager.clearLock && competitionId == 0)
|
||||||
{
|
{
|
||||||
startTimpStamp = DateTime.Now;
|
startTimpStamp = DateTime.Now;
|
||||||
}
|
}
|
||||||
|
|
||||||
//单击切换极简模式
|
//单击切换极简模式
|
||||||
if (Input.touches[0].tapCount==1 && Input.touches[0].phase == TouchPhase.Ended && isStart && singleUIManager.clearLock && competitionId == 0)
|
if (Input.touches[0].tapCount == 1 && Input.touches[0].phase == TouchPhase.Ended && isStart &&
|
||||||
|
singleUIManager.clearLock && competitionId == 0)
|
||||||
{
|
{
|
||||||
var interval = DateTime.Now - startTimpStamp;
|
var interval = DateTime.Now - startTimpStamp;
|
||||||
UnityEngine.Debug.Log(interval);
|
UnityEngine.Debug.Log(interval);
|
||||||
if (interval.TotalMilliseconds<=150 && IsPointerOverGameObject(Input.mousePosition))
|
if (interval.TotalMilliseconds <= 150 && IsPointerOverGameObject(Input.mousePosition))
|
||||||
{
|
{
|
||||||
singleUIManager?.ClearPanel(null);
|
singleUIManager?.ClearPanel(null);
|
||||||
}
|
}
|
||||||
@ -526,6 +562,7 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
cameraList.Add(plane);
|
cameraList.Add(plane);
|
||||||
cameraList.Add(far);
|
cameraList.Add(far);
|
||||||
}
|
}
|
||||||
|
|
||||||
var prePos = Camera.main.transform.localPosition;
|
var prePos = Camera.main.transform.localPosition;
|
||||||
var nextPos = Camera.main.transform.localPosition;
|
var nextPos = Camera.main.transform.localPosition;
|
||||||
if (offset < 0)
|
if (offset < 0)
|
||||||
@ -535,6 +572,7 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
Camera.main.transform.DOLocalMove(nextPos, 0.5f);
|
Camera.main.transform.DOLocalMove(nextPos, 0.5f);
|
||||||
//StartCoroutine(MoveCamera(prePos, nextPos));
|
//StartCoroutine(MoveCamera(prePos, nextPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
{
|
{
|
||||||
nextPos = cameraList.Where(c => c.y < Camera.main.transform.localPosition.y).LastOrDefault();
|
nextPos = cameraList.Where(c => c.y < Camera.main.transform.localPosition.y).LastOrDefault();
|
||||||
@ -562,18 +600,19 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
coordiantes = Along(App.tempRecordData.EndDistance);
|
coordiantes = Along(App.tempRecordData.EndDistance);
|
||||||
startTime = App.tempRecordData.StartTime;
|
startTime = App.tempRecordData.StartTime;
|
||||||
preticks = recorderData.RiderDatas.Last().Ticks;
|
preticks = recorderData.RiderDatas.Last().Ticks;
|
||||||
App.tempRecordData = null;//清空
|
App.tempRecordData = null; //清空
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerator Init()
|
private IEnumerator Init()
|
||||||
{
|
{
|
||||||
yield return null;
|
yield return null;
|
||||||
mapRoute = mapApi.GetById(routeId).data;
|
mapRoute = mapApi.GetById(routeId).data;
|
||||||
loadingController.Init();//初始化loading页面
|
loadingController.Init(); //初始化loading页面
|
||||||
loadingController.AddProcess(10);
|
loadingController.AddProcess(10);
|
||||||
InitData();//初始化数据
|
InitData(); //初始化数据
|
||||||
InitGameObject();//初始化场景
|
InitGameObject(); //初始化场景
|
||||||
MapUDPService.Init();//初始化TCP
|
MapUDPService.Init(); //初始化TCP
|
||||||
loadingController.AddProcess(10);
|
loadingController.AddProcess(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,36 +631,39 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
//初始比赛
|
//初始比赛
|
||||||
private IEnumerator InitRace()
|
private IEnumerator InitRace()
|
||||||
{
|
{
|
||||||
yield return null;//new WaitForSeconds(1);
|
yield return null; //new WaitForSeconds(1);
|
||||||
UnityEngine.Debug.Log($"TEST:{routeId}");
|
UnityEngine.Debug.Log($"TEST:{routeId}");
|
||||||
mapRoute = mapApi.GetById(routeId).data;
|
mapRoute = mapApi.GetById(routeId).data;
|
||||||
|
|
||||||
var mapCompetitionApi = new MapCompetitionApi();
|
var mapCompetitionApi = new MapCompetitionApi();
|
||||||
competition = mapCompetitionApi.GetById(competitionId).data;
|
competition = mapCompetitionApi.GetById(competitionId).data;
|
||||||
loadingController.Init();//初始化loading页面
|
loadingController.Init(); //初始化loading页面
|
||||||
loadingController.AddProcess(10);
|
loadingController.AddProcess(10);
|
||||||
InitRaceData();//初始化比赛数据
|
InitRaceData(); //初始化比赛数据
|
||||||
InitRaceGameObject();//初始化比赛场景
|
InitRaceGameObject(); //初始化比赛场景
|
||||||
//MapUDPService.Init(competitionId,isWatch);//初始化比赛TCP
|
//MapUDPService.Init(competitionId,isWatch);//初始化比赛TCP
|
||||||
loadingController.AddProcess(10);
|
loadingController.AddProcess(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitTcp()
|
public void InitTcp()
|
||||||
{
|
{
|
||||||
MapUDPService.Init(competitionId, isWatch);//初始化比赛TCP
|
MapUDPService.Init(competitionId, isWatch); //初始化比赛TCP
|
||||||
}
|
}
|
||||||
|
|
||||||
//初始化数据
|
//初始化数据
|
||||||
private void InitData()
|
private void InitData()
|
||||||
{
|
{
|
||||||
mapData = mapApi.GetData(routeId);//获取路书地理数据
|
mapData = mapApi.GetData(routeId); //获取路书地理数据
|
||||||
route = new Route(mapData, mapRoute);
|
route = new Route(mapData, mapRoute);
|
||||||
loadingController.AddProcess(10);
|
loadingController.AddProcess(10);
|
||||||
|
|
||||||
#region 其他场景传参处理
|
#region 其他场景传参处理
|
||||||
|
|
||||||
//骑行结果
|
//骑行结果
|
||||||
if (App.routeResult != null)
|
if (App.routeResult != null)
|
||||||
{
|
{
|
||||||
routeResult = App.routeResult;
|
routeResult = App.routeResult;
|
||||||
selectParamModel = App.routeResult.ContinueCyclingParam;//继续骑行
|
selectParamModel = App.routeResult.ContinueCyclingParam; //继续骑行
|
||||||
preticks = App.routeResult.Ticks;
|
preticks = App.routeResult.Ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -656,10 +698,12 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
|
|
||||||
private void InitGameRoomData()
|
private void InitGameRoomData()
|
||||||
{
|
{
|
||||||
mapData = mapApi.GetData(routeId);//获取路书地理数据
|
mapData = mapApi.GetData(routeId); //获取路书地理数据
|
||||||
route = new Route(mapData, mapRoute);
|
route = new Route(mapData, mapRoute);
|
||||||
loadingController.AddProcess(10);
|
loadingController.AddProcess(10);
|
||||||
|
|
||||||
#region 其他场景传参处理
|
#region 其他场景传参处理
|
||||||
|
|
||||||
selectParamModel = new RouteResultParam
|
selectParamModel = new RouteResultParam
|
||||||
{
|
{
|
||||||
CompetitionId = 0,
|
CompetitionId = 0,
|
||||||
@ -673,6 +717,7 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
double endDistance = selectParamModel.EndDistance;
|
double endDistance = selectParamModel.EndDistance;
|
||||||
//计算上次骑行距离调整地图中心点
|
//计算上次骑行距离调整地图中心点
|
||||||
coordiantes = Along(endDistance);
|
coordiantes = Along(endDistance);
|
||||||
@ -680,10 +725,12 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
|
|
||||||
private void InitRaceData()
|
private void InitRaceData()
|
||||||
{
|
{
|
||||||
mapData = mapApi.GetData(routeId);//获取路书地理数据
|
mapData = mapApi.GetData(routeId); //获取路书地理数据
|
||||||
route = new Route(mapData, mapRoute);
|
route = new Route(mapData, mapRoute);
|
||||||
loadingController.AddProcess(10);
|
loadingController.AddProcess(10);
|
||||||
|
|
||||||
#region 其他场景传参处理
|
#region 其他场景传参处理
|
||||||
|
|
||||||
selectParamModel = new RouteResultParam
|
selectParamModel = new RouteResultParam
|
||||||
{
|
{
|
||||||
CompetitionId = competitionId,
|
CompetitionId = competitionId,
|
||||||
@ -697,12 +744,12 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
double endDistance = selectParamModel.EndDistance;
|
double endDistance = selectParamModel.EndDistance;
|
||||||
//计算上次骑行距离调整地图中心点
|
//计算上次骑行距离调整地图中心点
|
||||||
coordiantes = Along(endDistance);
|
coordiantes = Along(endDistance);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector3 mapPos = Vector3.zero;
|
|
||||||
//加载人物和地图以及UI界面
|
//加载人物和地图以及UI界面
|
||||||
private void InitGameObject()
|
private void InitGameObject()
|
||||||
{
|
{
|
||||||
@ -717,6 +764,7 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
map.OnTileFinished += Map_OnTileFinished;
|
map.OnTileFinished += Map_OnTileFinished;
|
||||||
mapPos = map.transform.position;
|
mapPos = map.transform.position;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitGameRoomObject()
|
private void InitGameRoomObject()
|
||||||
{
|
{
|
||||||
#if !(UNITY_IOS || UNITY_ANDROID)
|
#if !(UNITY_IOS || UNITY_ANDROID)
|
||||||
@ -761,17 +809,19 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
map.SetExtent(MapExtentType.RangeAroundTransform, options);
|
map.SetExtent(MapExtentType.RangeAroundTransform, options);
|
||||||
map.SetExtentOptions(options);
|
map.SetExtentOptions(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
//根据性别创建当前骑手
|
//根据性别创建当前骑手
|
||||||
private void CreateCurrentPlayer()
|
private void CreateCurrentPlayer()
|
||||||
{
|
{
|
||||||
if (App.CurrentUser.Sex == 1)
|
if (App.CurrentUser.Sex == 1)
|
||||||
{
|
{
|
||||||
player = Instantiate<GameObject>(Resources.Load<GameObject>("UI/Prefab/Ride/Player"),transform);
|
player = Instantiate<GameObject>(Resources.Load<GameObject>("UI/Prefab/Ride/Player"), transform);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
player = Instantiate<GameObject>(Resources.Load<GameObject>("UI/Prefab/Ride/Player_NV"), transform);
|
player = Instantiate<GameObject>(Resources.Load<GameObject>("UI/Prefab/Ride/Player_NV"), transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
TrailRenderer trail = player.GetComponent<TrailRenderer>();
|
TrailRenderer trail = player.GetComponent<TrailRenderer>();
|
||||||
trail.Clear();
|
trail.Clear();
|
||||||
playerController = player.GetComponent<PlayerController>();
|
playerController = player.GetComponent<PlayerController>();
|
||||||
@ -797,16 +847,11 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
cyclingController = new GameModel(route, selectParamModel);
|
cyclingController = new GameModel(route, selectParamModel);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameStart();
|
GameStart();
|
||||||
InitPlayer();//初始化人物方向等
|
InitPlayer(); //初始化人物方向等
|
||||||
}
|
}
|
||||||
PlayerController playerController;
|
|
||||||
public AbstractPlayer currentPlayer { get; set; }
|
|
||||||
|
|
||||||
private GameObject onlinePlayer { get; set; }
|
|
||||||
|
|
||||||
Vector3 MAX_SIZE = new Vector3(3f, 3f, 3f);
|
|
||||||
Vector3 MIN_SIZE = new Vector3(0.1f, 0.1f, 0.1f);
|
|
||||||
public void ChangeCurrentPlayer(int userId)
|
public void ChangeCurrentPlayer(int userId)
|
||||||
{
|
{
|
||||||
var coll = FindObjectsOfType<AbstractPlayer>();
|
var coll = FindObjectsOfType<AbstractPlayer>();
|
||||||
@ -821,7 +866,7 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var selectedPlayer = coll.Where(c => c.UserId == userId).FirstOrDefault();
|
var selectedPlayer = coll.FirstOrDefault(c => c.UserId == userId);
|
||||||
if (selectedPlayer != null)
|
if (selectedPlayer != null)
|
||||||
{
|
{
|
||||||
currentPlayer = selectedPlayer;
|
currentPlayer = selectedPlayer;
|
||||||
@ -832,17 +877,19 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Utils.DestroyChildren(selectedPlayer.transform);
|
Utils.DestroyChildren(selectedPlayer.transform);
|
||||||
var ss = Instantiate(onlineUserPrefab3d, selectedPlayer.transform);
|
var currentOnlinePrefab = selectedPlayer.Sex == 1 ? onlineUserPrefab3d : onlineUserPrefab3dNv;
|
||||||
ss.transform.localScale = new Vector3(1f, 1f, 1f);
|
var onlineGameObject = Instantiate(currentOnlinePrefab, selectedPlayer.transform);
|
||||||
|
onlineGameObject.transform.localScale = new Vector3(1f, 1f, 1f);
|
||||||
selectedPlayer.transform.localScale = Is3dView ? MAX_SIZE : MIN_SIZE;
|
selectedPlayer.transform.localScale = Is3dView ? MAX_SIZE : MIN_SIZE;
|
||||||
selectedPlayer.UpdateAnimator();
|
selectedPlayer.UpdateAnimator();
|
||||||
selectedPlayer.UserId = userId;
|
selectedPlayer.UserId = userId;
|
||||||
}
|
}
|
||||||
Vector2d nextLatLon = Along(selectedPlayer.TotalDistance + 0.1);
|
|
||||||
|
var nextLatLon = Along(selectedPlayer.TotalDistance + 0.1);
|
||||||
//设定人物方向
|
//设定人物方向
|
||||||
var s = map.GeoToWorldPosition(selectedPlayer.Currentlatlong);
|
var s = map.GeoToWorldPosition(selectedPlayer.Currentlatlong);
|
||||||
var e = map.GeoToWorldPosition(nextLatLon);
|
var e = map.GeoToWorldPosition(nextLatLon);
|
||||||
Quaternion neededRotation = Quaternion.LookRotation(e - s);
|
var neededRotation = Quaternion.LookRotation(e - s);
|
||||||
selectedPlayer.transform.rotation = Quaternion.Euler(0, neededRotation.eulerAngles.y, 0);
|
selectedPlayer.transform.rotation = Quaternion.Euler(0, neededRotation.eulerAngles.y, 0);
|
||||||
selectedPlayer.currentRotation = neededRotation;
|
selectedPlayer.currentRotation = neededRotation;
|
||||||
}
|
}
|
||||||
@ -852,10 +899,9 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
graph.HorizontalScrolling = chartDataSourceScript.GetCurrentStart(currentIndex);
|
graph.HorizontalScrolling = chartDataSourceScript.GetCurrentStart(currentIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
//初始化人物位置角度
|
|
||||||
private void InitPlayer()
|
private void InitPlayer()
|
||||||
{
|
{
|
||||||
TempFileHandler();//处理中断骑行继续骑的逻辑
|
TempFileHandler(); //处理中断骑行继续骑的逻辑
|
||||||
lockView = true;
|
lockView = true;
|
||||||
|
|
||||||
Vector2d lastLatLon = Along(recorderData.EndDistance);
|
Vector2d lastLatLon = Along(recorderData.EndDistance);
|
||||||
@ -884,20 +930,21 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
{
|
{
|
||||||
tick = recorderData.RiderDatas.Last().Ticks;
|
tick = recorderData.RiderDatas.Last().Ticks;
|
||||||
}
|
}
|
||||||
|
|
||||||
//对战模式重连秒数按照现在的日期减去对战开始的日期
|
//对战模式重连秒数按照现在的日期减去对战开始的日期
|
||||||
if (recorderData.RoomId > 0 && recorderData.RiderDatas.Count > 0)
|
if (recorderData.RoomId > 0 && recorderData.RiderDatas.Count > 0)
|
||||||
{
|
{
|
||||||
tick = (int)(UIManager.Now.GetDateTime() - startTime).TotalSeconds;
|
tick = (int)(UIManager.Now.GetDateTime() - startTime).TotalSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
playerController.Init(index, recorderData.EndDistance, tick);
|
playerController.Init(index, recorderData.EndDistance, tick);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitGraph(int index)
|
public void InitGraph(int index)
|
||||||
{
|
{
|
||||||
chartDataSourceScript.InitHorizontalScrolling(index);
|
chartDataSourceScript.InitHorizontalScrolling(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
//SingleUIManager singleUIManager;
|
|
||||||
public BaseUIManager singleUIManager;
|
|
||||||
public void GameStart()
|
public void GameStart()
|
||||||
{
|
{
|
||||||
Camera.main.transform.DOLocalMove(near, 1f);
|
Camera.main.transform.DOLocalMove(near, 1f);
|
||||||
@ -917,15 +964,18 @@ public BaseUIManager singleUIManager;
|
|||||||
transform.Find("UI/Panel(Clone)/ToolBarPanel/StartOrPauseButton").GetComponent<Button>().enabled = false;
|
transform.Find("UI/Panel(Clone)/ToolBarPanel/StartOrPauseButton").GetComponent<Button>().enabled = false;
|
||||||
transform.Find("UI/Panel(Clone)/ToolBarPanel/SettingButton").GetComponent<Button>().enabled = false;
|
transform.Find("UI/Panel(Clone)/ToolBarPanel/SettingButton").GetComponent<Button>().enabled = false;
|
||||||
Utils.showToast(null, "Please connect the device!", duration: int.MaxValue, isLowest: true
|
Utils.showToast(null, "Please connect the device!", duration: int.MaxValue, isLowest: true
|
||||||
, stopFunc: () => isWatch || CheckAnt() || transform.Find("UI/Panel(Clone)/SelectPlayer").gameObject.activeInHierarchy
|
, stopFunc: () =>
|
||||||
|
isWatch || CheckAnt() || transform.Find("UI/Panel(Clone)/SelectPlayer").gameObject.activeInHierarchy
|
||||||
, endCallback: () =>
|
, endCallback: () =>
|
||||||
{
|
{
|
||||||
if (!transform.Find("UI/Panel(Clone)/SelectPlayer").gameObject.activeInHierarchy)
|
if (!transform.Find("UI/Panel(Clone)/SelectPlayer").gameObject.activeInHierarchy)
|
||||||
{
|
{
|
||||||
UIManager.Instance.DevicePanel.Close();
|
UIManager.Instance.DevicePanel.Close();
|
||||||
singleUIManager.StartRide();
|
singleUIManager.StartRide();
|
||||||
transform.Find("UI/Panel(Clone)/ToolBarPanel/StartOrPauseButton").GetComponent<Button>().enabled = true;
|
transform.Find("UI/Panel(Clone)/ToolBarPanel/StartOrPauseButton").GetComponent<Button>()
|
||||||
transform.Find("UI/Panel(Clone)/ToolBarPanel/SettingButton").GetComponent<Button>().enabled = true;
|
.enabled = true;
|
||||||
|
transform.Find("UI/Panel(Clone)/ToolBarPanel/SettingButton").GetComponent<Button>().enabled =
|
||||||
|
true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -938,26 +988,20 @@ public BaseUIManager singleUIManager;
|
|||||||
|
|
||||||
#region TCP相关
|
#region TCP相关
|
||||||
|
|
||||||
public void TcpHandler()
|
|
||||||
{
|
|
||||||
if (cyclingController != null)
|
|
||||||
{
|
|
||||||
////tcp数据传输
|
|
||||||
//if (competition != null && !cyclingController.recorderData.Saved)
|
|
||||||
//{
|
|
||||||
// cyclingController.recorderData.Saved = competition.HasRecord;
|
|
||||||
//}
|
|
||||||
cyclingController.Run(null);
|
|
||||||
//在线人物或比赛人物渲染
|
|
||||||
ShowOnlineUsers();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
List<OnlinePlayerController> otherList = new List<OnlinePlayerController>();
|
List<OnlinePlayerController> otherList = new List<OnlinePlayerController>();
|
||||||
GameObject onlineUserPrefab;
|
GameObject onlineUserPrefab;
|
||||||
GameObject miniMapPlayerPrefab;
|
GameObject miniMapPlayerPrefab;
|
||||||
|
|
||||||
int messageIndex = 0;
|
int messageIndex = 0;
|
||||||
|
|
||||||
|
private void TcpHandler()
|
||||||
|
{
|
||||||
|
if (cyclingController == null) return;
|
||||||
|
|
||||||
|
cyclingController.Run(null);
|
||||||
|
|
||||||
|
ShowOnlineUsers();
|
||||||
|
}
|
||||||
|
|
||||||
private void ShowOnlineUsers()
|
private void ShowOnlineUsers()
|
||||||
{
|
{
|
||||||
var onlineRiders = cyclingController.riders;
|
var onlineRiders = cyclingController.riders;
|
||||||
@ -966,78 +1010,118 @@ public BaseUIManager singleUIManager;
|
|||||||
foreach (var item in onlineRiders)
|
foreach (var item in onlineRiders)
|
||||||
{
|
{
|
||||||
var onlineRider = item as OnlineRiderModel;
|
var onlineRider = item as OnlineRiderModel;
|
||||||
var currentUser = currentOnlineUserList.Where(c => c.UserId == item.UserId).FirstOrDefault();
|
var currentUser = currentOnlineUserList.FirstOrDefault(c => c.UserId == item.UserId);
|
||||||
var onlineDistance = onlineRider.EndDistance - onlineRider.PreDistance;
|
var onlineDistance = onlineRider.EndDistance - onlineRider.PreDistance;
|
||||||
var onlineTotalDistance = onlineRider.PreDistance;
|
var onlineTotalDistance = onlineRider.PreDistance;
|
||||||
var index = GetCurrentIndex(onlineTotalDistance);
|
var index = GetCurrentIndex(onlineTotalDistance);
|
||||||
|
|
||||||
if (currentUser == null)
|
if (currentUser == null)
|
||||||
|
{
|
||||||
|
CreateOnlinePlayer(onlineRider,onlineTotalDistance,onlineDistance,index);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UpdateOnlinePlayer(currentUser,onlineRider,onlineTotalDistance,onlineDistance,index);
|
||||||
|
}
|
||||||
|
|
||||||
|
HandleWatcherView();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onlineRiders.Count > 0)
|
||||||
|
messageIndex++;
|
||||||
|
|
||||||
|
RemoveOfflineUsers();
|
||||||
|
ShowNearPlayerInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateOnlinePlayer(OnlineRiderModel onlineRider,double onlineTotalDistance,double onlineDistance,int index)
|
||||||
{
|
{
|
||||||
//大地图人物
|
//大地图人物
|
||||||
GameObject otherPlayerObj = (GameObject)Instantiate(onlineUserPrefab, transform);
|
var otherPlayerObj = (GameObject)Instantiate(onlineUserPrefab, transform);
|
||||||
otherPlayerObj.transform.position = map.GeoToWorldPosition(Along(onlineTotalDistance));
|
otherPlayerObj.transform.position = map.GeoToWorldPosition(Along(onlineTotalDistance));
|
||||||
var onlinePlayerController = otherPlayerObj.GetComponent<OnlinePlayerController>();
|
var onlinePlayerController = otherPlayerObj.GetComponent<OnlinePlayerController>();
|
||||||
otherList.Add(onlinePlayerController);
|
otherList.Add(onlinePlayerController);
|
||||||
|
|
||||||
onlinePlayerController.UserId = onlineRider.UserId;
|
onlinePlayerController.UserId = onlineRider.UserId;
|
||||||
|
onlinePlayerController.SetDataSource(onlineTotalDistance, onlineDistance, onlineRider.Power,
|
||||||
onlinePlayerController.SetDataSource(onlineTotalDistance, onlineDistance, onlineRider.Power, onlineRider.HeartRate, onlineRider.Cadence, onlineRider.TotalTicks, onlineRider.NickName, onlineRider.WeightKg, new Vector2d(onlineRider.Point.Latitude, onlineRider.Point.Longitude), index);
|
onlineRider.HeartRate, onlineRider.Cadence, onlineRider.TotalTicks, onlineRider.NickName,
|
||||||
|
onlineRider.WeightKg, new Vector2d(onlineRider.Point.Latitude, onlineRider.Point.Longitude), index,
|
||||||
|
onlineRider.Sex);
|
||||||
onlinePlayerController.SetHead(onlineRider.WxHeadImg);
|
onlinePlayerController.SetHead(onlineRider.WxHeadImg);
|
||||||
|
|
||||||
if (competitionId == 0)
|
if (competitionId == 0)
|
||||||
{
|
{
|
||||||
//小地图人物
|
//小地图人物
|
||||||
GameObject miniPlayer = (GameObject)Instantiate(miniMapPlayerPrefab, transform);
|
var miniPlayer = (GameObject)Instantiate(miniMapPlayerPrefab, transform);
|
||||||
var miniController = miniPlayer.GetComponent<MiniMapPlayerController>();
|
var miniController = miniPlayer.GetComponent<MiniMapPlayerController>();
|
||||||
miniController.SetController(onlinePlayerController);
|
miniController.SetController(onlinePlayerController);
|
||||||
}
|
}
|
||||||
|
|
||||||
//发消息xx进入路书
|
//发消息xx进入路书
|
||||||
if (messageIndex > 0)
|
if (messageIndex > 0)
|
||||||
EventQueueSystem.QueueEvent(new JoinMessageEvent(onlineRider.NickName, onlineRider.WxHeadImg));
|
EventQueueSystem.QueueEvent(new JoinMessageEvent(onlineRider.NickName, onlineRider.WxHeadImg));
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
currentUser.SetDataSource(onlineTotalDistance, onlineDistance, onlineRider.Power, onlineRider.HeartRate, onlineRider.Cadence, onlineRider.TotalTicks, onlineRider.NickName, onlineRider.WeightKg, new Vector2d(onlineRider.Point.Latitude, onlineRider.Point.Longitude), index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isWatch && (currentPlayer is PlayerController || currentPlayer == null))
|
private void UpdateOnlinePlayer(OnlinePlayerController currentUser, OnlineRiderModel onlineRider,
|
||||||
|
double onlineTotalDistance, double onlineDistance, int index)
|
||||||
{
|
{
|
||||||
var userId = onlineRiders.FirstOrDefault()?.UserId ?? 0;
|
currentUser.SetDataSource(onlineTotalDistance, onlineDistance, onlineRider.Power, onlineRider.HeartRate,
|
||||||
|
onlineRider.Cadence, onlineRider.TotalTicks, onlineRider.NickName, onlineRider.WeightKg,
|
||||||
|
new Vector2d(onlineRider.Point.Latitude, onlineRider.Point.Longitude), index, onlineRider.Sex);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleWatcherView()
|
||||||
|
{
|
||||||
|
var needChangeView = isWatch && (currentPlayer is PlayerController || currentPlayer == null);
|
||||||
|
if (!needChangeView) return;
|
||||||
|
|
||||||
|
var userId = cyclingController.riders.FirstOrDefault()?.UserId ?? 0;
|
||||||
ChangeCurrentPlayer(userId);
|
ChangeCurrentPlayer(userId);
|
||||||
|
|
||||||
var competitionRankingFactory = FindObjectOfType<CompetitionRankingFactory>();
|
var competitionRankingFactory = FindObjectOfType<CompetitionRankingFactory>();
|
||||||
if (competitionRankingFactory != null)
|
if (competitionRankingFactory != null)
|
||||||
{
|
{
|
||||||
competitionRankingFactory.isInit = false;
|
competitionRankingFactory.isInit = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//显示观察者头像
|
|
||||||
}
|
private void RemoveOfflineUsers()
|
||||||
if (onlineRiders.Count > 0)
|
{
|
||||||
messageIndex++;
|
var currentOnlineUserList = FindObjectsOfType<OnlinePlayerController>();
|
||||||
//移除
|
|
||||||
foreach (var item in currentOnlineUserList)
|
foreach (var item in currentOnlineUserList)
|
||||||
{
|
{
|
||||||
var currentItem = onlineRiders.Where(c => c.UserId == item.UserId).FirstOrDefault();
|
var currentItem = cyclingController.riders.FirstOrDefault(c => c.UserId == item.UserId);
|
||||||
if (currentItem == null)
|
if (currentItem == null)
|
||||||
{
|
{
|
||||||
item.RemoveSelf();
|
item.RemoveSelf();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//显示面板信息
|
//显示面板信息
|
||||||
|
private void ShowNearPlayerInfo()
|
||||||
|
{
|
||||||
var others = FindObjectsOfType<AbstractPlayer>();
|
var others = FindObjectsOfType<AbstractPlayer>();
|
||||||
foreach (var item in others)
|
foreach (var item in others)
|
||||||
{
|
{
|
||||||
item.IsShowInfo = false;
|
item.IsShowInfo = false;
|
||||||
}
|
}
|
||||||
var frontPlayer = others.Where(c => c.TotalDistance - currentPlayer.TotalDistance < 0.25 && c.TotalDistance - currentPlayer.TotalDistance >= 0 && c.UserId != currentPlayer.UserId).OrderBy(c => c.TotalDistance).FirstOrDefault();
|
|
||||||
var bakePlayer = others.Where(c => c.TotalDistance - currentPlayer.TotalDistance > -0.25 && c.TotalDistance - currentPlayer.TotalDistance < 0 && c.UserId != currentPlayer.UserId).OrderByDescending(c => c.TotalDistance).FirstOrDefault();
|
var frontPlayer = others
|
||||||
|
.Where(c => c.TotalDistance - currentPlayer.TotalDistance < 0.25 &&
|
||||||
|
c.TotalDistance - currentPlayer.TotalDistance >= 0 && c.UserId != currentPlayer.UserId)
|
||||||
|
.OrderBy(c => c.TotalDistance).FirstOrDefault();
|
||||||
|
var bakePlayer = others
|
||||||
|
.Where(c => c.TotalDistance - currentPlayer.TotalDistance > -0.25 &&
|
||||||
|
c.TotalDistance - currentPlayer.TotalDistance < 0 && c.UserId != currentPlayer.UserId)
|
||||||
|
.OrderByDescending(c => c.TotalDistance).FirstOrDefault();
|
||||||
if (frontPlayer != null)
|
if (frontPlayer != null)
|
||||||
frontPlayer.IsShowInfo = true;
|
frontPlayer.IsShowInfo = true;
|
||||||
if (bakePlayer != null)
|
if (bakePlayer != null)
|
||||||
bakePlayer.IsShowInfo = true;
|
bakePlayer.IsShowInfo = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//查询赛事观看者列表(取前5)
|
//查询赛事观看者列表(取前5)
|
||||||
public List<OnlineUser> GetWatcherList()
|
public List<OnlineUser> GetWatcherList()
|
||||||
{
|
{
|
||||||
return MapUDPService.GetCompetitionWatchers(competitionId);
|
return MapUDPService.GetCompetitionWatchers(competitionId);
|
||||||
|
|||||||
@ -21,6 +21,7 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
|
|
||||||
string nickName;
|
string nickName;
|
||||||
string weightKgStr;
|
string weightKgStr;
|
||||||
|
double diff = 0;
|
||||||
|
|
||||||
protected override void Init()
|
protected override void Init()
|
||||||
{
|
{
|
||||||
@ -73,8 +74,9 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
diff = 0;
|
diff = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
double diff = 0;
|
|
||||||
public void SetDataSource(double _totalDistance, double _distance, double _power, double _heartRate, double _cadence,int _totalTicks, string Name,double weightKg,Vector2d point,int index=0)
|
|
||||||
|
public void SetDataSource(double _totalDistance, double _distance, double _power, double _heartRate, double _cadence,int _totalTicks, string Name,double weightKg,Vector2d point,int index=0,int sex=0)
|
||||||
{
|
{
|
||||||
totalDistance = _totalDistance;
|
totalDistance = _totalDistance;
|
||||||
distance = _distance;
|
distance = _distance;
|
||||||
@ -88,6 +90,7 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
power = Convert.ToInt32(_power);
|
power = Convert.ToInt32(_power);
|
||||||
cadance = _cadence;
|
cadance = _cadence;
|
||||||
ticks = _totalTicks;
|
ticks = _totalTicks;
|
||||||
|
Sex = sex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector2d Point { get; set; }
|
public Vector2d Point { get; set; }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user