1. 程式人生 > >unity實現簡單的加密使用次數限制時間限制功能

unity實現簡單的加密使用次數限制時間限制功能

using UnityEngine;
using System.Collections;

public class jiaMI : MonoBehaviour {
    public System.DateTime time;
    int mi = 0;
	// Use this for initialization
	void Start () {
        //限制本地訪問exe次數
        if (PlayerPrefs.GetInt("miwen")>30) {
            Application.Quit();
        }
        mi = PlayerPrefs.GetInt("miwen");
        mi += 1;
        PlayerPrefs.SetInt("miwen",mi);

    }
	
	// Update is called once per frame
	void Update () {
        // Debug.Log(System.DateTime.Today.Year);
        //限制時間
        if (!(System.DateTime.Today.Year < 2017 && System.DateTime.Today.Month < 5 && System.DateTime.Today.Month < 1))
        {
            Application.Quit();
        }
 

	}
}