AR骑行和对战
This commit is contained in:
1 parent
341d386196
commit
3bcb3ee83e
51 files changed
+146686
-4950
No files matched your search
@@ -0,0 +1,97 @@
|
||||
using Assets.Scenes.Ride.Scripts;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.Scenes.Scripts
|
||||
{
|
||||
class GameRoomPlayerList : MonoBehaviour
|
||||
{
|
||||
private CyclingController manager { get; set; }
|
||||
protected GameObject nearByItem;
|
||||
protected GameObject nearByMajorItem;
|
||||
public Transform parent;
|
||||
|
||||
private Text num;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
manager = FindObjectOfType<CyclingController>();
|
||||
nearByMajorItem = Resources.Load<GameObject>("UI/Prefab/Match/CompetitionRankingMajorItem");
|
||||
nearByItem = Resources.Load<GameObject>("UI/Prefab/Match/CompetitionRankingItem");
|
||||
num = transform.Find("Head/OnlineUserNum").GetComponent<Text>();
|
||||
}
|
||||
|
||||
private void InitData()
|
||||
{
|
||||
Utils.DestroyChildren(parent);
|
||||
manager = FindObjectOfType<CyclingController>();
|
||||
var list = MapUDPService.GetOnlineUsers(App.RouteIdParam, manager.roomId).OrderByDescending(c=>c.EndDistance);
|
||||
int index = 1;
|
||||
num.text = list.Count().ToString();
|
||||
foreach (var item in list)
|
||||
{
|
||||
GameObject prefabItem = item.IsSelf ? nearByMajorItem : nearByItem;
|
||||
GameObject newObj = (GameObject)Instantiate(prefabItem, parent);
|
||||
var competitionRankingItem = newObj.GetComponent<CompetitionRankingItem>();
|
||||
competitionRankingItem.setUserId(item.Id);
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
competitionRankingItem.SetRank(index);
|
||||
#else
|
||||
competitionRankingItem.SetRank(index);
|
||||
#endif
|
||||
competitionRankingItem.setName(item.Name);
|
||||
competitionRankingItem.setRatio(item.WeightKg.ToString("f2") + "W/KG");
|
||||
competitionRankingItem.setSpeed(item.Speed.ToString() + "KM/H");
|
||||
competitionRankingItem.setHead(item.HeadImage);
|
||||
var countryTexture = manager.GetCountryImageByName(item.Country);
|
||||
competitionRankingItem.setCountry(countryTexture);
|
||||
var near = Math.Round((item.EndDistance - manager.currentPlayer.TotalDistance) * 1000);
|
||||
competitionRankingItem.setDistance(manager.currentPlayer.UserId == item.Id ? "0M" : near.ToString() + "M");
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
competitionRankingItem.transform.SetSiblingIndex(index);
|
||||
#else
|
||||
competitionRankingItem.transform.SetSiblingIndex(index);
|
||||
#endif
|
||||
index++;
|
||||
}
|
||||
}
|
||||
float timer = 0f;
|
||||
private void Update()
|
||||
{
|
||||
timer -= Time.deltaTime;
|
||||
while (timer < 0)
|
||||
{
|
||||
InitData();
|
||||
//if (manager.currentPlayer == null)
|
||||
|
||||
//var totalDitance = manager.GetMapData().TotalDistance;
|
||||
//var currentDistance = manager.currentPlayer.TotalDistance;
|
||||
////var currenList = GetComponentsInChildren<ListItem>(true);
|
||||
//var list = MapUDPService.GetOnlineUsers(App.RouteIdParam, manager.cyclingController.recorderData.RoomId);
|
||||
//var currentPlayerInfo = list.Where(c => c.Id.ToString() == manager.currentPlayer.UserId.ToString()).FirstOrDefault();
|
||||
//list = list.Where(c => c.Id != App.CurrentUser.Id).ToList();
|
||||
//var currentPlayer = FindObjectOfType<AbstractPlayer>();
|
||||
|
||||
//foreach (ListItem o in currenList)
|
||||
//{
|
||||
// if (currentPlayer.UserId.ToString() == o.Id)
|
||||
// continue;
|
||||
// var needUpdate = list.Where(c => c.Id.ToString() == o.Id).FirstOrDefault();
|
||||
// if (needUpdate != null && currentPlayerInfo != null)
|
||||
// {
|
||||
// var left = Math.Round((needUpdate.EndDistance - currentPlayerInfo.EndDistance) * 1000);
|
||||
// o.UpdateItem(needUpdate.Name, left.ToString() + "M", needUpdate.Id.ToString());
|
||||
// o.gameObject.SetActive(true);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// o.gameObject.SetActive(false);
|
||||
// }
|
||||
//}
|
||||
timer += 1f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0c6a7cf3e8b68c48bf9e6c13a25a97a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,282 @@
|
||||
using Assets.Scenes.Ride.Scripts.Model.CyclingModels;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.UI.UIEffect;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
using Facebook.Unity;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
public class GameRoomResultScript : MonoBehaviour
|
||||
{
|
||||
CyclingController cyclingController;
|
||||
RawImage Head;
|
||||
Text Ranking;
|
||||
Text Timer;
|
||||
GameObject Mine { get; set; }
|
||||
GameObject TitleImage { get; set; }
|
||||
GameObject WatchTitle { get; set; }
|
||||
GameObject RankingPanel { get; set; }
|
||||
GameObject ShareButton { get; set; }
|
||||
GameObject ToolBarPanel { get; set; }
|
||||
GameObject WeChatButton { get; set; }
|
||||
GameObject WeChatGpButton { get; set; }
|
||||
|
||||
|
||||
RawImage TopHead { get; set; }
|
||||
RawImage SecondHead { get; set; }
|
||||
RawImage ThirdHead { get; set; }
|
||||
Image Top { get; set; }
|
||||
Sprite SpriteTop { get; set; }
|
||||
Sprite SpriteSecond { get; set; }
|
||||
Sprite SpriteThrid { get; set; }
|
||||
|
||||
Text RankingTitle { get; set; }
|
||||
Text TimerTitle { get; set; }
|
||||
Text CloseTime { get; set; }
|
||||
Text CloseTitle { get; set; }
|
||||
private void Awake()
|
||||
{
|
||||
cyclingController = FindObjectOfType<CyclingController>();
|
||||
var closeBtn = transform.Find("Close").gameObject;
|
||||
Head = transform.Find("Mine/Head").GetComponent<RawImage>();
|
||||
Ranking = transform.Find("Mine/Ranking").GetComponent<Text>();
|
||||
RankingTitle = transform.Find("Mine/RankingTitle").GetComponent<Text>();
|
||||
TimerTitle = transform.Find("Mine/TimerTitle").GetComponent<Text>();
|
||||
Timer = transform.Find("Mine/Timer").GetComponent<Text>();
|
||||
Top = transform.Find("Mine/TOP").GetComponent<Image>();
|
||||
Mine = transform.Find("Mine").gameObject;
|
||||
RankingPanel = transform.Find("Ranking").gameObject;
|
||||
TopHead = transform.Find("Ranking/TopHead").GetComponent<RawImage>();
|
||||
SecondHead = transform.Find("Ranking/SecondHead").GetComponent<RawImage>();
|
||||
ThirdHead = transform.Find("Ranking/ThirdHead").GetComponent<RawImage>();
|
||||
TitleImage = transform.Find("TitleImage").gameObject;
|
||||
WatchTitle = transform.Find("WatchTitle").gameObject;
|
||||
CloseTitle = transform.Find("CloseTitle").GetComponent<Text>();
|
||||
CloseTime = transform.Find("CloseTime").GetComponent<Text>();
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
ShareButton = transform.Find("ShareButton").gameObject;
|
||||
ToolBarPanel = transform.Find("ToolBarPanel").gameObject;
|
||||
WeChatButton = transform.Find("ToolBarPanel/WeChatButton").gameObject;
|
||||
WeChatGpButton = transform.Find("ToolBarPanel/GoogleButton").gameObject;
|
||||
UIManager.AddEvent(WeChatButton, UnityEngine.EventSystems.EventTriggerType.PointerClick, ShareWechat);
|
||||
UIManager.AddEvent(WeChatGpButton, UnityEngine.EventSystems.EventTriggerType.PointerClick, ShareWechatGp);
|
||||
var fbButton = transform.Find("ToolBarPanel/FaceBookButton").gameObject;
|
||||
UIManager.AddEvent(fbButton, EventTriggerType.PointerClick, shareFb);
|
||||
#endif
|
||||
SpriteTop = Resources.Load<Sprite>("Images/Ride/Match/top-1");
|
||||
SpriteSecond = Resources.Load<Sprite>("Images/Ride/Match/top-2");
|
||||
SpriteThrid = Resources.Load<Sprite>("Images/Ride/Match/top-3");
|
||||
|
||||
UIManager.AddEvent(closeBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, Close);
|
||||
}
|
||||
|
||||
|
||||
float time = 1;
|
||||
private void Update()
|
||||
{
|
||||
//var model = cyclingController.cyclingController as GameModel;
|
||||
//if (model != null)
|
||||
//{
|
||||
///var s = model.EndCountDown();
|
||||
//显示关门时间
|
||||
//var isshow = s.Item3 && s.Item1 >= 0 && !cyclingController.isWatch;
|
||||
//CloseTime.text = Helper.FormatTicks(s.Item1);
|
||||
//CloseTitle.gameObject.SetActive(isshow);
|
||||
//CloseTime.gameObject.SetActive(isshow);
|
||||
//}
|
||||
time -= Time.deltaTime;
|
||||
while (time < 0)
|
||||
{
|
||||
Refresh();
|
||||
time += 1;
|
||||
}
|
||||
}
|
||||
|
||||
private Color RED = new Color(0.9764706f, 0.1882353f, 0.5254902f);
|
||||
private Color SHALLOW_RED = new Color(1f, 0.454902f, 0.5215687f);
|
||||
|
||||
private Color PURPLE = new Color(0.1568628f, 0.4431373f, 0.8745098f);
|
||||
private Color SHALLOW_PURPLE = new Color(0.3843137f, 0.7764706f, 1f);
|
||||
|
||||
private Color BLUE = new Color(0.4352941f, 0.3333333f, 0.9372549f);
|
||||
private Color SHALLOW_BLUE = new Color(0.772549f, 0.5529412f, 1f);
|
||||
|
||||
private Color WHITE = new Color(1f, 1f, 1f);
|
||||
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
if (cyclingController.cyclingController is GameModel model)
|
||||
{
|
||||
var list = model?.mapWorkoutRecordRankings;
|
||||
if (list == null) return;
|
||||
var parent = transform.Find("ScrollView/Viewport/Content");
|
||||
|
||||
Mine.SetActive(!cyclingController.isWatch);
|
||||
RankingPanel.SetActive(cyclingController.isWatch);
|
||||
TitleImage.SetActive(!cyclingController.isWatch);
|
||||
WatchTitle.SetActive(cyclingController.isWatch);
|
||||
|
||||
if (model.FirstEndTime.HasValue)
|
||||
{
|
||||
var gap = model.FirstEndTime.Value - UIManager.Now.GetDateTime();
|
||||
var seconds = (int)Math.Floor(gap.TotalSeconds);
|
||||
CloseTime.text = Helper.FormatTicks(seconds);
|
||||
CloseTitle.gameObject.SetActive(true);
|
||||
CloseTime.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
if (!cyclingController.isWatch)
|
||||
{
|
||||
//当前用户排名
|
||||
var currentRanking = list.Where(c => c.UserId == cyclingController.currentPlayer.UserId).FirstOrDefault();
|
||||
if (currentRanking != null)
|
||||
{
|
||||
Utils.DisplayImage(Head, currentRanking.WxHeadImg, true);
|
||||
Ranking.text = currentRanking.Rank.ToString().PadLeft(3, '0');
|
||||
Timer.text = currentRanking.TotalTime;
|
||||
var uigradient = Mine.transform.GetComponent<UIGradient>();
|
||||
if (currentRanking.Rank <= 3)
|
||||
{
|
||||
TimerTitle.color = WHITE;
|
||||
RankingTitle.color = WHITE;
|
||||
}
|
||||
if (currentRanking.Rank == 1)
|
||||
{
|
||||
uigradient.color1 = RED;
|
||||
uigradient.color2 = SHALLOW_RED;
|
||||
Top.sprite = SpriteTop;
|
||||
Top.gameObject.SetActive(true);
|
||||
}
|
||||
if (currentRanking.Rank == 2)
|
||||
{
|
||||
uigradient.color1 = PURPLE;
|
||||
uigradient.color2 = SHALLOW_PURPLE;
|
||||
Top.sprite = SpriteSecond;
|
||||
Top.gameObject.SetActive(true);
|
||||
}
|
||||
if (currentRanking.Rank == 3)
|
||||
{
|
||||
uigradient.color1 = BLUE;
|
||||
uigradient.color2 = SHALLOW_BLUE;
|
||||
Top.sprite = SpriteThrid;
|
||||
Top.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//观察者模式左边显示前三名
|
||||
var topList = list.OrderBy(c => c.Rank).Take(3);
|
||||
foreach (var item in topList)
|
||||
{
|
||||
if (item.Rank == 1)
|
||||
{
|
||||
Utils.DisplayImage(TopHead, item.WxHeadImg, true);
|
||||
var name = TopHead.transform.Find("Name").GetComponent<Text>();
|
||||
name.text = item.NickName;
|
||||
TopHead.gameObject.SetActive(true);
|
||||
}
|
||||
if (item.Rank == 2)
|
||||
{
|
||||
Utils.DisplayImage(SecondHead, item.WxHeadImg, true);
|
||||
var name = SecondHead.transform.Find("Name").GetComponent<Text>();
|
||||
name.text = item.NickName;
|
||||
SecondHead.gameObject.SetActive(true);
|
||||
}
|
||||
if (item.Rank == 3)
|
||||
{
|
||||
Utils.DisplayImage(ThirdHead, item.WxHeadImg, true);
|
||||
var name = ThirdHead.transform.Find("Name").GetComponent<Text>();
|
||||
name.text = item.NickName;
|
||||
ThirdHead.gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//排名列表
|
||||
var rankingList = FindObjectsOfType<FinalRankingItemScript>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var finalRankingItemScript = rankingList.Where(c => c.UserId == item.UserId).FirstOrDefault();
|
||||
//没有就创建
|
||||
if (finalRankingItemScript == null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
var finalRankingItem = Instantiate(Resources.Load<GameObject>("UI/Prefab/Match/Mobile/FinalRankingItem"), parent);
|
||||
#else
|
||||
var finalRankingItem = Instantiate(Resources.Load<GameObject>("UI/Prefab/Match/FinalRankingItem"), parent);
|
||||
#endif
|
||||
finalRankingItemScript = finalRankingItem.GetComponent<FinalRankingItemScript>();
|
||||
}
|
||||
|
||||
//有就更新
|
||||
finalRankingItemScript.setGap(item.Gap);
|
||||
//finalRankingItemScript.setSource(item.de);
|
||||
finalRankingItemScript.setUserId(item.UserId, item.WxHeadImg);
|
||||
finalRankingItemScript.setRanking(item.Rank);
|
||||
finalRankingItemScript.setHeartRate(item.HeartRate);
|
||||
finalRankingItemScript.setName(item.NickName);
|
||||
finalRankingItemScript.setPower(item.Power.ToString());
|
||||
finalRankingItemScript.setRatio(item.WeightKG);
|
||||
finalRankingItemScript.setTimer(item.TotalTime);
|
||||
finalRankingItemScript.transform.SetSiblingIndex(item.Rank);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Close(BaseEventData baseEventData)
|
||||
{
|
||||
this.gameObject.SetActive(false);
|
||||
this.Destroy();
|
||||
SceneManager.LoadScene("MainScene");
|
||||
//App.MainSceneParam["Name"] = "RaceHomePanel";
|
||||
}
|
||||
|
||||
private void OpenShare(BaseEventData baseEventData)
|
||||
{
|
||||
((RectTransform)ToolBarPanel.transform).pivot = new Vector2(0, ((RectTransform)ToolBarPanel.transform).pivot.y);
|
||||
ShareButton.SetActive(false);
|
||||
ToolBarPanel.transform.DOScaleX(1, 1);
|
||||
}
|
||||
|
||||
private void ShareWechat(BaseEventData baseEventData)
|
||||
{
|
||||
if (!App.weChatController.IsWeChatAppInstalled())
|
||||
{
|
||||
App.weChatController.ShareWebpageToWX(0, $"{App.CurrentUser.WebHost}Mine/MatchPreview?id={cyclingController.competitionId}&Token={App.CurrentUser.cookie}", cyclingController.competition.Title, "By " + App.CurrentUser.Nickname, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.showToast(null, "未安装微信");
|
||||
}
|
||||
}
|
||||
private void shareFb(BaseEventData arg0)
|
||||
{
|
||||
//cyclingController.competition.Title, "By " + App.CurrentUser.Nickname, null)
|
||||
FB.ShareLink(contentURL: new Uri($"{App.CurrentUser.WebHost}Mine/MatchPreview?id={cyclingController.competitionId}&Token={App.CurrentUser.cookie}"),
|
||||
contentTitle: cyclingController.competition.Title,
|
||||
contentDescription: "By " + App.CurrentUser.Nickname,
|
||||
photoURL: new Uri(cyclingController.competition.CoverImage));
|
||||
}
|
||||
|
||||
private void ShareWechatGp(BaseEventData baseEventData)
|
||||
{
|
||||
if (App.weChatController.IsWeChatAppInstalled())
|
||||
{
|
||||
App.weChatController.ShareWebpageToWX(1, $"{App.CurrentUser.WebHost}Mine/MatchPreview?id={cyclingController.competitionId}&Token={App.CurrentUser.cookie}", cyclingController.competition.Title, "By " + App.CurrentUser.Nickname, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.showToast(null, "未安装微信");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 180198074f4b2344d8fd96e8e068324b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,260 @@
|
||||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
using Assets.Scenes.Ride.Scripts.Model;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
using Assets.Scenes.Ride.Scripts.Model.CyclingModels;
|
||||
using System;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
public class GameRoomUIManager : BaseUIManager
|
||||
{
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
}
|
||||
GameObject countDownPanel { get; set; }
|
||||
Text title { get; set; }
|
||||
Text timer { get; set; }
|
||||
GameObject raceViewBtn { get; set; }
|
||||
GameObject timerIcon { get; set; }
|
||||
|
||||
GameModel model { get; set; }
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
|
||||
reviewPanel.SetActive(false);
|
||||
//隐藏单人骑行时间
|
||||
var spilitLineH2 = uipanel.transform.Find("ComputerPanel/SpilitLineH2").gameObject;
|
||||
raceViewBtn = uipanel.transform.Find("RaceViewButton").gameObject;
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
timerIcon = uipanel.transform.Find("ComputerPanel/TimerIcon").gameObject;
|
||||
timerIcon.SetActive(false);
|
||||
#else
|
||||
viewButton.gameObject.SetActive(false);
|
||||
#endif
|
||||
|
||||
UIManager.AddEvent(raceViewBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, ChangeView);
|
||||
|
||||
spilitLineH2.SetActive(false);
|
||||
//timerTxt.gameObject.SetActive(false);
|
||||
//timerTxtTitle.gameObject.SetActive(false);
|
||||
//观察者模式隐藏坡度
|
||||
if (mainController.isWatch)
|
||||
{
|
||||
nextSlopePanel.SetActive(false);
|
||||
currentSlopePanel.SetActive(false);
|
||||
}
|
||||
altitudeGraph.gameObject.SetActive(false);
|
||||
//暂停按钮禁用
|
||||
pauseButton.interactable = false;
|
||||
InitGameObject();
|
||||
}
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
CountDown();
|
||||
}
|
||||
|
||||
//开始游戏触发事件
|
||||
public void StartRide(BaseEventData baseEventData)
|
||||
{
|
||||
this.StartRide();
|
||||
}
|
||||
|
||||
public void StartRide(int seconds)
|
||||
{
|
||||
mainController.SetCyclingModel(CyclingModel.GameRoom);
|
||||
count = seconds;
|
||||
startPanel.SetActive(false);
|
||||
startBtn.gameObject.SetActive(false);
|
||||
countDownTxt.gameObject.SetActive(true);
|
||||
countDownTxt.text = count.ToString();
|
||||
}
|
||||
bool canStart = false;
|
||||
GameObject watchPanel { get; set; }
|
||||
//开始骑行-加个5秒钟倒计时
|
||||
public override void StartRide()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void InitGameObject()
|
||||
{
|
||||
miniMap.SetActive(false); //隐藏小地图
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
countDownPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Match/Mobile/CountDownPanel"), uipanel.transform);
|
||||
title = countDownPanel.transform.Find("Title").GetComponent<Text>();
|
||||
timer = countDownPanel.transform.Find("Timer").GetComponent<Text>();
|
||||
competitionRankingList = Instantiate(Resources.Load<GameObject>("UI/Prefab/Match/Mobile/CompetitionRankingPanel"), uipanel.transform);
|
||||
topRankPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Match/Mobile/TopRankPanel"), uipanel.transform);
|
||||
watchPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Match/Mobile/WatcherPanel"), uipanel.transform);
|
||||
#else
|
||||
//countDownPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Match/CountDownPanel"), uipanel.transform);
|
||||
//title = countDownPanel.transform.Find("Title").GetComponent<Text>();
|
||||
//timer = countDownPanel.transform.Find("Timer").GetComponent<Text>();
|
||||
competitionRankingList = Instantiate(Resources.Load<GameObject>("UI/Prefab/GameRoom/GameRoomRankingPanel"), uipanel.transform);
|
||||
topRankPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Match/TopRankPanel"), uipanel.transform);
|
||||
//watchPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Match/WatcherPanel"), uipanel.transform);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
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);
|
||||
};
|
||||
}
|
||||
countDownTxt.transform.DOPunchScale(new Vector3(1.2f, 1.2f, 1.2f), 1, 1, 1);
|
||||
timeRemaining = 1.0f;
|
||||
}
|
||||
}
|
||||
countDownTxt.text = count == 0 ? App.GetLocalString("GO!") : count.ToString();
|
||||
model = mainController.cyclingController as GameModel;
|
||||
//第一名诞生开始倒计时,倒计时结束自动保存
|
||||
if (model != null && model.FirstEndTime.HasValue && !FirstCompleted && App.CurrentUser.Id != model.FirstUserId)
|
||||
{
|
||||
FirstCompleted = true;
|
||||
var gap = model.FirstEndTime.Value - UIManager.Now.GetDateTime();
|
||||
var seconds = Math.Floor(gap.TotalSeconds);
|
||||
UIManager.ShowGameRoomCountDownPanel((int)seconds, () =>
|
||||
{
|
||||
SaveRide(null);
|
||||
}, true);
|
||||
}
|
||||
if (mainController.isQuit && !Saved)
|
||||
{
|
||||
Saved = true;
|
||||
ShowResultList();
|
||||
FindObjectOfType<GameRoomCountDownController>()?.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private bool FirstCompleted;
|
||||
|
||||
private bool Saved;
|
||||
|
||||
public override void SaveRide(BaseEventData baseEventData)
|
||||
{
|
||||
//观察者退出
|
||||
if (mainController.isWatch)
|
||||
{
|
||||
SceneManager.LoadScene("MainScene");
|
||||
return;
|
||||
}
|
||||
//参赛者保存并弹出赛事结果
|
||||
if (!mainController.isQuit)
|
||||
{
|
||||
mainController.SetQuit();
|
||||
playerController.Upload();
|
||||
quitPanel.SetActive(false);
|
||||
transform.Find("ModalPanel").gameObject.SetActive(false);
|
||||
}
|
||||
ShowResultList();//保存显示当前排名
|
||||
}
|
||||
|
||||
public override void ContinueRide()
|
||||
{
|
||||
//mainController.SetCyclingModel(CyclingModel.GameRoom);
|
||||
}
|
||||
public override void PauseRide(BaseEventData baseEventData)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//实时显示当前比赛排名
|
||||
GameObject competitionRankingList;
|
||||
public void ShowCurrentRanking()
|
||||
{
|
||||
if (competitionRankingList == null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
competitionRankingList = Instantiate(Resources.Load<GameObject>("UI/Prefab/Match/Mobile/CompetitionRankingPanel"), uipanel.transform);
|
||||
#else
|
||||
competitionRankingList = Instantiate(Resources.Load<GameObject>("UI/Prefab/GameRoom/GameRoomRankingPanel"), uipanel.transform);
|
||||
#endif
|
||||
}
|
||||
if (topRankPanel == null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
topRankPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Match/Mobile/TopRankPanel"), uipanel.transform);
|
||||
#else
|
||||
topRankPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Match/TopRankPanel"), uipanel.transform);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
GameObject competitionResultPanel;
|
||||
GameObject topRankPanel;
|
||||
//实时刷新显示比赛结果
|
||||
public void ShowResultList()
|
||||
{
|
||||
if (competitionResultPanel == null)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
competitionResultPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Match/Mobile/GameRoomResultPanel"), uipanel.transform);
|
||||
#else
|
||||
competitionResultPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/GameRoom/GameRoomResultPanel"), uipanel.transform);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//极简模式
|
||||
public override void ClearPanel(BaseEventData baseEventData)
|
||||
{
|
||||
if (clearLock)
|
||||
{
|
||||
base.ClearPanel(baseEventData);
|
||||
//countDownPanel.transform.DOLocalMove(new Vector3(countDownPanel.transform.localPosition.x + isSimple * -430f, countDownPanel.transform.localPosition.y, countDownPanel.transform.localPosition.z), 1);
|
||||
topRankPanel.transform.DOLocalMove(new Vector3(topRankPanel.transform.localPosition.x + isSimple * -430f, topRankPanel.transform.localPosition.y, topRankPanel.transform.localPosition.z), 1);
|
||||
competitionRankingList.transform.DOLocalMove(new Vector3(competitionRankingList.transform.localPosition.x + isSimple * 430f, competitionRankingList.transform.localPosition.y, competitionRankingList.transform.localPosition.z), 1);
|
||||
//watchPanel.transform.DOLocalMove(new Vector3(watchPanel.transform.localPosition.x, watchPanel.transform.localPosition.y + isSimple * 260f, watchPanel.transform.localPosition.z), 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetMobileViewButton(bool enabled)
|
||||
{
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
//viewButton.enabled = enabled;
|
||||
viewButton.interactable = enabled;
|
||||
#endif
|
||||
}
|
||||
|
||||
protected override void StopRide(BaseEventData baseEventData)
|
||||
{
|
||||
if (mainController.isWatch)
|
||||
{
|
||||
UIManager.ShowConfirm("Quit", "Do you want to quit?", async () =>
|
||||
{
|
||||
SceneManager.LoadScene("MainScene");
|
||||
UIManager.CloseConfirm();
|
||||
});
|
||||
}
|
||||
//参赛者:提醒是否退出并保存赛事结果
|
||||
else
|
||||
{
|
||||
base.StopRide(baseEventData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0821b0665a03be14c90fc2250e9b1d4c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user