66 lines
1.1 KiB
C#
66 lines
1.1 KiB
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
using UnityEngine.UI;
|
||
|
public class TaskMgr : MonoBehaviour
|
||
|
{
|
||
|
public static TaskMgr instance;
|
||
|
|
||
|
public int tasktime;
|
||
|
|
||
|
public bool taskbool ;
|
||
|
void Awake()
|
||
|
{
|
||
|
taskbool = true;
|
||
|
instance = this;
|
||
|
tasktime = 300;
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
|
||
|
|
||
|
public void setText(Text tx)
|
||
|
{
|
||
|
|
||
|
tx.text = "slkjfla" +"("+ SetTime(tasktime)+")";
|
||
|
Debug.Log(tasktime);
|
||
|
if (tasktime > 0)
|
||
|
{
|
||
|
taskbool = true;
|
||
|
tasktime--;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
taskbool = false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
private string SetTime(int time)
|
||
|
{
|
||
|
string tm="";
|
||
|
int hour, sec, miao;
|
||
|
hour = time / 3600;
|
||
|
sec = time / 60;
|
||
|
miao = time %60;
|
||
|
tm += hour.ToString();
|
||
|
tm += sec.ToString()+":";
|
||
|
|
||
|
if (miao == 0)
|
||
|
{
|
||
|
tm += "00";
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
tm += miao.ToString();
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
//tm = ""+ hour + "" + sec + ":" + "" + miao;
|
||
|
return tm;
|
||
|
}
|
||
|
|
||
|
}
|