graph chart引入&骑行结果弹窗
This commit is contained in:
1 parent
40d118cea3
commit
96f3644b5b
2374 files changed
+485161
-2410
No files matched your search
@@ -27,28 +27,32 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
public int preticks;
|
||||
|
||||
#region 参数
|
||||
private MapRoute mapRoute;//当前路书数据
|
||||
private MapDataModel mapData;//当前路书数据
|
||||
private Route route;//当前路书综合数据
|
||||
public List<MapRouteRanking> mapRouteRankingList;
|
||||
private Vector2d coordiantes;//当前地图中心
|
||||
|
||||
public bool isStart;//当前游戏是否开始
|
||||
public CyclingModel cyclingModel;//当前骑行模式
|
||||
public BaseCycling cyclingController { get; set; }
|
||||
private int RouteId;
|
||||
private int routeId;
|
||||
|
||||
private MapApi mapApi;
|
||||
private Route mapRoute;
|
||||
public DateTime startTime;
|
||||
public DateTime endTime;
|
||||
public bool isQuit;
|
||||
public bool isPause;
|
||||
#endregion
|
||||
GameObject loadingcanvas;
|
||||
|
||||
LoadingController loadingController;
|
||||
private async Task Login()
|
||||
{
|
||||
var result = await new UserApi().Login("13115011550", "laozhong", "");
|
||||
App.CurrentUser = result.data;
|
||||
}
|
||||
GameObject miniMap;
|
||||
GameObject resultPanel;
|
||||
void Awake()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
@@ -56,34 +60,55 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
#endif
|
||||
//获取路书信息
|
||||
mapApi = ConfigHelper.mapApi;
|
||||
RouteId = App.RouteIdParam > 0? App.RouteIdParam : 5492;
|
||||
MapDataModel result = mapApi.GetData(RouteId);
|
||||
mapRoute = GetNewInstace(RouteId);//获取一个路书所有的数据
|
||||
MapUDPService.Init();//初始化TCP
|
||||
|
||||
if (result != null )
|
||||
{
|
||||
Init(result);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("获取地图数据失败");
|
||||
}
|
||||
routeId = App.RouteIdParam > 0? App.RouteIdParam : 5492;
|
||||
mapRoute = mapApi.GetById(routeId).data;
|
||||
miniMap = transform.Find("MiniMap").gameObject;//小地图
|
||||
resultPanel = transform.Find("SingleUI/Panel/ResultPanel").gameObject;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
UIManager.Instance.MainPanel = this.transform.Find("SingleUI/Panel").GetComponent<PFUIPanel>();
|
||||
UIManager.Instance.ModalsPanel = this.transform.Find("SingleUI/ModalPanel").GetComponent<PFUIPanel>();
|
||||
loadingController = FindObjectOfType<LoadingController>();
|
||||
loadingController.InjectController(this);
|
||||
//开始loading
|
||||
Init();
|
||||
}
|
||||
//加载人物和地图以及UI界面
|
||||
private void Init(MapDataModel result)
|
||||
|
||||
public Texture GetCountryImageByCode(string code)
|
||||
{
|
||||
return UIManager.Instance.loginRegOptions.GetCountryImage(code);
|
||||
}
|
||||
|
||||
public Texture GetCountryImageByName(string name)
|
||||
{
|
||||
return UIManager.Instance.loginRegOptions.GetCountryImageByName(name);
|
||||
}
|
||||
private void Init()
|
||||
{
|
||||
loadingController.Init(mapRoute);//初始化loading页面 10
|
||||
loadingController.AddProcess(10);
|
||||
MapUDPService.Init();//初始化TCP
|
||||
loadingController.AddProcess(10);
|
||||
InitData();//初始化数据
|
||||
InitGameObject();//初始化场景
|
||||
}
|
||||
//初始化数据
|
||||
private void InitData()
|
||||
{
|
||||
mapData = mapApi.GetData(routeId);//获取路书地理数据
|
||||
route = new Route(mapData, mapRoute);
|
||||
loadingController.AddProcess(10);
|
||||
#region 其他场景传参处理
|
||||
//骑行结果
|
||||
if (App.routeResult != null )
|
||||
{
|
||||
routeResult = App.routeResult;
|
||||
selectParamModel = App.routeResult.ContinueCyclingParam;
|
||||
selectParamModel = App.routeResult.ContinueCyclingParam;//继续骑行
|
||||
preticks = App.routeResult.Ticks;
|
||||
}
|
||||
|
||||
if (selectParamModel == null)
|
||||
{
|
||||
selectParamModel = new RouteResultParam
|
||||
@@ -101,14 +126,30 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
|
||||
App.routeResult = null;
|
||||
|
||||
mapData = result;
|
||||
double endDistance = 0;
|
||||
endDistance = selectParamModel.EndDistance;
|
||||
coordiantes = Along(endDistance);
|
||||
|
||||
#endregion
|
||||
//计算上次骑行距离调整地图中心点
|
||||
double endDistance = selectParamModel.EndDistance;
|
||||
coordiantes = Along(endDistance);
|
||||
loadingController.AddProcess(10);
|
||||
//查询排行榜
|
||||
var list = mapApi.GetRouteRanking(App.RouteIdParam, "1", 0, 10, "");
|
||||
if (list.result)
|
||||
{
|
||||
mapRouteRankingList = list.data.list;
|
||||
loadingController.CreateRankingList(mapRouteRankingList);
|
||||
loadingController.AddProcess(10);
|
||||
}
|
||||
//异步请求mapbox画出当前路书路线图
|
||||
//loadingController.DrawMapRoute(mapData);
|
||||
loadingController.AddProcess(10);
|
||||
}
|
||||
//加载人物和地图以及UI界面
|
||||
private void InitGameObject()
|
||||
{
|
||||
map.gameObject.SetActive(true);
|
||||
player.SetActive(true);
|
||||
UIObject.SetActive(true);
|
||||
miniMap.SetActive(true);
|
||||
}
|
||||
|
||||
//设置骑行模式
|
||||
@@ -119,10 +160,10 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
switch (cyclingModel)
|
||||
{
|
||||
case CyclingModel.Single:
|
||||
cyclingController = new SingleModel(mapRoute, selectParamModel);
|
||||
cyclingController = new SingleModel(route, selectParamModel);
|
||||
break;
|
||||
case CyclingModel.Review:
|
||||
cyclingController = new SingleModel(mapRoute, selectParamModel);
|
||||
cyclingController = new SingleModel(route, selectParamModel);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -201,13 +242,14 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
}
|
||||
public Route GetRoute()
|
||||
{
|
||||
return mapRoute;
|
||||
return route;
|
||||
}
|
||||
|
||||
public MapDataModel GetMapData()
|
||||
{
|
||||
return mapData;
|
||||
}
|
||||
|
||||
public void Save(double totalDistance)
|
||||
{
|
||||
isStart = false;
|
||||
@@ -218,7 +260,12 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
cyclingController.recorderData.AntModelId = AntModelId;
|
||||
cyclingController.recorderData.ManufacturerId = ManufacturerId;
|
||||
cyclingController.recorderData.DeviceNumber = DeviceNumber;
|
||||
cyclingController.recorderData.SaveData(cyclingModel, selectParamModel, imageFileName);
|
||||
//cyclingController.recorderData.SaveData(cyclingModel, selectParamModel, imageFileName);
|
||||
//显示骑行结果
|
||||
resultPanel.SetActive(true);
|
||||
var rs = resultPanel.GetComponent<ResultPanelScript>();
|
||||
rs.InjectController(this);
|
||||
rs.SetDataSource(cyclingController.recorderData);
|
||||
}
|
||||
|
||||
protected string CaptureCamera(Camera camera, Rect rect)
|
||||
@@ -256,16 +303,6 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
{
|
||||
return coordiantes;
|
||||
}
|
||||
public Route GetNewInstace(int id)
|
||||
{
|
||||
var routeInstance = mapApi.GetById(id);
|
||||
if (routeInstance == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var jsonData = mapApi.GetData(RouteId);
|
||||
return new Route(jsonData, routeInstance.data);
|
||||
}
|
||||
public Vector2d Along(double endDistance)
|
||||
{
|
||||
if (mapData != null)
|
||||
|
||||
Reference in new issue
Block a user