You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
2.5 KiB
102 lines
2.5 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
public class MyInput : MonoBehaviour
|
|
{
|
|
public InputField inputField;
|
|
public List<string> key;
|
|
public bool boolOpen;
|
|
|
|
public GameObject one, two;
|
|
|
|
public int IntName;
|
|
|
|
public List<GameObject> ObjList;
|
|
|
|
public GameObject mistakeTetx; //错误显示文本
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (!boolOpen)
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.Return) && inputField.text.Contains(key[0]) && !inputField.text.Contains(key[1]))
|
|
{
|
|
|
|
switch (IntName)
|
|
{
|
|
case 0:
|
|
mistakeTetx.SetActive(false);
|
|
|
|
one.SetActive(true);
|
|
boolOpen = true;
|
|
Invoke("yc", 2);
|
|
break;
|
|
case 1:
|
|
mistakeTetx.SetActive(false);
|
|
|
|
StartCoroutine(display());
|
|
boolOpen = true;
|
|
Invoke("yc", 5);
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.Return) && inputField.text.Contains(key[1]))
|
|
{
|
|
|
|
switch (IntName)
|
|
{
|
|
case 0:
|
|
mistakeTetx.SetActive(false);
|
|
|
|
two.SetActive(true);
|
|
boolOpen = true;
|
|
Invoke("yc", 2);
|
|
break;
|
|
case 1:
|
|
mistakeTetx.SetActive(false);
|
|
|
|
StartCoroutine(display());
|
|
boolOpen = true;
|
|
Invoke("yc", 5);
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
if(Input.GetKeyDown(KeyCode.Return) && !inputField.text.Contains(key[1])&& !inputField.text.Contains(key[0]))
|
|
{
|
|
mistakeTetx.SetActive(true);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
IEnumerator display()
|
|
{
|
|
for (int i = 0; i < ObjList.Count; i++)
|
|
{
|
|
yield return new WaitForSeconds(0.5f);
|
|
ObjList[i].SetActive(true);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 延迟执行
|
|
/// </summary>
|
|
public void yc()
|
|
{
|
|
GameManager.Instance.UpdateQuestionIndex();
|
|
|
|
this.gameObject.SetActive(false);
|
|
|
|
}
|
|
}
|