70 lines
1.8 KiB
C#
70 lines
1.8 KiB
C#
using DG.Tweening;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class FractionInputManager : MonoBehaviour
|
|
{
|
|
public InputField InputStr;
|
|
[Header("跳转的用户编号")]
|
|
[SerializeField] List<string> StrData;
|
|
[Header("错误用户编号")]
|
|
[SerializeField] List<string> RunStrData;
|
|
[Header("输入框")]
|
|
[SerializeField] List<InputField> input;
|
|
[Header("分数")]
|
|
public int score;
|
|
int TempScore;//每题分数
|
|
[SerializeField] int XianZaiScore;//现在累计分数
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
InputStr.onValueChanged.AddListener((x) =>
|
|
{
|
|
if (x.Length.Equals(13))
|
|
{
|
|
var tempstr = x.Substring(3, 10);
|
|
|
|
StrData.Add(tempstr);
|
|
}
|
|
else if (x.Length.Equals(10))
|
|
{
|
|
StrData.Add(x);
|
|
}
|
|
});
|
|
foreach (var item in input)
|
|
{
|
|
item.onValueChanged.AddListener((x) =>
|
|
{
|
|
if (x.Length.Equals(10))
|
|
{
|
|
Starts(x);
|
|
}
|
|
if (x.Length.Equals(13))
|
|
{
|
|
Debug.Log(x);
|
|
var tempstr = x.Substring(3, 10);
|
|
Debug.Log(tempstr);
|
|
if (tempstr.Length.Equals(10))
|
|
{
|
|
Starts(x);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
public void Starts(string text)
|
|
{
|
|
int sum = 0;
|
|
for (int i = 0; i < RunStrData.Count; i++)
|
|
{
|
|
if (RunStrData[i] == text)
|
|
{
|
|
sum++;
|
|
}
|
|
}
|
|
XianZaiScore *= sum;
|
|
}
|
|
}
|