Merge remote-tracking branch 'origin/dev_cyp' into dev_lishuo
# Conflicts: # Assets/Scripts/UI/Prefab/Race/RaceButtonGroupScript.cs
This commit is contained in:
commit
7d0128d912
15 files changed
+1095
-109
No files matched your search
@@ -81,20 +81,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)
|
||||
|
||||
@@ -6,7 +6,7 @@ using UnityEngine.SceneManagement;
|
||||
|
||||
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
|
||||
@@ -15,6 +15,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());
|
||||
@@ -27,14 +28,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 GoJoin()
|
||||
{
|
||||
if (!map.HasJoin)
|
||||
{
|
||||
parent.GetComponent<RaceItemScript>().Join();
|
||||
} App.RouteIdParam = map.RouteId;
|
||||
}
|
||||
void GoEnter()
|
||||
{
|
||||
if (!map.HasJoin)
|
||||
{
|
||||
parent.GetComponent<RaceItemScript>().Join();
|
||||
}
|
||||
App.RouteIdParam = map.RouteId;
|
||||
App.RouteIdParam = map.RouteId;
|
||||
App.CompetionId = map.Id;
|
||||
SceneManager.LoadScene("Ride");
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user