Merge remote-tracking branch 'origin/dev_cyp' into dev_lishuo
# Conflicts: # Assets/Scripts/Apis/Models/MapCompetition.cs # Assets/Scripts/UI/Prefab/Race/RaceButtonGroupScript.cs
This commit is contained in:
commit
ac59808915
25 files changed
+826
-200
No files matched your search
@@ -60,9 +60,9 @@ namespace Assets.Scripts.Apis
|
||||
data = Newtonsoft.Json.JsonConvert.DeserializeObject<List<MapCompetitionModel>>(JsonConvert.SerializeObject(list.data))
|
||||
};
|
||||
}
|
||||
public async Task<JsonResult<List<MapCompetition>>> GetCompetitionListV2(string name, int pageIndex, int pageSize, string status = "", int order = 1, bool self = false)
|
||||
public async Task<JsonResult<List<MapCompetition>>> GetCompetitionListV2(string name, int pageIndex, int pageSize, string status = "", int order = 1, bool self = false, int activity = 0)
|
||||
{
|
||||
var list = await GetAsync<JsonResult<dynamic>>($"/MapCompetition/v2/GetList?pageIndex={ pageIndex }&pageSize={ pageSize }&name={ name }&status={ status }&order={order}&self={self}");
|
||||
var list = await GetAsync<JsonResult<dynamic>>($"/MapCompetition/v2/GetList?pageIndex={ pageIndex }&pageSize={ pageSize }&name={ name }&status={ status }&order={order}&self={self}&activity={activity}");
|
||||
return new JsonResult<List<MapCompetition>>
|
||||
{
|
||||
result = list.result,
|
||||
@@ -100,5 +100,14 @@ namespace Assets.Scripts.Apis
|
||||
};
|
||||
return Post<JsonResult>($"/MapCompetition/CancelMapCompetition", param);
|
||||
}
|
||||
//取消报名比赛
|
||||
public async Task<JsonResult> CancelMapCompetition(int id)
|
||||
{
|
||||
var param = new
|
||||
{
|
||||
id = id,
|
||||
};
|
||||
return await PostAsync<JsonResult>($"/MapCompetition/CancelMapCompetition", param);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,8 @@ namespace Assets.Scripts.Apis.Models
|
||||
public string ShortPreview { get; set; }
|
||||
//活动banner
|
||||
public string BannerPreview { get; set; }
|
||||
public bool HasJoin { get; set; }
|
||||
public int ApplyCount { get; set; }
|
||||
|
||||
}
|
||||
public class CompetitionPlayer
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class RaceButtonGroupScript : MonoBehaviour
|
||||
{
|
||||
private Transform BtnEnter, BtnCancel, BtnWatch;
|
||||
public MapCompetition map { get; set; }
|
||||
public Transform parent { get; set; }
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
BtnEnter = transform.Find("BtnEnter");
|
||||
BtnCancel = transform.Find("BtnCancel");
|
||||
BtnWatch = transform.Find("BtnWatch");
|
||||
if (BtnEnter != null)
|
||||
{
|
||||
UIManager.AddEvent(BtnEnter.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b => GoEnter());
|
||||
}
|
||||
if (BtnCancel != null)
|
||||
{
|
||||
UIManager.AddEvent(BtnCancel.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b => GoCancel());
|
||||
}
|
||||
if (BtnWatch != null)
|
||||
{
|
||||
UIManager.AddEvent(BtnWatch.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b => GoWatch());
|
||||
}
|
||||
}
|
||||
void GoEnter()
|
||||
{
|
||||
if (!map.HasJoin)
|
||||
{
|
||||
parent.GetComponent<RaceItemScript>().Join();
|
||||
}else
|
||||
{
|
||||
App.RouteIdParam = map.RouteId;
|
||||
App.CompetionId = map.Id;
|
||||
SceneManager.LoadScene("Ride");
|
||||
}
|
||||
Debug.Log(map);
|
||||
}
|
||||
void GoCancel()
|
||||
{
|
||||
if (map.HasJoin)
|
||||
{
|
||||
parent.GetComponent<RaceItemScript>().CancelJoin();
|
||||
}
|
||||
}
|
||||
void GoWatch()
|
||||
{
|
||||
App.RouteIdParam = map.RouteId;
|
||||
App.CompetionId = map.Id;
|
||||
SceneManager.LoadScene("Ride");
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5357b651626f6a1488bd3b1b756d271b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,203 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class RaceHomeScript : RaceScript
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
private ScrollRect scroll;
|
||||
private Transform content,rightContainer,leftContainer,btnGoList,avatar;
|
||||
private float contentSize;
|
||||
private int count;
|
||||
private Button L, R;
|
||||
//当前鼠标悬浮的卡片
|
||||
async void Start()
|
||||
{
|
||||
scroll = transform.Find("LeftContainer/Swiper").GetComponent<ScrollRect>();
|
||||
content = scroll.content;
|
||||
//Initial();
|
||||
if (scroll != null)
|
||||
{
|
||||
L = scroll.transform.Find("Left").GetComponent<Button>();
|
||||
R = scroll.transform.Find("Right").GetComponent<Button>();
|
||||
}
|
||||
if (L != null)
|
||||
{
|
||||
UIManager.AddEvent(L.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
goLeft();
|
||||
});
|
||||
}
|
||||
if (R != null)
|
||||
{
|
||||
UIManager.AddEvent(R.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
goRight();
|
||||
});
|
||||
}
|
||||
StartTime();
|
||||
#if UNITY_EDITOR
|
||||
if (App.CurrentUser == null) //App.CurrentUser == null
|
||||
{
|
||||
await Login();
|
||||
}
|
||||
#endif
|
||||
rightContainer = transform.Find("RightContainer");
|
||||
leftContainer = transform.Find("LeftContainer");
|
||||
btnGoList = rightContainer.Find("Container-2/BtnGoList");
|
||||
UIManager.AddEvent(btnGoList.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowRaceListPanel();
|
||||
});
|
||||
avatar = transform.Find("Avatar");
|
||||
if (avatar != null)
|
||||
{
|
||||
Utils.DisplayImage(avatar.GetComponent<RawImage>(), App.CurrentUser.WxHeadImg, true);
|
||||
UIManager.AddEvent(avatar.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowUserInfoPanel();
|
||||
});
|
||||
}
|
||||
var r = await ConfigHelper.mapCompetitionApi.GetCompetitionListV2("", 0, 5);
|
||||
var activityList = await ConfigHelper.mapCompetitionApi.GetCompetitionListV2("", 0, 3, activity: 1);
|
||||
DisplayMaps(r.data,activityList.data);
|
||||
Initial();
|
||||
}
|
||||
|
||||
private void DisplayMaps(List<MapCompetition> list, List<MapCompetition> activityList)
|
||||
{
|
||||
int i = 0;
|
||||
GameObject bigGame = Resources.Load<GameObject>("UI/Prefab/Race/ItemBig"),
|
||||
smallGame = Resources.Load<GameObject>("UI/Prefab/Race/ItemSmall"),
|
||||
bannerItem = Resources.Load<GameObject>("UI/Prefab/Race/Banner/BannerItem"),
|
||||
dotItem = Resources.Load<GameObject>("UI/Prefab/Race/Banner/DotItem");
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
var game = Instantiate<GameObject>(bigGame);
|
||||
game.GetComponent<RaceItemScript>().Initial(list[i], transform);
|
||||
game.transform.SetParent(rightContainer.Find("Container-1"));
|
||||
game.transform.localScale = Vector3.one;
|
||||
}
|
||||
for (; i < 5; i++)
|
||||
{
|
||||
var game = Instantiate<GameObject>(smallGame);
|
||||
game.GetComponent<RaceItemScript>().Initial(list[i], transform);
|
||||
game.transform.SetParent(rightContainer.Find("Container-2"));
|
||||
game.transform.localScale = Vector3.one;
|
||||
}
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
var activity = activityList[i];
|
||||
var banner = Instantiate<GameObject>(bannerItem);
|
||||
var dot = Instantiate<GameObject>(dotItem);
|
||||
Utils.DisplayImage(banner.GetComponent<RawImage>(), activity.BannerPreview, true);
|
||||
|
||||
UIManager.AddEvent(banner.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
OnBannerClick(activity);
|
||||
});
|
||||
banner.transform.SetParent(scroll.content);
|
||||
dot.GetComponent<Image>().color =
|
||||
i == 0 ? Utils.HexToColorHtml("#f93086") : Utils.HexToColorHtml("#ffffff");
|
||||
dot.transform.SetParent(scroll.transform.Find("DotList"));
|
||||
banner.transform.localScale = Vector3.one;
|
||||
dot.transform.localScale = Vector3.one;
|
||||
//scroll.content
|
||||
}
|
||||
rightContainer.Find("Container-2/BtnGoList").SetAsLastSibling();
|
||||
}
|
||||
void OnBannerClick(MapCompetition map)
|
||||
{
|
||||
Debug.Log("banner點擊");
|
||||
}
|
||||
private async Task Login()
|
||||
{
|
||||
var result = await ConfigHelper.userApi.Login("13115011550", "laozhong", "");
|
||||
App.CurrentUser = result.data;
|
||||
}
|
||||
int scrollIndex = 0;
|
||||
public void Initial()
|
||||
{
|
||||
//if (content.childCount - 2 > 0)
|
||||
//{
|
||||
// contentSize = 1f / (content.childCount - 2);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// contentSize = 0;
|
||||
//}
|
||||
contentSize = 1f / (content.childCount - 1);
|
||||
scroll.horizontalNormalizedPosition = 0;
|
||||
}
|
||||
void goLeft()
|
||||
{
|
||||
Debug.Log($"{scroll.horizontalNormalizedPosition}");
|
||||
if (scroll.horizontalNormalizedPosition<=0.0001) return;
|
||||
goMove(-1);
|
||||
}
|
||||
void goRight()
|
||||
{
|
||||
|
||||
if (scroll.horizontalNormalizedPosition >= 0.9999) return;
|
||||
//if ((scroll.horizontalNormalizedPosition + contentSize) >= 1) return;
|
||||
|
||||
goMove();
|
||||
}
|
||||
void goMove(int i = 1)
|
||||
{
|
||||
//doAni();
|
||||
if (!start) startPosition = scroll.horizontalNormalizedPosition;
|
||||
start = true;
|
||||
scrollValue = i * contentSize / 20;
|
||||
}
|
||||
private bool start = false;
|
||||
private float scrollValue = 0, totalScrollValue = 0, startPosition = 0;
|
||||
// Update is called once per frame
|
||||
private void FixedUpdate()
|
||||
{
|
||||
if (start)
|
||||
{
|
||||
scroll.horizontalNormalizedPosition += scrollValue;
|
||||
totalScrollValue += scrollValue;
|
||||
if (System.Math.Abs(totalScrollValue) >= contentSize)
|
||||
{
|
||||
scrollValue = 0;
|
||||
start = false;
|
||||
scroll.horizontalNormalizedPosition = startPosition + (totalScrollValue < 0 ? -1 : 1) * contentSize;
|
||||
handleDotList(totalScrollValue);
|
||||
|
||||
Debug.Log(scrollIndex);
|
||||
//Debug.Log();
|
||||
totalScrollValue = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleDotList(float totalScrollValue)
|
||||
{
|
||||
scrollIndex = ((scrollIndex + content.childCount) + (totalScrollValue < 0 ? -1 : 1)) % content.childCount;
|
||||
var dotList = scroll.transform.Find("DotList");
|
||||
for (int i = 0; i < dotList.childCount; i++)
|
||||
{
|
||||
if (i == scrollIndex)
|
||||
{
|
||||
dotList.GetChild(i).GetComponent<Image>().color = Utils.HexToColorHtml("#f93086");
|
||||
}
|
||||
else
|
||||
{
|
||||
dotList.GetChild(i).GetComponent<Image>().color = Utils.HexToColorHtml("#ffffff");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93263b6a2a269ae4fb052ec2c022251c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,241 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler, IPointerUpHandler
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
public enum ItemType { big, small }
|
||||
private Transform parent;
|
||||
[SerializeField] ItemType myType;
|
||||
public MapCompetition mapCompetition { get; set; }
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
public void Initial(MapCompetition mapCompetition,Transform parent)
|
||||
{
|
||||
Utils.DisplayImage(transform.GetComponent<RawImage>(), mapCompetition.RouteCover, true);
|
||||
Utils.DisplayImage(transform.Find("InfoContainer/AltitudeCurve").GetComponent<RawImage>(), mapCompetition.AltitudeGraph, true);
|
||||
transform.Find("Text").GetComponent<Text>().SetTextWithEllipsis(mapCompetition.Title);
|
||||
transform.Find("GetReadyContainer").gameObject.SetActive(mapCompetition.Status == 2);
|
||||
//transform.Find("Text").GetComponent<Text>().text = mapCompetition.Title;
|
||||
//props.Find("DistanceText").GetComponent<Text>().text = $"{myMap.Distance.ToString(myMap.Distance > 1000 ? "#0" : "#0.00")}KM";
|
||||
//props.Find("EleText").GetComponent<Text>().text = $"{(myMap.TotalClimb ?? 0.0).ToString(myMap.TotalClimb > 1000 ? "#0" : "#0.00")}M";
|
||||
//props.Find("SlopeText").GetComponent<Text>().text = $"{myMap.AverageGrade.ToString("#0.00")}%";
|
||||
transform.Find("InfoContainer/DataContainer/Distance/Text").GetComponent<Text>().text
|
||||
= $"{mapCompetition.Distance.ToString(mapCompetition.Distance > 1000 ? "#0" : "#0.00")}KM";
|
||||
transform.Find("InfoContainer/DataContainer/Altitude/Text").GetComponent<Text>().text
|
||||
= $"{(mapCompetition.TotalClimb ?? 0.0).ToString(mapCompetition.TotalClimb > 1000 ? "#0" : "#0.00")}M";
|
||||
transform.Find("InfoContainer/DataContainer/Slope/Text").GetComponent<Text>().text
|
||||
= $"{mapCompetition.AverageGrade.ToString("#0.00")}%";
|
||||
transform.Find("InfoContainer/DataContainer/StartTime/Text").GetComponent<Text>().text = mapCompetition.StartTime.ToString();
|
||||
transform.Find("CountContainer/Text").GetComponent<Text>().text = mapCompetition.ApplyCount.ToString();
|
||||
SetStatus(mapCompetition);
|
||||
SetButtonGroup(mapCompetition);
|
||||
this.parent = parent;
|
||||
this.mapCompetition = mapCompetition;
|
||||
}
|
||||
|
||||
private void SetButtonGroup(MapCompetition mapCompetition)
|
||||
{
|
||||
if (mapCompetition.Status == 1 || mapCompetition.Status == 3 || (mapCompetition.Status == 2 && !mapCompetition.HasJoin))
|
||||
{
|
||||
var game = Resources.Load<GameObject>("UI/Prefab/Race/ButtonGroup/BtnContainer-Enter");
|
||||
var igame = Instantiate(game);
|
||||
igame.name = "BtnContainer";
|
||||
igame.GetComponent<RaceButtonGroupScript>().map = mapCompetition;
|
||||
igame.GetComponent<RaceButtonGroupScript>().parent = transform;
|
||||
igame.transform.SetParent(transform);
|
||||
igame.transform.localScale = Vector3.one;
|
||||
var loc = Vector3.zero;
|
||||
loc.y = myType == ItemType.big ? -252 : -257;
|
||||
igame.transform.localPosition = loc;
|
||||
}
|
||||
else if (mapCompetition.Status == 4)
|
||||
{
|
||||
var game = Resources.Load<GameObject>("UI/Prefab/Race/ButtonGroup/BtnContainer-Watch");
|
||||
var igame = Instantiate(game);
|
||||
igame.name = "BtnContainer";
|
||||
igame.GetComponent<RaceButtonGroupScript>().map = mapCompetition;
|
||||
igame.GetComponent<RaceButtonGroupScript>().parent = transform;
|
||||
igame.transform.SetParent(transform);
|
||||
igame.transform.localScale = Vector3.one;
|
||||
var loc = Vector3.zero;
|
||||
loc.y = myType == ItemType.big ? -252 : -257;
|
||||
igame.transform.localPosition = loc;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (myType == ItemType.big)
|
||||
{
|
||||
var game = Resources.Load<GameObject>("UI/Prefab/Race/ButtonGroup/BtnContainer-Double-H");
|
||||
var igame = Instantiate(game);
|
||||
igame.name = "BtnContainer";
|
||||
igame.GetComponent<RaceButtonGroupScript>().map = mapCompetition;
|
||||
igame.GetComponent<RaceButtonGroupScript>().parent = transform;
|
||||
igame.transform.SetParent(transform);
|
||||
igame.transform.localScale = Vector3.one;
|
||||
var loc = Vector3.zero;
|
||||
loc.y = -252;
|
||||
igame.transform.localPosition = loc;
|
||||
}
|
||||
else
|
||||
{
|
||||
var game = Resources.Load<GameObject>("UI/Prefab/Race/ButtonGroup/BtnContainer-Double-V");
|
||||
var igame = Instantiate(game);
|
||||
igame.name = "BtnContainer";
|
||||
igame.GetComponent<RaceButtonGroupScript>().map = mapCompetition;
|
||||
igame.GetComponent<RaceButtonGroupScript>().parent = transform;
|
||||
igame.transform.SetParent(transform);
|
||||
igame.transform.localScale = Vector3.one;
|
||||
var loc = Vector3.zero;
|
||||
loc.y = -209;
|
||||
igame.transform.localPosition = loc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<int, string> statusColorDict = new Dictionary<int, string>
|
||||
{
|
||||
{2,"#F93086" },{3,"#41A6FE" },{4,"#6E6E7D" },
|
||||
};
|
||||
private void SetStatus(MapCompetition mapCompetition)
|
||||
{
|
||||
var status = transform.Find("Status");
|
||||
if (mapCompetition.Status == 1)
|
||||
{
|
||||
status.gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
status.GetComponent<RawImage>().color = Utils.HexToColorHtml(statusColorDict[mapCompetition.Status]);
|
||||
if (mapCompetition.Status == 2 && mapCompetition.HasJoin)
|
||||
{
|
||||
status.Find("Text").GetComponent<Text>().text = "Applied";
|
||||
}
|
||||
else
|
||||
{
|
||||
status.Find("Text").GetComponent<Text>().text = mapCompetition.StatusVlaue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
{
|
||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
transform.Find("Masking").GetComponent<CanvasGroup>().DOFade(0, 0.5f);
|
||||
transform.Find("Text").GetComponent<CanvasGroup>().DOFade(0, 0.5f);
|
||||
transform.Find("BtnContainer").GetComponent<CanvasGroup>().DOFade(0, 0.5f);
|
||||
transform.Find("CountContainer").GetComponent<CanvasGroup>().DOFade(0, 0.5f);
|
||||
transform.Find("GetReadyContainer").GetComponent<CanvasGroup>().DOFade(0, 0.5f);
|
||||
|
||||
transform.Find("InfoContainer").GetComponent<Image>().DOFade(1, 0.5f);
|
||||
if (myType == ItemType.small)
|
||||
{
|
||||
transform.Find("InfoContainer/DataContainer").GetComponent<CanvasGroup>().DOFade(1, 0.5f);
|
||||
transform.Find("InfoContainer/AltitudeCurve").DOScaleY(1f, 0.5f);
|
||||
transform.Find("InfoContainer").DOLocalMoveY(-225, 0.3f);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.Find("InfoContainer/Line").GetComponent<Image>().DOFade(1,0.5f);
|
||||
transform.Find("InfoContainer").DOLocalMoveY(-246, 0.3f);
|
||||
}
|
||||
if (this.parent != null)
|
||||
{
|
||||
this.parent.GetComponent<RaceScript>().SetCurrentItem(null);
|
||||
//this.parent.SendMessage("SetCurrentItem", null, SendMessageOptions.RequireReceiver);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
Cursor.SetCursor(Resources.Load<Texture2D>("Images/PointerButtonHover"), Vector2.zero, CursorMode.Auto);
|
||||
transform.Find("Masking").GetComponent<CanvasGroup>().DOFade(1, 0.5f);
|
||||
transform.Find("Text").GetComponent<CanvasGroup>().DOFade(1, 0.5f);
|
||||
transform.Find("BtnContainer").GetComponent<CanvasGroup>().DOFade(1, 0.5f);
|
||||
transform.Find("CountContainer").GetComponent<CanvasGroup>().DOFade(1, 0.5f);
|
||||
transform.Find("GetReadyContainer").GetComponent<CanvasGroup>().DOFade(1, 0.5f);
|
||||
transform.Find("InfoContainer").GetComponent<Image>().DOFade(0, 0.5f);
|
||||
if (myType == ItemType.small)
|
||||
{
|
||||
transform.Find("InfoContainer/DataContainer").GetComponent<CanvasGroup>().DOFade(0, 0.5f);
|
||||
transform.Find("InfoContainer/AltitudeCurve").DOScaleY(1.7f, 0.5f);
|
||||
transform.Find("InfoContainer").DOLocalMoveY(-124 + 50, 0.3f);
|
||||
//transform.Find("InfoContainer").DOLocalMoveY(-139, 0.3f);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.Find("InfoContainer/Line").GetComponent<Image>().DOFade(0, 0.5f);
|
||||
transform.Find("InfoContainer").DOLocalMoveY(-155, 0.3f);
|
||||
}
|
||||
if (this.parent != null)
|
||||
{
|
||||
this.parent.GetComponent<RaceScript>().SetCurrentItem(transform);
|
||||
//this.parent.SendMessage("SetCurrentItem", transform);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
|
||||
}
|
||||
/*
|
||||
//先报名
|
||||
if (_canJoin)
|
||||
{
|
||||
MapCompetitionApi s = new MapCompetitionApi();
|
||||
var rrr = s.ApplyMapCompetition(cyclingController.competitionId);
|
||||
if (rrr.Result.result)
|
||||
{
|
||||
var competition = s.GetById(cyclingController.competitionId).data;
|
||||
_canStart = competition.CanStart;
|
||||
}
|
||||
rideNowText.text = "RideNow";
|
||||
}
|
||||
else
|
||||
{
|
||||
base.StartRide(baseEvent);
|
||||
}
|
||||
*/
|
||||
async public void Join()
|
||||
{
|
||||
var res = await ConfigHelper.mapCompetitionApi.ApplyMapCompetition(mapCompetition.Id);
|
||||
if (res.result)
|
||||
{
|
||||
mapCompetition.HasJoin = true;
|
||||
transform.Find("CountContainer/Text").GetComponent<Text>().text = (++mapCompetition.ApplyCount).ToString();
|
||||
SetStatus(mapCompetition);
|
||||
transform.Find("BtnContainer").gameObject.Destroy();
|
||||
SetButtonGroup(mapCompetition);
|
||||
Utils.showToast(null, "Successful application!", type: 1);
|
||||
}
|
||||
}
|
||||
async public void CancelJoin()
|
||||
{
|
||||
var res = await ConfigHelper.mapCompetitionApi.CancelMapCompetition(mapCompetition.Id);
|
||||
if (res.result)
|
||||
{
|
||||
mapCompetition.HasJoin = false;
|
||||
transform.Find("CountContainer/Text").GetComponent<Text>().text = (--mapCompetition.ApplyCount).ToString();
|
||||
SetStatus(mapCompetition);
|
||||
transform.Find("BtnContainer").gameObject.Destroy();
|
||||
SetButtonGroup(mapCompetition);
|
||||
Utils.showToast(null, "Successful cancellation application!", type: 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71608401d5eb08c409fd49e9a11e4cbe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,227 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Assets.Scripts.UI.Prefab.Race;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class RaceListScript : RaceScript
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
private GameObject scroll;
|
||||
private Transform content,statusOptionContainer, reserveContainer,dirContainer, searchInput,btnReturn,avatar;
|
||||
private bool startMouse = false,isEnd = false;
|
||||
private int pageIndex = 0, pageSize = 24;
|
||||
private string raceName = "";
|
||||
//筛选条件
|
||||
private List<string> statusOptions = new List<string>();
|
||||
bool isReserve = false;
|
||||
int order = 1;
|
||||
//筛选条件
|
||||
async void Start()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (App.CurrentUser == null) //App.CurrentUser == null
|
||||
{
|
||||
await Login();
|
||||
}
|
||||
#endif
|
||||
scroll = transform.Find("ListContainer/List").gameObject;
|
||||
if (scroll != null)
|
||||
{
|
||||
content = scroll.GetComponent<ScrollRect>().content;
|
||||
UIManager.AddEvent(scroll, UnityEngine.EventSystems.EventTriggerType.EndDrag, OnEndDrag);
|
||||
}
|
||||
statusOptionContainer = transform.Find("ListContainer/Conditions/StatusContainer");
|
||||
if (statusOptionContainer != null)
|
||||
{
|
||||
foreach (Transform t in statusOptionContainer)
|
||||
{
|
||||
var button = t.GetComponent<Button>();
|
||||
var image = t.GetComponent<Image>();
|
||||
var text = t.Find("Text").GetComponent<Text>();
|
||||
UIManager.AddEvent(button.gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
Color c1 = Utils.HexToColorHtml("#23232D");
|
||||
if (image.color.r == c1.r && image.color.g == c1.g && image.color.b == c1.b)
|
||||
{
|
||||
image.color = Utils.HexToColorHtml("#F93086");
|
||||
text.color = new Color(1, 1, 1, 1);
|
||||
statusOptions.Add(RaceFilterOptions.statusDict[text.text]);
|
||||
}
|
||||
else
|
||||
{
|
||||
image.color = c1;
|
||||
text.color = new Color(1, 1, 1, 1);
|
||||
statusOptions.Remove(RaceFilterOptions.statusDict[text.text]);
|
||||
}
|
||||
scroll.GetComponent<ScrollRect>().verticalNormalizedPosition = 1;
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
}
|
||||
reserveContainer = transform.Find("ListContainer/Conditions/ReserveContainer");
|
||||
if (reserveContainer != null)
|
||||
{
|
||||
UIManager.AddEvent(reserveContainer.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b=>
|
||||
{
|
||||
var gou = reserveContainer.Find("Gou").gameObject;
|
||||
bool v = !gou.activeSelf;
|
||||
gou.SetActive(v);
|
||||
isReserve = v;
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
dirContainer = transform.Find("ListContainer/Conditions/Dir");
|
||||
if (dirContainer != null)
|
||||
{
|
||||
var image = dirContainer.Find("Image").GetComponent<Image>();
|
||||
UIManager.AddEvent(dirContainer.gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
if (image.sprite.name == "DOWN")
|
||||
{
|
||||
image.sprite = Resources.Load<Sprite>("Images/UP");
|
||||
order = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
image.sprite = Resources.Load<Sprite>("Images/DOWN");
|
||||
order = 1;
|
||||
}
|
||||
Refresh();
|
||||
});
|
||||
}
|
||||
searchInput = transform.Find("ListContainer/Conditions/SearchInput");
|
||||
if (searchInput != null)
|
||||
{
|
||||
UIManager.AddEvent(searchInput.Find("Button").gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
onEndEdit();
|
||||
});
|
||||
}
|
||||
btnReturn = transform.Find("BtnReturn");
|
||||
if (btnReturn != null)
|
||||
{
|
||||
UIManager.AddEvent(btnReturn.gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
UIManager.ShowRaceHomePanel(true);
|
||||
});
|
||||
}
|
||||
avatar = transform.Find("Avatar");
|
||||
if (avatar != null)
|
||||
{
|
||||
Utils.DisplayImage(avatar.GetComponent<RawImage>(), App.CurrentUser.WxHeadImg, true);
|
||||
UIManager.AddEvent(avatar.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowUserInfoPanel();
|
||||
});
|
||||
}
|
||||
Refresh();
|
||||
}
|
||||
|
||||
private async Task Login()
|
||||
{
|
||||
var result = await ConfigHelper.userApi.Login("13115011550", "laozhong", "");
|
||||
App.CurrentUser = result.data;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetAxis("Mouse ScrollWheel") != 0)
|
||||
{
|
||||
Debug.Log(scroll.GetComponent<ScrollRect>().verticalNormalizedPosition);
|
||||
if (scroll.GetComponent<ScrollRect>().verticalNormalizedPosition <= 0 ||
|
||||
scroll.GetComponent<ScrollRect>().verticalNormalizedPosition >= (pageIndex == 0 ? 1.2 : 1))
|
||||
{
|
||||
startMouse = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (startMouse)
|
||||
{
|
||||
startMouse = false;
|
||||
OnEndDrag(null);
|
||||
}
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Return))
|
||||
{
|
||||
onEndEdit();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEndDrag(BaseEventData arg0)
|
||||
{
|
||||
var scrollrect = scroll.GetComponent<ScrollRect>();
|
||||
Debug.Log(scrollrect.verticalNormalizedPosition);
|
||||
if (scrollrect.verticalNormalizedPosition <= 0)
|
||||
{
|
||||
pageIndex++;
|
||||
GetList();
|
||||
}
|
||||
if (scrollrect.verticalNormalizedPosition >= (pageIndex == 0 ? 1.2 : 1))
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
content.transform.DestroyChildren();
|
||||
pageIndex = 0;
|
||||
isEnd = false;
|
||||
GetList();
|
||||
}
|
||||
|
||||
private async void GetList()
|
||||
{
|
||||
if (isEnd) return;
|
||||
var res = await ConfigHelper.mapCompetitionApi.GetCompetitionListV2(raceName, pageIndex,pageSize,
|
||||
status:string.Join(",", statusOptions),self:isReserve,order:order);
|
||||
if (res.result)
|
||||
{
|
||||
if (res.data.Count == 0)
|
||||
{
|
||||
if (pageIndex != 0)
|
||||
{
|
||||
isEnd = true;
|
||||
scroll.transform.Find("Error").gameObject.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("当前没查到内容");
|
||||
scroll.transform.Find("Error").gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isEnd = false;
|
||||
DisplayMaps(res.data);
|
||||
scroll.transform.Find("Error").gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DisplayMaps(List<MapCompetition> list)
|
||||
{
|
||||
GameObject smallGame = Resources.Load<GameObject>("UI/Prefab/Race/ItemSmall");
|
||||
foreach (var map in list)
|
||||
{
|
||||
var game = Instantiate<GameObject>(smallGame);
|
||||
game.GetComponent<RaceItemScript>().Initial(map, transform);
|
||||
game.transform.SetParent(scroll.GetComponent<ScrollRect>().content);
|
||||
game.transform.localScale = Vector3.one;
|
||||
}
|
||||
}
|
||||
void onEndEdit()
|
||||
{
|
||||
var t = searchInput.GetComponent<InputField>().text;
|
||||
raceName = t;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82b3faa60bd657241a826920f2d8ad14
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,82 @@
|
||||
using Assets.Scripts;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class RaceScript : PFUIPanel
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
protected Transform currentItem { get; set; }
|
||||
protected void StartTime()
|
||||
{
|
||||
timerFlag = true;
|
||||
StartCoroutine(Timer());
|
||||
}
|
||||
protected void StopTime()
|
||||
{
|
||||
timerFlag = false;
|
||||
}
|
||||
/// <summary>
|
||||
/// 通过消息调用,子给父传
|
||||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
public void SetCurrentItem(Transform t)
|
||||
{
|
||||
currentItem = t;
|
||||
HandleTime();
|
||||
if (t != null)
|
||||
{
|
||||
StartTime();
|
||||
}
|
||||
else
|
||||
{
|
||||
StopTime();
|
||||
}
|
||||
}
|
||||
/*参考代码
|
||||
var second = Math.Ceiling((Now - mapCompetition.StartTime.ToLocalTime()).TotalSeconds);
|
||||
|
||||
var ts = TimeSpan.FromSeconds(second);
|
||||
return $"{ (int)ts.TotalHours }:{ts:mm}:{ts:ss}";*/
|
||||
private bool timerFlag = false;
|
||||
IEnumerator Timer()
|
||||
{
|
||||
while (timerFlag)
|
||||
{
|
||||
yield return new WaitForSeconds(1.0f); // 停止执行1秒
|
||||
HandleTime();
|
||||
//time = UIManager.Now.GetDateTime().AddSeconds(1);
|
||||
}
|
||||
}
|
||||
private void HandleTime()
|
||||
{
|
||||
if (currentItem != null && currentItem.Find("GetReadyContainer").gameObject.activeSelf)
|
||||
{
|
||||
var map = currentItem.GetComponent<RaceItemScript>().mapCompetition;
|
||||
var time = map.StartTime.ToLocalTime() - UIManager.Now.GetDateTime();
|
||||
if (time.TotalSeconds < 0)
|
||||
{
|
||||
currentItem.Find("GetReadyContainer").GetComponent<CanvasGroup>().alpha = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentItem.Find("GetReadyContainer").GetComponent<CanvasGroup>().alpha = 1;
|
||||
currentItem.Find("GetReadyContainer/Value").GetComponent<Text>().text
|
||||
= Utils.GetCountDown(time);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 381020fe46b984f4c9188b95655c0ee4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class RaceBookedScript : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
//private enum ReserveType {1,2,3,4}
|
||||
[SerializeField]
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c08a8330773871469117ac971e01821
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -151,6 +151,7 @@ public class ResultListController : MonoBehaviour
|
||||
{
|
||||
var index = sindex ?? scrollIndex;
|
||||
if (isEnd[index]) return;
|
||||
Debug.Log(sindex);
|
||||
var r = await ConfigHelper.mapInterruptRecordApi.GetMapInterruptRecord(name, pageIndex[index], 20,filterOptionDict[index]);
|
||||
|
||||
if (r.result)
|
||||
|
||||
@@ -93,7 +93,12 @@ public class RouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandle
|
||||
right.gameObject.SetActive(true);
|
||||
gameObject.GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
Application.OpenURL(result.ViewUrl + "?Token=" + App.CurrentUser.cookie);
|
||||
var url = result.ViewUrl + "?Token=" + App.CurrentUser.cookie;
|
||||
if (index == 1)
|
||||
{
|
||||
url += "&raceId="+result.MapCompetitionId;
|
||||
}
|
||||
Application.OpenURL(url);
|
||||
});
|
||||
|
||||
this.index = index;
|
||||
|
||||
Reference in new issue
Block a user