Merge remote-tracking branch 'origin/dev_cyp' into dev_lishuo

# Conflicts:
#	Assets/Scripts/UI/Prefab/Race/RaceButtonGroupScript.cs
This commit is contained in:
lishuo committed 2021-07-26 14:11:10 +08:00
commit 7d0128d912
15 files changed
+1095 -109

No files matched your search

@@ -92,12 +92,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 =>
{
@@ -141,16 +153,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)
{
@@ -159,8 +170,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()
{
@@ -180,8 +203,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;
@@ -198,7 +236,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()
{