小地图进度微调,人物脚本调整
This commit is contained in:
1 parent
8ca32cd1ae
commit
2b4b2c4f70
15 files changed
+3626
-3085
No files matched your search
@@ -17,6 +17,8 @@ using Assets.Scripts;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Events;
|
||||
using Assets.Scenes.Ride.Scripts.Model.RiderModels;
|
||||
using System.IO;
|
||||
|
||||
public class CyclingController : DeviceServiceMonoBase
|
||||
{
|
||||
@@ -50,7 +52,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
LoadingController loadingController;
|
||||
private async Task Login()
|
||||
{
|
||||
var result = await new UserApi().Login("13115011550", "laozhong", "");
|
||||
var result = await new UserApi().Login("15261826280", "123456", "");
|
||||
App.CurrentUser = result.data;
|
||||
}
|
||||
GameObject miniMap;
|
||||
@@ -77,6 +79,8 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
{
|
||||
UIManager.Instance.MainPanel = this.transform.Find("SingleUI/Panel").GetComponent<PFUIPanel>();
|
||||
UIManager.Instance.ModalsPanel = this.transform.Find("SingleUI/ModalPanel").GetComponent<PFUIPanel>();
|
||||
onlineUserPrefab = Resources.Load<GameObject>("UI/Prefab/Ride/OnlinePlayer");
|
||||
miniMapPlayerPrefab = Resources.Load<GameObject>("UI/Prefab/Ride/MiniMapPlayer");
|
||||
target = transform.Find("Target");
|
||||
//进入倒计时
|
||||
singleUIManager = UIObject.GetComponent<SingleUIManager>();
|
||||
@@ -240,7 +244,74 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
singleUIManager.ContinueRide();
|
||||
}
|
||||
|
||||
#region
|
||||
#region TCP相关
|
||||
|
||||
public void TcpHandler()
|
||||
{
|
||||
if (cyclingController != null)
|
||||
{
|
||||
//tcp数据传输
|
||||
cyclingController.Run(null);
|
||||
//在线人物或比赛人物渲染
|
||||
ShowOnlineUsers();
|
||||
}
|
||||
}
|
||||
|
||||
List<OnlinePlayerController> otherList = new List<OnlinePlayerController>();
|
||||
GameObject onlineUserPrefab;
|
||||
GameObject miniMapPlayerPrefab;
|
||||
|
||||
private void ShowOnlineUsers()
|
||||
{
|
||||
var onlineRiders = cyclingController.riders;
|
||||
List<OnlinePlayerController> currentOnlineUserList = new List<OnlinePlayerController>();
|
||||
currentOnlineUserList.AddRange(FindObjectsOfType<OnlinePlayerController>());
|
||||
//新增或者更新
|
||||
foreach (var item in onlineRiders)
|
||||
{
|
||||
var onlineRider = item as OnlineRiderModel;
|
||||
var currentUser = currentOnlineUserList.Where(c => c.UserId == item.UserId).FirstOrDefault();
|
||||
var onlineDistance = onlineRider.EndDistance - onlineRider.PreDistance;
|
||||
var onlineTotalDistance = onlineRider.EndDistance;
|
||||
if (currentUser == null)
|
||||
{
|
||||
//for (int i = 0; i < 100; i++)
|
||||
{
|
||||
//大地图人物
|
||||
GameObject otherPlayerObj = (GameObject)Instantiate(onlineUserPrefab, transform);
|
||||
var onlinePlayerController = otherPlayerObj.GetComponent<OnlinePlayerController>();
|
||||
otherList.Add(onlinePlayerController);
|
||||
onlinePlayerController.UserId = onlineRider.UserId;
|
||||
//onlinePlayerController.SetDistance(onlineDistance);
|
||||
onlinePlayerController.SetTotalDistance(onlineTotalDistance, onlineDistance);
|
||||
onlinePlayerController.SetHead(onlineRider.WxHeadImg);
|
||||
//小地图人物
|
||||
GameObject miniPlayer = (GameObject)Instantiate(miniMapPlayerPrefab, transform);
|
||||
var miniController = miniPlayer.GetComponent<MiniMapPlayerController>();
|
||||
miniController.SetController(onlinePlayerController);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//currentUser.SetDistance(onlineDistance);
|
||||
currentUser.SetTotalDistance(onlineTotalDistance, onlineDistance);
|
||||
}
|
||||
}
|
||||
////移除
|
||||
//foreach (var item in currentOnlineUserList)
|
||||
//{
|
||||
// var currentItem = onlineRiders.Where(c => c.UserId == item.UserId).FirstOrDefault();
|
||||
// if (currentItem == null)
|
||||
// {
|
||||
// item.RemoveSelf();
|
||||
// }
|
||||
//}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 视角切换
|
||||
|
||||
public AbstractMap map3d;
|
||||
public bool Is3dView;
|
||||
public void ChangeMapImageStyle(GameObject arrowGameObj)
|
||||
{
|
||||
@@ -255,6 +326,8 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
map.Terrain.SetElevationType(ElevationLayerType.TerrainWithElevation);
|
||||
map.ImageLayer.SetLayerSource(ImagerySourceType.Custom);
|
||||
map.SetCenterLatitudeLongitude(playerController.Currentlatlong);
|
||||
//map3d.gameObject.SetActive(true);
|
||||
//map.gameObject.SetActive(false);
|
||||
//人物属性变更
|
||||
var pos = map.GeoToWorldPosition(playerController.Currentlatlong);
|
||||
playerController.currentPos = pos;
|
||||
@@ -272,6 +345,8 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
map.Terrain.ExaggerationFactor = 0f;
|
||||
map.Terrain.SetElevationType(ElevationLayerType.FlatTerrain);
|
||||
map.SetCenterLatitudeLongitude(playerController.Currentlatlong);
|
||||
//map.gameObject.SetActive(true);
|
||||
//map3d.gameObject.SetActive(false);
|
||||
//人物属性变更
|
||||
var pos = map.GeoToWorldPosition(playerController.Currentlatlong);
|
||||
player.transform.position = pos;
|
||||
@@ -377,7 +452,10 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
isStart = false;
|
||||
|
||||
string recordId = Guid.NewGuid().ToString();
|
||||
var path = Helper.GetDataDir("MapWorkoutRecords/"+ recordId);
|
||||
//var path = Helper.GetDataDir("MapWorkoutRecords/"+ recordId);
|
||||
var path = PFConstants.MapWorkoutRecordFolder + "/" + recordId;
|
||||
Helper.CreateDirectoryIfNotExsit(path);
|
||||
|
||||
string imageFileName = path +"/"+ Guid.NewGuid().ToString() + ".png";
|
||||
CaptureCamera(Camera.main, new Rect(Screen.width * 0f, Screen.height * 0f, Screen.width * 0.5f, Screen.height * 0.5f), imageFileName);
|
||||
|
||||
@@ -392,7 +470,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
var rs = resultPanel.GetComponent<ResultPanelScript>();
|
||||
rs.InjectController(this);
|
||||
rs.SetDataSource(cyclingController.recorderData);
|
||||
cyclingController.recorderData.SaveLocal(cyclingModel, selectParamModel, imageFileName, recordId);
|
||||
cyclingController.recorderData.SaveWithLocalRecordAysnc(cyclingModel, selectParamModel, imageFileName, recordId, path);
|
||||
}
|
||||
|
||||
protected void CaptureCamera(Camera camera, Rect rect,string fileName)
|
||||
|
||||
Reference in new issue
Block a user