78 lines
2.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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<CyclingController>();
Title = transform.Find("Title").GetComponent<Text>();
CountTimer = transform.Find("Timer").GetComponent<Text>();
TimerTitle = transform.Find("ConpetitionTimerTitle").GetComponent<Text>();
Timer = transform.Find("ConpetitionTimer").GetComponent<Text>();
competitionModel = cyclingController.cyclingController as CompetitionModel;
}
GameObject competitionResultPanel { get; set; }
private void Update()
{
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.Item2 && !isAutoSave)
{
//显示倒计时面板信息
ShowCountDown(s.Item1, "Get The First Place. Time Limit");
}
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(cyclingController.currentPlayer.TotalTicks);
}
}
}
private void ShowCountDown(int count, string text)
{
Title.text = text;
if (count >= 0)
{
CountTimer.text = Helper.FormatTicks(count);
}
}
}
}