134 lines
5.1 KiB
C#
134 lines
5.1 KiB
C#
using UnityEngine;
|
|
using DG.Tweening;
|
|
using Assets.Scenes.Ride.Scripts.Model;
|
|
using UnityEngine.EventSystems;
|
|
|
|
namespace Assets.Scenes.Ride.Scripts
|
|
{
|
|
public class SingleUIManager : BaseUIManager
|
|
{
|
|
protected override void Start()
|
|
{
|
|
base.Start();
|
|
|
|
UIManager.AddEvent(startBtn.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, StartRide);
|
|
UIManager.AddEvent(singleButton.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, SingleRide);
|
|
UIManager.AddEvent(shadowButton.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, ShadowRide);
|
|
UIManager.AddEvent(addButton.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, ShowSelectPlayer);
|
|
|
|
selectPanel.SetActive(true);//显示选择单人、影子骑行模式
|
|
}
|
|
protected override void Update()
|
|
{
|
|
base.Update();
|
|
CountDown();
|
|
}
|
|
//继续骑行如果有伴侣就自动进入伴侣骑行
|
|
public override void ContinueRide()
|
|
{
|
|
if (mainController.routeResult != null)
|
|
{
|
|
#region 注释伴侣骑行的重骑和继续骑行的逻辑
|
|
//if (mainController.routeResult.Mode == CyclingModel.Review.ToString())
|
|
//{
|
|
// mainController.SetCyclingModel(CyclingModel.Review);
|
|
// selectPanel.SetActive(false);
|
|
// var reviewFactory = reviewPanel.transform.GetComponent<ReviewFactory>();
|
|
// reviewFactory.Refresh();
|
|
//}
|
|
#endregion
|
|
if (mainController.routeResult.Mode == CyclingModel.Single.ToString())
|
|
{
|
|
mainController.SetCyclingModel(CyclingModel.Single);
|
|
selectPanel.SetActive(false);
|
|
}
|
|
//显示附近的人面板
|
|
nearByPanel.SetActive(true);
|
|
}
|
|
}
|
|
//倒计时
|
|
private void CountDown()
|
|
{
|
|
if (count > 0)
|
|
{
|
|
timeRemaining -= Time.deltaTime;
|
|
if (timeRemaining <= 0)//定时器
|
|
{
|
|
count--;
|
|
if (count == 0)
|
|
{
|
|
mainController.SetStart();
|
|
var canvasGroup = countDownTxt.transform.GetComponent<CanvasGroup>();
|
|
canvasGroup.DOFade(0, 1).onComplete+=()=> {
|
|
countDownTxt.gameObject.SetActive(false);
|
|
canvasGroup.alpha = 1;
|
|
};
|
|
}
|
|
if (count == 1 && mainController.cyclingModel == CyclingModel.Single)
|
|
{
|
|
reviewPanel.GetComponent<CanvasGroup>().DOFade(0, 1).onComplete += () => {
|
|
reviewPanel.gameObject.SetActive(false);
|
|
};
|
|
//附近的人
|
|
// nearByPanel.GetComponent<CanvasGroup>().DOFade(0, 1);
|
|
}
|
|
|
|
countDownTxt.transform.DOPunchScale(new Vector3(1.2f, 1.2f, 1.2f),1,1,1);
|
|
timeRemaining = 1.0f;
|
|
}
|
|
}
|
|
countDownTxt.text = count==0?"GO!": count.ToString();
|
|
}
|
|
//重置游戏状态
|
|
public void Reset()
|
|
{
|
|
mainController.isStart = false;
|
|
mainController.isPause = false;
|
|
mainController.isQuit = false;
|
|
count = 0;
|
|
countDownTxt.gameObject.SetActive(false);
|
|
}
|
|
//单人骑行
|
|
private void SingleRide(BaseEventData baseEventData)
|
|
{
|
|
selectPanel.SetActive(false);
|
|
mainController.SetCyclingModel(CyclingModel.Single);
|
|
//显示单人骑行列表
|
|
reviewPanel.SetActive(true);
|
|
//显示附近的人列表
|
|
nearByPanel.SetActive(true);
|
|
}
|
|
//伴侣骑行
|
|
private void ShadowRide(BaseEventData baseEventData)
|
|
{
|
|
selectPanel.SetActive(false);
|
|
//显示影子选手骑行列表
|
|
selectPlayer.SetActive(true);
|
|
selectPlayer.GetComponent<SelectPlayerFactory>().Refresh();
|
|
//显示附近的人列表
|
|
nearByPanel.SetActive(true);
|
|
}
|
|
//伴侣骑行选择界面
|
|
private void ShowSelectPlayer(BaseEventData baseEventData)
|
|
{
|
|
Reset();
|
|
selectPlayer.SetActive(true);
|
|
selectPlayer.GetComponent<SelectPlayerFactory>().Refresh();
|
|
}
|
|
//开始游戏触发事件
|
|
public void StartRide(BaseEventData baseEventData)
|
|
{
|
|
this.StartRide();
|
|
}
|
|
//开始骑行-加个5秒钟倒计时
|
|
public override void StartRide()
|
|
{
|
|
count = 5;
|
|
startPanel.SetActive(false);
|
|
startBtn.gameObject.SetActive(false);
|
|
countDownTxt.gameObject.SetActive(true);
|
|
countDownTxt.text = count.ToString();
|
|
}
|
|
}
|
|
}
|