using Assets.Scenes.Ride.Scripts.Model; using Assets.Scenes.Ride.Scripts.Model.CyclingModels; using System.Collections.Generic; using System.Linq; using UnityEngine; using UnityEngine.UI; namespace Assets.Scenes.Ride.Scripts { public class CountDownFactory : MonoBehaviour { Text Title { get; set; } Text CountTimer { get; set; } Text TimerTitle { get; set; } Text Timer { get; set; } CompetitionModel competitionModel { get; set; } CyclingController cyclingController { get; set; } private void Start() { cyclingController = FindObjectOfType(); Title = transform.Find("Title").GetComponent(); CountTimer = transform.Find("Timer").GetComponent(); TimerTitle = transform.Find("ConpetitionTimerTitle").GetComponent(); Timer = transform.Find("ConpetitionTimer").GetComponent(); } GameObject competitionResultPanel { get; set; } private void Update() { if (competitionModel == null) { competitionModel = cyclingController.cyclingController as CompetitionModel; } if (competitionModel != null) { var count = competitionModel.StartCountdown(); //比赛开始前倒计时 if (count >= 0 && !competitionModel.recorderData.Saved) { ShowCountDown(count, "Get Ready!");//显示倒计时面板信息 Timer.gameObject.SetActive(false); TimerTitle.gameObject.SetActive(false); } else { var s = competitionModel.EndCountDown(); var isAutoSave = s.Item1 <= 0 && !cyclingController.cyclingController.recorderData.Saved && !cyclingController.isWatch; //显示关门时间 if (s.Item3 && !isAutoSave) { #if UNITY_IOS || UNITY_ANDROID //显示倒计时面板信息 ShowCountDown(s.Item1, "Time Limit"); #else ShowCountDown(s.Item1, "Get The First Place. Time Limit"); #endif } else if (s.Item1 >= 0) { //显示倒计时面板信息 //ShowCountDown(s.Item1, "remaining"); ShowCountDown(s.Item1, "Remaining Time"); } //显示当前选手骑行时间 Timer.gameObject.SetActive(true); TimerTitle.gameObject.SetActive(true); Timer.text = Helper.FormatTicks(s.Item2);// Helper.FormatTicks(cyclingController.currentPlayer.TotalTicks); } } } private void ShowCountDown(int count, string text) { Title.text = text; if (count >= 0) { CountTimer.text = Helper.FormatTicks(count); } } } }