修复小人移动动画显示异常和一些界面调整

This commit is contained in:
lishuo committed 2021-07-29 16:13:23 +08:00
1 parent b9db3325a8
commit 33df128750
10 files changed
+338 -65

No files matched your search

@@ -107,12 +107,18 @@ namespace Assets.Scenes.Ride.Scripts
}
GameObject Detail { get; set; }
GameObject Apply { get; set; }
GameObject Watcher { get; set; }
GameObject MoreHead { get; set; }
Text CompetitionTitle { get; set; }
Text EndTime { get; set; }
//构建赛事界面
protected override void InitGameObject()
{
base.InitGameObject();
CompetitionTitle = panel.transform.Find("CompetitionName").GetComponent<Text>();
CompetitionDesc = panel.transform.Find("CompetitionDesc").GetComponent<RawImage>();
StartTime = panel.transform.Find("Time").GetComponent<Text>();
EndTime = panel.transform.Find("EndTime").GetComponent<Text>();
Contestant = panel.transform.Find("Contestant").GetComponent<Text>();
Watch = panel.transform.Find("Watch").gameObject;
CancelJoin = panel.transform.Find("CancelJoin").gameObject;
@@ -125,7 +131,8 @@ namespace Assets.Scenes.Ride.Scripts
ReadMore = panel.transform.Find("ReadMore").gameObject;
GetReady = panel.transform.Find("GetReady").GetComponent<Text>();
GetReadyTitle = panel.transform.Find("GetReadyTitle").GetComponent<Text>();
Watcher = Resources.Load<GameObject>("UI/Prefab/Match/Watcher");
MoreHead = Resources.Load<GameObject>("UI/Prefab/Match/MoreHead");
Watch.GetComponent<Button>().enabled = false;
Watch.GetComponent<Button>().interactable = false;
@@ -151,7 +158,9 @@ namespace Assets.Scenes.Ride.Scripts
_canWatch = competition.CanWatch;
#region 赛事基本信息
//赛事名称
mapName.text = competition.Title;
CompetitionTitle.text = competition.Title;
//线路名称
mapName.text = route.Name;
//距离
distance.text = route.Distance.ToString("f1") + "KM";
//海拔
@@ -160,6 +169,8 @@ namespace Assets.Scenes.Ride.Scripts
slope.text = Math.Round(route.AverageGrade, 2).ToString() + "%";
//比赛开始时间
StartTime.text = competition.StartTime.ToLocalTime().ToString();
//比赛结束时间
EndTime.text = competition.EndTime.ToLocalTime().ToString();
//比赛状态
CompetitionStatus.text = competition.StatusVlaue.ToString();
//参赛选手
@@ -196,18 +207,17 @@ namespace Assets.Scenes.Ride.Scripts
private int maxShowCout = 9;
private void ShowPlayers(List<CompetitionPlayer> list)
{
var watcher = Resources.Load<GameObject>("UI/Prefab/Match/Watcher");
var moreHead = Resources.Load<GameObject>("UI/Prefab/Match/MoreHead");
int index = 0;
Utils.DestroyChildren(PlayersPanel);
foreach (var item in list)
{
index++;
if (index >= maxShowCout)
{
Instantiate(moreHead, PlayersPanel);
Instantiate(MoreHead, PlayersPanel);
break;
}
var head = Instantiate(watcher, PlayersPanel);
var head = Instantiate(Watcher, PlayersPanel);
var headiamge = head.GetComponent<RawImage>();
if (!string.IsNullOrEmpty(item.WxHeadImg))
{
@@ -268,11 +278,14 @@ namespace Assets.Scenes.Ride.Scripts
_canCancelApply = competition.CanCancelJoin;
_canWatch = competition.CanWatch;
_raceStart = competition.Status == 3;
Contestant.text = competition.UserList.Count.ToString() + "Riders";
ShowPlayers(competition.UserList);
}
}
protected void ApplyRace(BaseEventData baseEvent)
{
UIManager.ShowConfirm("Join", "you want to join?", async () =>
UIManager.ShowConfirm("Join", "Do you want to join?", async () =>
{
MapCompetitionApi s = ConfigHelper.mapCompetitionApi;
var rrr = s.ApplyMapCompetition(cyclingController.competitionId);
@@ -298,7 +311,7 @@ namespace Assets.Scenes.Ride.Scripts
{
try
{
UIManager.ShowConfirm("Canel Reservation", "you want to cancel reservation?", async () =>
UIManager.ShowConfirm("Canel Reservation", "Do you want to cancel reservation?", async () =>
{
MapCompetitionApi api = ConfigHelper.mapCompetitionApi;
var data = api.CancelMapCompetition(cyclingController.competition.Id);
@@ -181,7 +181,7 @@ namespace Assets.Scenes.Ride.Scripts
}
if (mainController.isWatch)
{
UIManager.ShowConfirm("Quit", "Are you want to quit?", async () =>
UIManager.ShowConfirm("Quit", "Do you want to quit?", async () =>
{
SceneManager.LoadScene("MainScene");
UIManager.CloseConfirm();
@@ -33,7 +33,19 @@ namespace Assets.Scenes.Ride.Scripts
var ss = s?.competitionRankingModel;
rankingList = ss?.TopList;
if (rankingList == null) return;
//删除
var currentTopRankingList = FindObjectsOfType<TopRankingItem>();
foreach (var o in currentTopRankingList)
{
var e = rankingList.Where(c => c.UserId == o.UserId).FirstOrDefault();
if (e == null)
{
o.transform.gameObject.SetActive(false);//TODO:这里暂时不删除,删除对应的图片和脚本依赖这个对象;脚本提供一个dispose
bufferSize--;
}
}
for (int i = 0; i < rankingList.Count(); i++)
{
Create(rankingList[i]);
@@ -60,6 +72,7 @@ namespace Assets.Scenes.Ride.Scripts
//情况二:没有足够的buffer,找到要被淘汰的buffer()最后一名
competitionRankingItem = rankingList.OrderByDescending(c => c.rank).FirstOrDefault();
}
}
competitionRankingItem.setHead(item.Head);
competitionRankingItem.setTimer(item.TripTime);
@@ -119,6 +119,7 @@ namespace Assets.Scenes.Ride.Scripts.Model
public void SaveWithLocalRecordAysnc(CyclingModel cyclingModel, RouteResultParam selectParam, string imageName,string recordId,string path)
{
Saved = true;
Dictionary<MapInterruptRecord, List<string>> recordData = new Dictionary<MapInterruptRecord, List<string>>();
if (RiderDatas.Count <= 0)
{
@@ -220,7 +221,7 @@ namespace Assets.Scenes.Ride.Scripts.Model
System.IO.File.WriteAllText(recordFilePath, recordString);
recordData.Add(interruptRecord, files);
Saved = true;
//Saved = true;
SaveDataAysnc(recordData, path);
}
/// <summary>
@@ -194,7 +194,7 @@ namespace Assets.Scenes.Ride.Scripts
prePos = transform.localPosition;//当前点
thisRotation = transform.localRotation;
//移动动画控制
if (distance > 0)
if (distance >= 0)
{
//transform.localPosition = nextPos;
StartCoroutine(LookAtNextPos());//转向
@@ -254,6 +254,11 @@ namespace Assets.Scenes.Ride.Scripts
break;
}
}
var DOUBLE_DELTA = 1E-6;
if (Math.Abs(totalDistance - mapData.TotalDistance) < DOUBLE_DELTA)
{
index = pointList.Count - 1;
}
preIndex = index > 0 ? index - 1:0;//前一个索引
CurrentIndex = index;//当前索引
int nextIndex = index == pointList.Count - 1 ? index : index + 1; //计算下一个点的坡度和距离
@@ -288,8 +288,13 @@ namespace Assets.Scenes.Ride.Scripts
shadowButton.enabled = true;
shadowButton.interactable = true;
}
//标记3d的地图可以用
if (!route.RouteInstance.Enable3D)
//默认地图3d/2d
DefaultView(routeInstance);
}
private void DefaultView(MapRoute routeInstance)
{
if (!routeInstance.Enable3D)
{
viewButton.enabled = false;
viewButton.interactable = false;
@@ -324,7 +324,7 @@ public class CyclingController : DeviceServiceMonoBase
private GameObject onlinePlayer { get; set; }
Vector3 MAX_SIZE = new Vector3(3f, 3f, 3f);
Vector3 MIN_SIZE = new Vector3(0.1f, 0.1f, 0.1f);
Vector3 MIN_SIZE = new Vector3(0.01f, 0.01f, 0.01f);
public void ChangeCurrentPlayer(int userId)
{
var coll = FindObjectsOfType<AbstractPlayer>();
@@ -421,7 +421,7 @@ public class CyclingController : DeviceServiceMonoBase
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;
var onlineTotalDistance = onlineRider.PreDistance;
var index = GetCurrentIndex(onlineTotalDistance);
if (currentUser == null)
@@ -564,7 +564,7 @@ public class CyclingController : DeviceServiceMonoBase
//人物属性变更
var pos = map.GeoToWorldPosition(currentPlayer.Currentlatlong);
player.transform.position = pos;
player.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
player.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f);
target.position = pos;
//playerController.currentPos = Vector3.zero;
arrowGameObj.SetActive(true);
@@ -677,7 +677,6 @@ public class CyclingController : DeviceServiceMonoBase
{
isQuit = true;
isStart = false;
string recordId = Guid.NewGuid().ToString();
//var path = Helper.GetDataDir("MapWorkoutRecords/"+ recordId);
var path = PFConstants.MapWorkoutRecordFolder + "/" + recordId;