修改细节

This commit is contained in:
Caiyanpeng committed 2021-07-26 14:08:43 +08:00
1 parent b93fbd2f2e
commit 929fb0a1a7
15 files changed
+1093 -107

No files matched your search

@@ -69,20 +69,20 @@ public class HomeController : PFUIPanel
//GetSummary();
dict = new Dictionary<string, Sprite[]>
{
{
"BtnMatch",new Sprite[]
{
Resources.Load<Sprite>("Images/home/Entrance - MATCH_soon"),
Resources.Load<Sprite>("Images/home/Entrance - MATCH_soon_hover"),
}
},
{
"BtnTraining",new Sprite[]
{
Resources.Load<Sprite>("Images/home/Entrance - TRAINING_soon"),
Resources.Load<Sprite>("Images/home/Entrance - TRAINING_soon_hover"),
}
},
//{
// "BtnMatch",new Sprite[]
// {
// Resources.Load<Sprite>("Images/home/Entrance - MATCH_soon"),
// Resources.Load<Sprite>("Images/home/Entrance - MATCH_soon_hover"),
// }
//},
//{
// "BtnTraining",new Sprite[]
// {
// Resources.Load<Sprite>("Images/home/Entrance - TRAINING_soon"),
// Resources.Load<Sprite>("Images/home/Entrance - TRAINING_soon_hover"),
// }
//},
};
}
private void GoRide(BaseEventData e)
@@ -5,7 +5,7 @@ using UnityEngine;
public class RaceButtonGroupScript : MonoBehaviour
{
private Transform BtnEnter, BtnCancel, BtnWatch;
private Transform BtnEnter, BtnCancel, BtnWatch, BtnJoin;
public MapCompetition map { get; set; }
public Transform parent { get; set; }
// Start is called before the first frame update
@@ -14,6 +14,7 @@ public class RaceButtonGroupScript : MonoBehaviour
BtnEnter = transform.Find("BtnEnter");
BtnCancel = transform.Find("BtnCancel");
BtnWatch = transform.Find("BtnWatch");
BtnJoin = transform.Find("BtnJoin");
if (BtnEnter != null)
{
UIManager.AddEvent(BtnEnter.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b => GoEnter());
@@ -26,14 +27,21 @@ public class RaceButtonGroupScript : MonoBehaviour
{
UIManager.AddEvent(BtnWatch.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b => GoWatch());
}
if (BtnJoin != null)
{
UIManager.AddEvent(BtnJoin.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b => GoJoin());
}
}
void GoEnter()
void GoJoin()
{
if (!map.HasJoin)
if (!map.HasJoin)
{
parent.GetComponent<RaceItemScript>().Join();
}
Debug.Log(map);
}
void GoEnter()
{
}
void GoCancel()
{
@@ -91,12 +91,24 @@ public class RaceHomeScript : RaceScript
game.transform.SetParent(rightContainer.Find("Container-2"));
game.transform.localScale = Vector3.one;
}
for (i = 0; i < 3; i++)
for (i = 0; i < activityList.Count; i++)
{
var activity = activityList[i];
var banner = Instantiate<GameObject>(bannerItem);
var dot = Instantiate<GameObject>(dotItem);
Utils.DisplayImage(banner.GetComponent<RawImage>(), activity.BannerPreview, true);
//if (i == 0)
//{
// banner.GetComponent<RawImage>().color = Utils.HexToColorHtml("#ff0000");
//}
//else if (i == 1)
//{
// banner.GetComponent<RawImage>().color = Utils.HexToColorHtml("#00ff00");
//}
//else
//{
// banner.GetComponent<RawImage>().color = Utils.HexToColorHtml("#0000ff");
//}
UIManager.AddEvent(banner.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
@@ -138,16 +150,15 @@ public class RaceHomeScript : RaceScript
void goLeft()
{
Debug.Log($"{scroll.horizontalNormalizedPosition}");
if (scroll.horizontalNormalizedPosition<=0.0001) return;
goMove(-1);
if (scroll.horizontalNormalizedPosition <= 0.0001) goMoveEnd(1- scroll.horizontalNormalizedPosition);
else goMove(-1);
}
void goRight()
{
if (scroll.horizontalNormalizedPosition >= 0.9999) return;
if (scroll.horizontalNormalizedPosition >= 0.9999) goMoveEnd(0 - scroll.horizontalNormalizedPosition);
//if ((scroll.horizontalNormalizedPosition + contentSize) >= 1) return;
goMove();
else goMove();
}
void goMove(int i = 1)
{
@@ -156,8 +167,20 @@ public class RaceHomeScript : RaceScript
start = true;
scrollValue = i * contentSize / 20;
}
void goMoveEnd(float pos)
{
//doAni();
if (!startMoveEnd) startPosition = scroll.horizontalNormalizedPosition;
totalScrollValue = 0;
moveEndValue = pos;
scrollValue = pos / 20;
startMoveEnd = true;
}
private bool start = false;
private float scrollValue = 0, totalScrollValue = 0, startPosition = 0;
bool startMoveEnd = false;
float moveEndValue = 0;
// Update is called once per frame
private void FixedUpdate()
{
@@ -177,8 +200,23 @@ public class RaceHomeScript : RaceScript
totalScrollValue = 0;
}
}
}
if (startMoveEnd)
{
scroll.horizontalNormalizedPosition += scrollValue;
totalScrollValue += scrollValue;
if (System.Math.Abs(totalScrollValue) >= System.Math.Abs(moveEndValue))
{
scrollValue = 0;
startMoveEnd = false;
scroll.horizontalNormalizedPosition = startPosition + moveEndValue;
handleDotListMoveEnd(totalScrollValue);
Debug.Log(scrollIndex);
//Debug.Log();
totalScrollValue = 0;
}
}
}
private void handleDotList(float totalScrollValue)
{
scrollIndex = ((scrollIndex + content.childCount) + (totalScrollValue < 0 ? -1 : 1)) % content.childCount;
@@ -195,7 +233,22 @@ public class RaceHomeScript : RaceScript
}
}
}
void handleDotListMoveEnd(float totalScrollValue)
{
var dotList = scroll.transform.Find("DotList");
scrollIndex = totalScrollValue < 0 ? 0 : dotList.childCount - 1;
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()
{
@@ -51,7 +51,7 @@ public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterH
private void SetButtonGroup(MapCompetition mapCompetition)
{
if (mapCompetition.Status == 1 || mapCompetition.Status == 3 || (mapCompetition.Status == 2 && !mapCompetition.HasJoin))
if (mapCompetition.Status == 1)
{
var game = Resources.Load<GameObject>("UI/Prefab/Race/ButtonGroup/BtnContainer-Enter");
var igame = Instantiate(game);
@@ -86,11 +86,16 @@ public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterH
igame.name = "BtnContainer";
igame.GetComponent<RaceButtonGroupScript>().map = mapCompetition;
igame.GetComponent<RaceButtonGroupScript>().parent = transform;
igame.transform.Find("BtnJoin").gameObject.SetActive(mapCompetition.CanJoin);
igame.transform.Find("BtnCancel").gameObject.SetActive(mapCompetition.HasJoin);
igame.transform.SetParent(transform);
igame.transform.localScale = Vector3.one;
igame.transform.GetComponent<RectTransform>().anchorMax = new Vector2(0, 0);
igame.transform.GetComponent<RectTransform>().anchorMin = new Vector2(1, 0);
igame.transform.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0);
var loc = Vector3.zero;
loc.y = -252;
igame.transform.localPosition = loc;
loc.y = 20;
igame.transform.GetComponent<RectTransform>().anchoredPosition = loc;
}
else
{
@@ -99,11 +104,16 @@ public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterH
igame.name = "BtnContainer";
igame.GetComponent<RaceButtonGroupScript>().map = mapCompetition;
igame.GetComponent<RaceButtonGroupScript>().parent = transform;
igame.transform.Find("BtnJoin").gameObject.SetActive(mapCompetition.CanJoin);
igame.transform.Find("BtnCancel").gameObject.SetActive(mapCompetition.HasJoin);
igame.transform.SetParent(transform);
igame.transform.localScale = Vector3.one;
igame.transform.GetComponent<RectTransform>().anchorMax = new Vector2(0, 0);
igame.transform.GetComponent<RectTransform>().anchorMin = new Vector2(1, 0);
igame.transform.GetComponent<RectTransform>().pivot = new Vector2(0.5f, 0);
var loc = Vector3.zero;
loc.y = -209;
igame.transform.localPosition = loc;
loc.y = 20;
igame.transform.GetComponent<RectTransform>().anchoredPosition = loc;
}
}
}
@@ -218,12 +228,17 @@ public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterH
if (res.result)
{
mapCompetition.HasJoin = true;
mapCompetition.CanJoin = false;
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);
}
else
{
Utils.showToast(null, res.errMsg, type: 0);
}
}
async public void CancelJoin()
{
@@ -231,11 +246,16 @@ public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterH
if (res.result)
{
mapCompetition.HasJoin = false;
mapCompetition.CanJoin = true;
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);
}
else
{
Utils.showToast(null, res.errMsg, type: 0);
}
}
}