加链接,文件位置
This commit is contained in:
1 parent
ae3f9d2101
commit
b93fbd2f2e
14 files changed
+7
-1
No files matched your search
@@ -0,0 +1,82 @@
|
||||
using Assets.Scripts;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class RaceScript : PFUIPanel
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
protected Transform currentItem { get; set; }
|
||||
protected void StartTime()
|
||||
{
|
||||
timerFlag = true;
|
||||
StartCoroutine(Timer());
|
||||
}
|
||||
protected void StopTime()
|
||||
{
|
||||
timerFlag = false;
|
||||
}
|
||||
/// <summary>
|
||||
/// 通过消息调用,子给父传
|
||||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
public void SetCurrentItem(Transform t)
|
||||
{
|
||||
currentItem = t;
|
||||
HandleTime();
|
||||
if (t != null)
|
||||
{
|
||||
StartTime();
|
||||
}
|
||||
else
|
||||
{
|
||||
StopTime();
|
||||
}
|
||||
}
|
||||
/*参考代码
|
||||
var second = Math.Ceiling((Now - mapCompetition.StartTime.ToLocalTime()).TotalSeconds);
|
||||
|
||||
var ts = TimeSpan.FromSeconds(second);
|
||||
return $"{ (int)ts.TotalHours }:{ts:mm}:{ts:ss}";*/
|
||||
private bool timerFlag = false;
|
||||
IEnumerator Timer()
|
||||
{
|
||||
while (timerFlag)
|
||||
{
|
||||
yield return new WaitForSeconds(1.0f); // 停止执行1秒
|
||||
HandleTime();
|
||||
//time = UIManager.Now.GetDateTime().AddSeconds(1);
|
||||
}
|
||||
}
|
||||
private void HandleTime()
|
||||
{
|
||||
if (currentItem != null && currentItem.Find("GetReadyContainer").gameObject.activeSelf)
|
||||
{
|
||||
var map = currentItem.GetComponent<RaceItemScript>().mapCompetition;
|
||||
var time = map.StartTime.ToLocalTime() - UIManager.Now.GetDateTime();
|
||||
if (time.TotalSeconds < 0)
|
||||
{
|
||||
currentItem.Find("GetReadyContainer").GetComponent<CanvasGroup>().alpha = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentItem.Find("GetReadyContainer").GetComponent<CanvasGroup>().alpha = 1;
|
||||
currentItem.Find("GetReadyContainer/Value").GetComponent<Text>().text
|
||||
= Utils.GetCountDown(time);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user