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.

172 lines
3.9 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class panding22 : MonoBehaviour
{
public DuoXuan dx;
public static int[] a = new int[4];//代表54的12345题的对错
public static bool z;//代表第一次初始化
public Toggle[] one;//第一道题
public Toggle[] two;//第二道题
public Toggle[] three;//第三道题
public Toggle[] four;//第四道题
public Text[] text;
private void Start()
{
if (!z)
{
for (int i = 0; i < a.Length; i++)
{
a[i] = -1;
}
z = true;
}
dx.[0] = a[0];
dx.[1] = a[1];
dx.[2] = a[2];
dx.[3] = a[3];
for (int i = 0; i < one.Length; i++)
{
int k = i;
one[i].onValueChanged.AddListener((bool bo) => oneToggleCtrl(bo, k));
}
for (int i = 0; i < two.Length; i++)
{
int k = i;
two[i].onValueChanged.AddListener((bool bo) => twoToggleCtrl(bo, k));
}
for (int i = 0; i < three.Length; i++)
{
int k = i;
three[i].onValueChanged.AddListener((bool bo) => threeToggleCtrl(bo, k));
}
for (int i = 0; i < four.Length; i++)
{
int k = i;
four[i].onValueChanged.AddListener((bool bo) => fourToggleCtrl(bo, k));
}
}
public void panding1(int b)
{
dx.[3] = b;
}
public void panding2(int b)
{
dx.[2] = b;
}
public void panding3(int b)
{
dx.[1] = b;
}
public void panding4(int b)
{
dx.[0] = b;
}
public void panding1()
{
a[0] = dx.[0];
}
public void panding2()
{
a[1] = dx.[1];
}
public void panding3()
{
a[2] = dx.[2];
}
public void oneToggleCtrl(bool bo, int id)
{
if (bo)
{
for (int i = 0; i < id; i++)
{
one[i].isOn = false;
}
for (int i = id + 1; i < one.Length; i++)
{
one[i].isOn = false;
}
}
if (one[4].isOn)
{
dx.[3] = 0;
}
else
{
dx.[3] = 1;
}
text[3].text = "100%";
}
public void twoToggleCtrl(bool bo, int id)
{
if (bo)
{
for (int i = 0; i < id; i++)
{
two[i].isOn = false;
}
for (int i = id + 1; i < two.Length; i++)
{
two[i].isOn = false;
}
}
if (two[7].isOn)
{
dx.[2] = 0;
}
else
{
dx.[2] = 1;
}
text[2].text = "75%";
}
public void threeToggleCtrl(bool bo, int id)
{
if (bo)
{
for (int i = 0; i < id; i++)
{
three[i].isOn = false;
}
for (int i = id + 1; i < three.Length; i++)
{
three[i].isOn = false;
}
}
if (three[5].isOn)
{
dx.[1] = 0;
}
else
{
dx.[1] = 1;
}
text[1].text = "50%";
}
public void fourToggleCtrl(bool bo, int id)
{
if (bo)
{
for (int i = 0; i < id; i++)
{
four[i].isOn = false;
}
for (int i = id + 1; i < three.Length; i++)
{
four[i].isOn = false;
}
}
if (four[3].isOn)
{
dx.[0] = 0;
}
else
{
dx.[0] = 1;
}
text[0].text = "25%";
}
}