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.
137 lines
3.0 KiB
137 lines
3.0 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class panding21 : MonoBehaviour
|
|
{
|
|
public DuoXuan dx;
|
|
public static int[] a = new int[3];//代表21的123题的对错
|
|
public static bool z;//代表第一次初始化
|
|
public Toggle[] one;//第一道题
|
|
public Toggle[] two;//第二道题
|
|
public Toggle[] three;//第三道题
|
|
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];
|
|
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));
|
|
|
|
}
|
|
}
|
|
public void panding1(int b)
|
|
{
|
|
dx.选项[2] = b;
|
|
}
|
|
public void panding2(int b)
|
|
{
|
|
dx.选项[1] = b;
|
|
}
|
|
public void panding3(int b)
|
|
{
|
|
dx.选项[0] = b;
|
|
}
|
|
public void panding1()
|
|
{
|
|
a[0] = dx.选项[0];
|
|
}
|
|
public void panding2()
|
|
{
|
|
a[1] = dx.选项[1];
|
|
}
|
|
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[1].isOn)
|
|
{
|
|
dx.选项[2] = 0;
|
|
}
|
|
else
|
|
{
|
|
dx.选项[2] = 1;
|
|
}
|
|
text[2].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[6].isOn)
|
|
{
|
|
dx.选项[1] = 0;
|
|
}
|
|
else
|
|
{
|
|
dx.选项[1] = 1;
|
|
}
|
|
text[1].text = "66%";
|
|
}
|
|
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[2].isOn)
|
|
{
|
|
dx.选项[0] = 0;
|
|
}
|
|
else
|
|
{
|
|
dx.选项[0] = 1;
|
|
}
|
|
text[0].text = "33%";
|
|
}
|
|
}
|