123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using System;
- using UnityEngine;
- using System.Collections;
- using Random = UnityEngine.Random;
- public class CapchaCheck : MonoBehaviour {
-
- [SerializeField]
- private UISprite[] Symbol1;
- [SerializeField]
- private UISprite[] Symbol2;
- [SerializeField]
- private UISprite[] Symbol3;
- [SerializeField]
- private UISprite[] Symbol4;
- [SerializeField]
- private UIButton _refresh;
- private string _value;
- // Use this for initialization
- void Start ()
- {
- Refresh();
- _refresh.onClick.Add(new EventDelegate(Refresh));
- }
- public void Refresh()
- {
- _value = Random.Range(1000, 9999).ToString();
- for (int i = 0; i < _value.Length; i++)
- {
- Activate(i, Int32.Parse(_value[i].ToString()));
- }
- }
- private void Activate(int leter, int index)
- {
- UISprite[] arr = null;
- switch (leter)
- {
- case 0:
- arr = Symbol1;
- break;
- case 1:
- arr = Symbol2;
- break;
- case 2:
- arr = Symbol3;
- break;
- case 3:
- arr = Symbol4;
- break;
- }
- if (arr != null)
- {
- for (int i = 0; i < arr.Length; i++)
- {
- arr[i].gameObject.SetActive(i==index);
- }
- }
- }
- public bool Check(string capcha)
- {
- return _value.Equals(capcha.Trim());
- }
- private void OnEnable()
- {
- Refresh();
- }
- }
|