划船机暂存
This commit is contained in:
1 parent
1c73701e73
commit
c73545d912
164 files changed
+38281
-2181
No files matched your search
@@ -13,7 +13,7 @@ public class BigLeftController : MonoBehaviour
|
||||
{
|
||||
route.OnPointerExit(null);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
route.OnPointerEnter(null);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using DG.Tweening;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@@ -14,20 +16,23 @@ public class ResultListController : PFUIPanel
|
||||
[SerializeField]Transform routeResult;
|
||||
Transform localRouteItem;
|
||||
Transform scrollContent;
|
||||
Transform routeScroll, matchScroll;
|
||||
Transform routeContent, matchContent;
|
||||
Transform btnRoute, btnMatch,searchInput;
|
||||
Transform routeScroll, matchScroll, rowerScroll;
|
||||
Transform routeContent, matchContent, rowerContent;
|
||||
Transform btnRoute, btnMatch ,btnRower, searchInput;
|
||||
Color c1, c2;
|
||||
// Start is called before the first frame update
|
||||
int pageSize = 20;
|
||||
string name = "";
|
||||
Transform[] contents,scrolls;
|
||||
Transform[] contents,scrolls,btns;
|
||||
Dictionary<int, string> filterOptionDict = new Dictionary<int, string>
|
||||
{
|
||||
{0,"routes" },{1,"competition" }
|
||||
};
|
||||
//交互用
|
||||
public Transform currentItem { get; set; }
|
||||
|
||||
int scrollIndex = 0;
|
||||
ScrollRect scroll;
|
||||
void Awake()
|
||||
{
|
||||
//ApiBase.SetCookie("73385F5F719B610D132C1ECF3E9143272BF15214D57ED91CD7A9DFD832407471535112AAEB8E9271F75D54FBBF2D99F18FA313C1EEA5676F5D722D7FBB07C926BEC5905591BF9AFDDC6336552DF273112C2DA1794E6FA2F465B11FECD2E82E52");
|
||||
@@ -40,30 +45,41 @@ public class ResultListController : PFUIPanel
|
||||
scroll = transform.Find("ListPanel").Find("Scroll").GetComponent<ScrollRect>();
|
||||
btnMatch = transform.Find("ListPanel").Find("BtnMatch");
|
||||
btnRoute = transform.Find("ListPanel").Find("BtnRoute");
|
||||
btnRower = transform.Find("ListPanel").Find("BtnRower");
|
||||
searchInput = transform.Find("ListPanel").Find("SearchInput");
|
||||
scrollContent = scroll.transform.Find("Viewport").Find("Content");
|
||||
routeScroll = scrollContent.Find("RouteList");
|
||||
routeContent = routeScroll.Find("Viewport").Find("Content");
|
||||
matchScroll = scrollContent.Find("MatchList");
|
||||
matchContent = matchScroll.Find("Viewport").Find("Content");
|
||||
contents = new Transform[] { routeContent, matchContent};
|
||||
rowerScroll = scrollContent.Find("RowerList");
|
||||
rowerContent = rowerScroll.Find("Viewport").Find("Content");
|
||||
contents = new Transform[] { routeContent, matchContent, rowerContent};
|
||||
|
||||
if (btnMatch != null)
|
||||
{
|
||||
UIManager.AddEvent(btnMatch.gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
StartScroll(0);
|
||||
});
|
||||
//btnMatch.GetComponent<Button>().onClick.AddListener(() => StartScroll(0));
|
||||
}
|
||||
if (btnRoute != null)
|
||||
{
|
||||
UIManager.AddEvent(btnRoute.gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
StartScroll(1);
|
||||
StartScroll(0);
|
||||
});
|
||||
//btnRoute.GetComponent<Button>().onClick.AddListener(() => StartScroll(1));
|
||||
}
|
||||
if (btnMatch != null)
|
||||
{
|
||||
UIManager.AddEvent(btnMatch.gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
StartScroll(1);
|
||||
});
|
||||
//btnMatch.GetComponent<Button>().onClick.AddListener(() => StartScroll(0));
|
||||
}
|
||||
if (btnRower != null)
|
||||
{
|
||||
UIManager.AddEvent(btnRower.gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
StartScroll(2);
|
||||
});
|
||||
}
|
||||
btns = new Transform[] { btnRoute,btnMatch,btnRower };
|
||||
if (searchInput != null)
|
||||
{
|
||||
UIManager.AddEvent(searchInput.Find("Button").gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
@@ -88,15 +104,22 @@ public class ResultListController : PFUIPanel
|
||||
{
|
||||
UIManager.AddEvent(matchScroll.gameObject, UnityEngine.EventSystems.EventTriggerType.EndDrag, OnEndDrag);
|
||||
}
|
||||
scrolls = new Transform[] { routeScroll, matchScroll };
|
||||
if (rowerScroll != null)
|
||||
{
|
||||
UIManager.AddEvent(rowerScroll.gameObject, UnityEngine.EventSystems.EventTriggerType.EndDrag, OnEndDrag);
|
||||
|
||||
}
|
||||
scrolls = new Transform[] { routeScroll, matchScroll, rowerScroll };
|
||||
//GetList(0);
|
||||
GetList(1);
|
||||
GetList(2);
|
||||
}
|
||||
|
||||
public void Load()
|
||||
{
|
||||
Debug.Log("刷新show");
|
||||
if (contents != null && contents.Length == 2)
|
||||
//Refresh(contents[0]);
|
||||
if (contents != null && contents.Length == 3)
|
||||
{
|
||||
Debug.Log("刷新show进入");
|
||||
Refresh(contents[scrollIndex]);
|
||||
@@ -151,19 +174,26 @@ public class ResultListController : PFUIPanel
|
||||
}
|
||||
Dictionary<int, bool> isEnd = new Dictionary<int, bool>
|
||||
{
|
||||
{0,false },{1,false }
|
||||
{0,false },{1,false },{2,false }
|
||||
};
|
||||
Dictionary<int, int> pageIndex = new Dictionary<int, int>
|
||||
{
|
||||
{0,0 },{1,0 }
|
||||
{0,0 },{1,0 },{2,0 }
|
||||
};
|
||||
async void GetList(int? sindex = null)
|
||||
{
|
||||
var index = sindex ?? scrollIndex;
|
||||
if (isEnd[index]) return;
|
||||
Debug.Log(sindex);
|
||||
var r = await ConfigHelper.mapInterruptRecordApi.GetMapInterruptRecord(name, pageIndex[index], 20,filterOptionDict[index]);
|
||||
|
||||
JsonResult<List<JObject>> r = null;
|
||||
if (index == 0 || index == 1)
|
||||
{
|
||||
r = await ConfigHelper.mapInterruptRecordApi.GetMapInterruptRecord(name, pageIndex[index], 20, filterOptionDict[index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
r = await ConfigHelper.rowerApi.GetList(pageIndex[index], 20);
|
||||
}
|
||||
if (r.result)
|
||||
{
|
||||
if (r.data.Count == 0)
|
||||
@@ -173,10 +203,10 @@ public class ResultListController : PFUIPanel
|
||||
isEnd[index] = true;
|
||||
scroll.transform.Find("Error").gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
//contents[index];
|
||||
if (!sindex.HasValue ||(sindex.HasValue && sindex.Value == scrollIndex))
|
||||
if (!sindex.HasValue || (sindex.HasValue && sindex.Value == scrollIndex))
|
||||
{
|
||||
scroll.transform.Find("Error").gameObject.SetActive(true);
|
||||
}
|
||||
@@ -185,25 +215,32 @@ public class ResultListController : PFUIPanel
|
||||
else
|
||||
{
|
||||
isEnd[index] = false;
|
||||
DisplayRouteResult(r.data, contents[index],index);
|
||||
DisplayRouteResult(r.data, contents[index], index);
|
||||
scroll.transform.Find("Error").gameObject.SetActive(false);
|
||||
//DisplayRouteResult(r.data, matchContent);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
Utils.showToast(gameObject, r.errMsg);
|
||||
}
|
||||
}
|
||||
void DisplayRouteResult(List<RouteResult> list,Transform content,int index)
|
||||
void DisplayRouteResult(List<JObject> list,Transform content,int index)
|
||||
{
|
||||
if (routeResult != null)
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
var obj = Instantiate(routeResult);
|
||||
obj.GetComponent<RouteItem>().Initial(item, index, transform);
|
||||
if (index == 0 || index == 1)
|
||||
{
|
||||
obj.GetComponent<RouteItem>().Initial(item.ToObject<RouteResult>(), index, transform, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
obj.GetComponent<RouteItem>().Initial(item.ToObject<RowerResultModel>(), index, transform,true);
|
||||
}
|
||||
//obj.SendMessage("Initial", );
|
||||
obj.transform.parent = content;
|
||||
obj.transform.localScale = new Vector3(1, 1, 1);
|
||||
@@ -249,7 +286,7 @@ public class ResultListController : PFUIPanel
|
||||
bool startMouse = false;
|
||||
void Update()
|
||||
{
|
||||
GoScroll();
|
||||
//GoScroll();
|
||||
if (Input.GetAxis("Mouse ScrollWheel") != 0)
|
||||
{
|
||||
if (scrolls[scrollIndex].GetComponent<ScrollRect>().verticalNormalizedPosition <= 0 ||
|
||||
@@ -273,88 +310,42 @@ public class ResultListController : PFUIPanel
|
||||
}
|
||||
void StartScroll(int index)
|
||||
{
|
||||
if (startScroll) return;
|
||||
if (index == 0)
|
||||
#if UNITY_ANDROID || UNITY_IOS
|
||||
scrollContent.DOLocalMoveX(674*index*-1,0.3f);
|
||||
#else
|
||||
scrollContent.DOLocalMoveX(1158*index*-1,0.3f);
|
||||
#endif
|
||||
scrollIndex = index;
|
||||
for (int i = 0; i < btns.Length; i++)
|
||||
{
|
||||
//翻到比赛页,比赛按钮变白,线路按钮变灰
|
||||
scrollIndex = 1;
|
||||
startScroll = true;
|
||||
btnRoute.GetComponent<Text>().color = c2;
|
||||
btnMatch.GetComponent<Text>().color = c1;
|
||||
}
|
||||
else if (index == 1)
|
||||
{
|
||||
//反过来
|
||||
scrollIndex = 0;
|
||||
startScroll = true;
|
||||
btnRoute.GetComponent<Text>().color = c1;
|
||||
btnMatch.GetComponent<Text>().color = c2;
|
||||
}
|
||||
scroll.transform.Find("Error").gameObject.SetActive(contents[scrollIndex].childCount == 0);
|
||||
}
|
||||
#region 主页面滑动逻辑
|
||||
int scrollIndex = 0;
|
||||
bool startScroll = false;
|
||||
ScrollRect scroll;
|
||||
//private float scrollValue = 0.5f;
|
||||
int pageNums = 2;
|
||||
void GoScroll()
|
||||
{
|
||||
var index = scrollIndex;
|
||||
var scrollValue = 1f / (pageNums - 1);
|
||||
var value = index * scrollValue;
|
||||
if (scroll != null && startScroll)
|
||||
{
|
||||
if (scroll.horizontalNormalizedPosition >= value)
|
||||
if (!btns[i]) continue;
|
||||
if (i == index)
|
||||
{
|
||||
scroll.horizontalNormalizedPosition -= (scrollValue / 20);
|
||||
if (scroll.horizontalNormalizedPosition <= value)
|
||||
{
|
||||
Debug.Log(index);
|
||||
scroll.horizontalNormalizedPosition = value;
|
||||
startScroll = false;
|
||||
}
|
||||
btns[i].GetComponent<Text>().color = c1;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
scroll.horizontalNormalizedPosition += (scrollValue / 20);
|
||||
if (scroll.horizontalNormalizedPosition >= value)
|
||||
{
|
||||
Debug.Log(index);
|
||||
scroll.horizontalNormalizedPosition = value;
|
||||
startScroll = false;
|
||||
}
|
||||
btns[i].GetComponent<Text>().color = c2;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
//float scrollIndex = 0;
|
||||
//bool startScroll = false;
|
||||
//ScrollRect scroll;
|
||||
//void GoScroll()
|
||||
//{
|
||||
// float value = scrollIndex;
|
||||
// if (scroll != null && startScroll)
|
||||
// {
|
||||
// if (scrollIndex == 0)
|
||||
// {
|
||||
// scroll.horizontalNormalizedPosition -= (1f / 20);
|
||||
// if (scroll.horizontalNormalizedPosition <= 0)
|
||||
// {
|
||||
// scroll.horizontalNormalizedPosition = 0;
|
||||
// startScroll = false;
|
||||
|
||||
//if (startScroll) return;
|
||||
//if (index == 0)
|
||||
//{
|
||||
// //翻到比赛页,比赛按钮变白,线路按钮变灰
|
||||
// scrollIndex = 1;
|
||||
// startScroll = true;
|
||||
// btnRoute.GetComponent<Text>().color = c2;
|
||||
// btnMatch.GetComponent<Text>().color = c1;
|
||||
//}
|
||||
//else if (index == 1)
|
||||
//{
|
||||
// //反过来
|
||||
// scrollIndex = 0;
|
||||
// startScroll = true;
|
||||
// btnRoute.GetComponent<Text>().color = c1;
|
||||
// btnMatch.GetComponent<Text>().color = c2;
|
||||
//}
|
||||
|
||||
// }
|
||||
// }
|
||||
// else if (scrollIndex == 1)
|
||||
// {
|
||||
// scroll.horizontalNormalizedPosition += (1f / 20);
|
||||
// if (scroll.horizontalNormalizedPosition >= 1)
|
||||
// {
|
||||
// scroll.horizontalNormalizedPosition = 1;
|
||||
// startScroll = false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System;
|
||||
using System.Collections;
|
||||
@@ -14,6 +15,7 @@ public class RouteItem : MonoBehaviour
|
||||
#endif
|
||||
{
|
||||
RouteResult routeResult;
|
||||
RowerResultModel rowerResult;
|
||||
// Start is called before the first frame update
|
||||
Transform left,row1,row2,right,rightDot;
|
||||
Transform btnReRide, btnContinue, btnDelete;
|
||||
@@ -22,6 +24,7 @@ public class RouteItem : MonoBehaviour
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
@@ -33,18 +36,97 @@ public class RouteItem : MonoBehaviour
|
||||
int index;
|
||||
//交互用
|
||||
private Transform parent { get; set; }
|
||||
public void Initial(RouteResult result,int index,Transform parent = null)
|
||||
public void Initial(object result, int index, Transform parent = null,bool top = false)
|
||||
{
|
||||
if (parent)
|
||||
this.index = index;
|
||||
if (parent)
|
||||
{
|
||||
this.parent = parent;
|
||||
}
|
||||
routeResult = result;
|
||||
this.index = index;
|
||||
left = transform.Find("BigLeft/Left");
|
||||
row1 = left.Find("Main").Find("Row1");
|
||||
row2 = left.Find("Main").Find("Row2");
|
||||
rightDot = transform.Find("RightDot");
|
||||
if (rightDot != null)
|
||||
{
|
||||
UIManager.AddEvent(rightDot.Find("BtnDot").gameObject, EventTriggerType.PointerClick, (b) => OnPointerEnter(null));
|
||||
UIManager.AddEvent(rightDot.Find("BtnDelete").gameObject, EventTriggerType.PointerClick, (b) => Delete());
|
||||
}
|
||||
|
||||
//right.gameObject.SetActive(true);
|
||||
#if !(UNITY_ANDROID || UNITY_IOS)
|
||||
gameObject.GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
Detail();
|
||||
});
|
||||
#else
|
||||
gameObject.GetComponent<Button>().enabled = false;
|
||||
#endif
|
||||
if (result is RouteResult)
|
||||
{
|
||||
Initial((RouteResult)result, index, parent);
|
||||
}
|
||||
else
|
||||
{
|
||||
Initial((RowerResultModel)result, index, parent);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 划船机初始化
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="parent"></param>
|
||||
public void Initial(RowerResultModel result, int index, Transform parent = null)
|
||||
{
|
||||
rowerResult = result;
|
||||
row1.Find("Rank").gameObject.SetActive(false);
|
||||
row1.Find("Times").gameObject.SetActive(false);
|
||||
var raw = transform.Find("BigLeft/CoverImage").GetComponent<RawImage>();
|
||||
if (string.IsNullOrEmpty(result.Cover))
|
||||
{
|
||||
raw.texture = Resources.Load<Texture>("Images/Rower/地图1");
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.DisplayImage(raw, result.Cover, true);
|
||||
}
|
||||
row1.Find("Time").GetComponent<Text>().text = $"<color=#5c5c6e>Rowing time:</color>{TimeSpan.FromSeconds(result.TotalTime).ToString()}";
|
||||
row1.Find("Distance").GetComponent<Text>().text = $"<color=#5c5c6e>Distance:</color>{result.TotalDistance}M";
|
||||
row2.Find("Device").GetComponent<Text>().text = $"<color=#5c5c6e>Rowing equipment:</color>{result.ManufacturerName}";
|
||||
left.Find("Progress").gameObject.SetActive(false);
|
||||
left.Find("Main/Name").GetComponent<Text>().text = "Free rowing";
|
||||
left.Find("Main/Time").GetComponent<Text>().text = $"{result.StartTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")} ~ {result.CreateTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")}";
|
||||
var rect = left.Find("Main").GetComponent<RectTransform>();
|
||||
rect.sizeDelta = new Vector2(399,rect.sizeDelta.y);
|
||||
SetButtonColor(false);
|
||||
right = transform.Find("RightRower");
|
||||
if (right != null)
|
||||
{
|
||||
btnDetail = right.Find("BtnDetail");
|
||||
if (btnDetail)
|
||||
{
|
||||
UIManager.AddEvent(btnDetail.gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowRowerResult(result.Id);
|
||||
});
|
||||
}
|
||||
btnReRide = right.Find("BtnRide");
|
||||
if (btnReRide)
|
||||
{
|
||||
UIManager.AddEvent(btnReRide.gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowRowerPanel();
|
||||
});
|
||||
}
|
||||
}
|
||||
//UIManager.AddEvent(transform.gameObject, EventTriggerType.PointerClick, b => UIManager.ShowRowerResult(result.Id));
|
||||
}
|
||||
|
||||
public void Initial(RouteResult result,int index,Transform parent = null)
|
||||
{
|
||||
routeResult = result;
|
||||
|
||||
Utils.DisplayImage(transform.Find("BigLeft/CoverImage").GetComponent<RawImage>(), result.RouteImage, true);
|
||||
|
||||
left.Find("Main").Find("Name").GetComponent<Text>().text = result.RouteName;
|
||||
@@ -107,22 +189,7 @@ public class RouteItem : MonoBehaviour
|
||||
SetButtonColor(false);
|
||||
transform.Find("Right").gameObject.SetActive(false);
|
||||
}
|
||||
rightDot = transform.Find("RightDot");
|
||||
if (rightDot != null)
|
||||
{
|
||||
UIManager.AddEvent(rightDot.Find("BtnDot").gameObject, EventTriggerType.PointerClick, (b) => OnPointerEnter(null));
|
||||
UIManager.AddEvent(rightDot.Find("BtnDelete").gameObject, EventTriggerType.PointerClick, (b) => Delete());
|
||||
}
|
||||
|
||||
//right.gameObject.SetActive(true);
|
||||
#if !(UNITY_ANDROID || UNITY_IOS)
|
||||
gameObject.GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
Detail();
|
||||
});
|
||||
#else
|
||||
gameObject.GetComponent<Button>().enabled = false;
|
||||
#endif
|
||||
|
||||
}
|
||||
void Detail()
|
||||
{
|
||||
@@ -148,13 +215,21 @@ public class RouteItem : MonoBehaviour
|
||||
{
|
||||
UIManager.ShowConfirm("Delete", "Delete this record?", async () =>
|
||||
{
|
||||
var r = await ConfigHelper.mapApi.DeleteRecord(routeResult.Id);
|
||||
JsonResult<object> r = null;
|
||||
if (index != 2)
|
||||
{
|
||||
r = await ConfigHelper.mapApi.DeleteRecord(routeResult.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
r = await ConfigHelper.rowerApi.Delete(rowerResult.Id);
|
||||
}
|
||||
UIManager.CloseConfirm();
|
||||
if (r.result)
|
||||
{
|
||||
DestroyImmediate(gameObject);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
Utils.showToast(gameObject, r.errMsg);
|
||||
}
|
||||
@@ -245,6 +320,7 @@ public class RouteItem : MonoBehaviour
|
||||
{
|
||||
if (!f)
|
||||
{
|
||||
transform.Find("RightRower").gameObject.SetActive(false);
|
||||
transform.Find("Right").gameObject.SetActive(false);
|
||||
transform.Find("RightMatch").gameObject.SetActive(false);
|
||||
transform.Find("RightDot").gameObject.SetActive(true);
|
||||
@@ -262,6 +338,7 @@ public class RouteItem : MonoBehaviour
|
||||
}
|
||||
|
||||
transform.Find("RightMatch").gameObject.SetActive(index == 1);
|
||||
transform.Find("RightRower").gameObject.SetActive(index == 2);
|
||||
transform.Find("RightDot").gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user