修改新设计稿,保存每次划船的影子id;修改细节,增加c2适配前暂存

This commit is contained in:
Caiyanpeng committed 2022-03-29 18:12:21 +08:00
1 parent ab653b994f
commit e0649f7ea1
20 files changed
+4964 -4083

No files matched your search

@@ -38,6 +38,7 @@ public class RowerMultiModeScript : MonoBehaviour
public bool isMine { get; set; }
public int currentDistance { get; set; }
public string Country { get; set; }
public int currentRank { get; set; }
}
List<Trace> traceList;
List<float> initialPosYList;
@@ -48,6 +49,18 @@ public class RowerMultiModeScript : MonoBehaviour
if (PlayerPrefs.GetFloat("RowerMultiModeLocationX") != 0f)
{
scroll.localPosition = new Vector3(PlayerPrefs.GetFloat("RowerMultiModeLocationX"), startPosition.y, startPosition.z);
foreach (Transform t in transform.Find("Rower/Dots"))
{
t.GetComponent<Image>().color = Utils.HexToColorHtml("#ffffff");
}
if (scroll.localPosition.x >= startPosition.x - (730 / 2))
{
transform.Find("Rower/Dots/d1").GetComponent<Image>().color = Utils.HexToColorHtml("#f93086");
}
else
{
transform.Find("Rower/Dots/d2").GetComponent<Image>().color = Utils.HexToColorHtml("#f93086");
}
}
AddTouchEvent();
m2 = transform.Find("Rower/Modes/Scroll/M2");
@@ -75,6 +88,7 @@ public class RowerMultiModeScript : MonoBehaviour
public void HandleTimeTick(RowerChartModel data)
{
//rowerType = GetComponent<RowerHomeScript>().rowerType;
currentSecond++;
myData.list.Add(data);
SortByCurrentDistance();
@@ -105,6 +119,10 @@ public class RowerMultiModeScript : MonoBehaviour
});
}
userList = userList.OrderByDescending(x => x.currentDistance).ToList();
for (int i = 0; i < userList.Count; i++)
{
userList[i].currentRank = i + 1;
}
}
private List<TraceData> HandleData()
{
@@ -126,21 +144,15 @@ public class RowerMultiModeScript : MonoBehaviour
List<TraceData> userList;
TraceData myData;
List<RowerRank> shadowList;
private async void Start()
{
rowerType = GetComponent<RowerHomeScript>().rowerType;
//#if UNITY_EDITOR
// rowerType = new RowerTaskPanel.RowerType { type = 1, value = 250 };
//#endif
GetShadowList(rowerType);
}
public List<RowerRank> shadowList { get; private set; }
public async void GetShadowList(RowerTaskPanel.RowerType rowerType)
{
this.rowerType = rowerType;
currentSecond = -1;
var res = await ConfigHelper.rowerApi.GetShadowList(rowerType);
shadowList = res.data;
var _tmpList = shadowList.Select(x => new TraceData
{
list = x.list,
@@ -161,6 +173,10 @@ public class RowerMultiModeScript : MonoBehaviour
myData.Country = App.CurrentUser.Country;
_tmpList.Add(myData);
userList = _tmpList.OrderByDescending(x => x.currentDistance).ToList();
for (int i = 0; i < userList.Count; i++)
{
userList[i].currentRank = i + 1;
}
DisplayUserRanks(true);
DisplayTraces();
}
@@ -263,16 +279,20 @@ public class RowerMultiModeScript : MonoBehaviour
}
var width = t.Find("Main").GetComponent<RectTransform>().sizeDelta.x - t.Find("Main/Boat").GetComponent<RectTransform>().sizeDelta.x;
var diffWidth = data.currentDistance - mineData.currentDistance + 50;
if (diffWidth >= 0 && diffWidth <= 100)
if (data.currentDistance <= 50)
{
if (data.currentDistance <= 50)
{
diffWidth = data.currentDistance;
}
else if (rowerType.type == 1 && rowerType.value - data.currentDistance <= 50)
{
diffWidth = 100 - ((int)rowerType.value - data.currentDistance);
}
diffWidth = data.currentDistance;
}
else if (rowerType.type == 1 && rowerType.value - data.currentDistance <= 50)
{
diffWidth = 100 - ((int)rowerType.value - data.currentDistance);
}
if (data.isMine)
{
print("diff:" + diffWidth + ";"+ rowerType.type);
}
if (diffWidth >= 0 && diffWidth <= 100)
{
var tWidth = (diffWidth / 100f) * width;
t.Find("Main/Boat").gameObject.SetActive(true);
//t.Find("Main/Boat").localPosition = new Vector3(25 + tWidth, t.Find("Main/Boat").localPosition.y, t.Find("Main/Boat").localPosition.z);
@@ -331,7 +351,7 @@ public class RowerMultiModeScript : MonoBehaviour
private void SetRank(GameObject game, TraceData item,int i)
{
game.transform.Find("Content/Rank").GetComponent<Text>().text = (i + 1).ToString("00");
game.transform.Find("Content/Rank").GetComponent<Text>().text = item.currentRank.ToString("00");
game.transform.Find("Content/NickName").GetComponent<Text>().text = item.NickName;
Utils.DisplayImageTempDict(game.transform.Find("Content/Avatar").GetComponent<RawImage>(), item.Avatar, caches);
var _c = countryList.FirstOrDefault(x => item.Country == x.country);
@@ -339,7 +359,7 @@ public class RowerMultiModeScript : MonoBehaviour
{
game.transform.Find("Content/Country").GetComponent<Image>().sprite = Resources.Load<Sprite>(_c.source);
}
if (currentSecond < 0)
if (currentSecond < 0 || item.list.Count == 0)
{
game.transform.Find("Content/Time").GetComponent<Text>().text = "0M";
game.transform.Find("Content/Power").GetComponent<Text>().text = "0W";
@@ -369,17 +389,42 @@ public class RowerMultiModeScript : MonoBehaviour
game.transform.Find("Content/Rank").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
}
}
private List<TraceData> Get8UserList()
{
var resRanks = userList;
var ind = resRanks.FindIndex(x => x.UserId == App.CurrentUser.Id);
if (ind >= 8)
{
var tops = resRanks.Take(3).ToList();
List<TraceData> mys = null;
if (resRanks.Count - 1 - ind < 2)
{
mys = resRanks.GetRange(resRanks.Count - 5, 5);
}
else
{
mys = resRanks.GetRange(ind - 2, 5);
}
resRanks = tops.Concat(mys).ToList();
}
else
{
resRanks = resRanks.Take(8).ToList();
}
return resRanks;
}
private void DisplayUserRanks(bool isRefresh = false)
{
if (isRefresh)
{
scrollRank.content.DestroyChildren();
}
var list = Get8UserList();
if (scrollRank.content.childCount == 0)
{
for (int i = 0; i < userList.Count; i++)
for (int i = 0; i < list.Count; i++)
{
var item = userList[i];
var item = list[i];
var game = Instantiate<GameObject>(rank);
SetRank(game, item, i);
game.transform.SetParent(scrollRank.content);
@@ -392,7 +437,7 @@ public class RowerMultiModeScript : MonoBehaviour
int i = 0;
foreach (Transform t in scrollRank.content)
{
var item = userList[i];
var item = list[i];
SetRank(t.gameObject, item, i);
i++;
}
@@ -419,13 +464,19 @@ public class RowerMultiModeScript : MonoBehaviour
pan.gestureCompleteEvent += (r) =>
{
float x = 0;
foreach (Transform t in transform.Find("Rower/Dots"))
{
t.GetComponent<Image>().color = Utils.HexToColorHtml("#ffffff");
}
if (scroll.localPosition.x >= startPosition.x - (730 / 2))
{
x = startPosition.x;
transform.Find("Rower/Dots/d1").GetComponent<Image>().color = Utils.HexToColorHtml("#f93086");
}
else
{
x = startPosition.x - 730;
transform.Find("Rower/Dots/d2").GetComponent<Image>().color = Utils.HexToColorHtml("#f93086");
}
scroll.DOLocalMoveX(x, 0.5f);
PlayerPrefs.SetFloat("RowerMultiModeLocationX", x);
@@ -518,7 +569,7 @@ public class RowerMultiModeScript : MonoBehaviour
int currentSecond = -1;
private List<CountryModel> countryList;
public RowerTaskPanel.RowerType rowerType { get; private set; }
public RowerTaskPanel.RowerType rowerType { get; set; }
// Update is called once per frame
void Update()
@@ -533,9 +584,8 @@ public class RowerMultiModeScript : MonoBehaviour
//ChangeTrace(a, a+1);
HandleTimeTick(new RowerChartModel()
{
Distance = 0,
Distance = 15,
});
currentSecond++;
timer += 1f;
}
#endif
@@ -41,6 +41,16 @@ public class RowerTaskPanel : PFUIPanel
{
Close();
});
UIManager.AddEvent(transform.Find("Main/BtnFreeMode").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
rowerType.type = 0;
rowerType.value = 0;
if (callBack != null)
{
callBack.Invoke(rowerType);
}
Close();
});
//var bg = transform.Find("Main/Time/Inputbg").gameObject;
//UIManager.AddEvent(bg, UnityEngine.EventSystems.EventTriggerType.PointerEnter, b =>
// {
@@ -59,6 +69,7 @@ public class RowerTaskPanel : PFUIPanel
formList = new List<object>
{
distance.Find("Btn500").GetComponent<Button>(),
distance.Find("Btn1000").GetComponent<Button>(),
distance.Find("Btn2000").GetComponent<Button>(),
distance.Find("Btn5000").GetComponent<Button>(),
distance.Find("Btn10000").GetComponent<Button>(),
@@ -1,5 +1,6 @@
using Assets.Scripts;
using Assets.Scripts.Apis.Models;
using Facebook.Unity;
using System;
using System.Collections;
using System.Collections.Generic;
@@ -41,6 +42,26 @@ public class RowerWelldone : PFUIPanel
Close();
Application.OpenURL($"{App.websiteDict[App.Host]}rower/record/{id}?Token={App.CurrentUser.cookie}");
});
UIManager.AddEvent(transform.Find("Container/Share/Wx").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
if (data == null) return;
App.weChatController.ShareWebpageToWX(0, $"{App.websiteDict[App.Host]}rower/record/{id}?UserId={App.CurrentUser.Id}", $"PowerFun {data.info.TypeStr} Rowing", $"By {App.CurrentUser.Nickname}",null);
});
UIManager.AddEvent(transform.Find("Container/Share/WxMoment").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
if (data == null) return;
App.weChatController.ShareWebpageToWX(1, $"{App.websiteDict[App.Host]}rower/record/{id}?UserId={App.CurrentUser.Id}", $"PowerFun {data.info.TypeStr} Rowing", $"By {App.CurrentUser.Nickname}", null);
});
UIManager.AddEvent(transform.Find("Container/Share/Fb").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
if (data == null) return;
FB.ShareLink(contentURL: new Uri($"{App.websiteDict[App.Host]}rower/record/{id}?UserId={App.CurrentUser.Id}"),
contentTitle: $"PowerFun {data.info.TypeStr} Rowing",
contentDescription: $"By {App.CurrentUser.Nickname}");
//App.weChatController.ShareWebpageToWX(1, , , , null);
});
}
// Update is called once per frame
@@ -66,6 +87,7 @@ public class RowerWelldone : PFUIPanel
float timer = 1f, remainTime = 10f;
bool startTime = false;
RowerSegmentData data;
public async void Initial(string id)
{
Debug.Log("Initial");
@@ -74,6 +96,7 @@ public class RowerWelldone : PFUIPanel
var res = await ConfigHelper.rowerApi.GetSegmentDataAndRanking(id);
if (res.result)
{
this.data = res.data;
DisplayData(res.data, caches);
startTime = true;
remainTime = 10f;
@@ -123,7 +146,7 @@ public class RowerWelldone : PFUIPanel
content.Find("Power").GetComponent<Text>().text = item.Power.ToString("#0");
content.Find("HR").GetComponent<Text>().text = item.HeartRate.ToString("#0");
content.Find("Count").GetComponent<Text>().text = item.StrokeCount.ToString("#0");
content.Find("Carlories").GetComponent<Text>().text = item.Energy.ToString("#0");
content.Find("Carlories").GetComponent<Text>().text = item.Rate.ToString("#0");
//game.transform.Find("Content/Rank").GetComponent<Text>().text = (i + 1).ToString("00");
//game.transform.Find("Content/NickName").GetComponent<Text>().text = item.NickName;
//Utils.DisplayImageTempDict(game.transform.Find("Content/Avatar").GetComponent<RawImage>(), item.WxHeadImg, caches);