public class LockTest : MonoBehaviour
{
//限定最小时间字符串
string minLockTime;
//到期时间字符串
string maxLockTime;
//最小时间整形
int minTime = 0;
//到期时间整型
int maxTime = 0;
//配置文件管理类
private ConfigTest configTest;
//Main
private Main main;
游戏按钮遮挡物体
//public GameObject zheObject;
// Use this for initialization
void Start()
{
main = GetComponent<Main>();
configTest = GetComponent<ConfigTest>();
BeginString();
StartCoroutine(ToLockThis());
}
/// <summary>
/// 初始化数据
/// </summary>
void BeginString()
{
minLockTime = configTest.dic["激活码"]["min"];
maxLockTime = configTest.dic["激活码"]["max"];
}
/// <summary>
/// 根据日期锁定
/// </summary>
/// <returns></returns>
IEnumerator ToLockThis()
{
yield return new WaitForSeconds(0.1f);
ToChangeTen();
yield return new WaitForSeconds(0.1f);
BeginToLock();
}
/// <summary>
/// 十六进制字符转换为十进制字符
/// </summary>
void ToChangeTen()
{
minTime = Convert.ToInt32(minLockTime,16);
maxTime = Convert.ToInt32(maxLockTime, 16);
}
/// <summary>
/// 根据日期锁定游戏
/// </summary>
void BeginToLock()
{
int todayTime = int.Parse(System.DateTime.Now.ToString("yyyyMMdd"));
Debug.Log(todayTime);
Debug.Log(minTime);
Debug.Log(maxTime);
if ((todayTime >= minTime) && (todayTime <= maxTime))
{
main.BlockGame(false);//调用的方法
}
else
{
main.BlockGame(true);//调用的方法
}
}
}
根据日期锁定,配合前边的config配置代码一起使用
最新推荐文章于 2024-01-11 14:31:05 发布