2025-09-08 14:51:28 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using UnityEngine;
|
2025-09-25 17:30:19 +08:00
|
|
|
|
using ZXKFramework;
|
|
|
|
|
|
namespace DongWuYiXue.DaoNiaoShu
|
2025-09-08 14:51:28 +08:00
|
|
|
|
{
|
|
|
|
|
|
public class TxtSelectManager : MonoBehaviour
|
|
|
|
|
|
{
|
|
|
|
|
|
TxtOption[] txtOptions;
|
|
|
|
|
|
public TxtOption[] answers;
|
|
|
|
|
|
|
|
|
|
|
|
public void Init()
|
|
|
|
|
|
{
|
|
|
|
|
|
txtOptions = GetComponentsInChildren<TxtOption>();
|
|
|
|
|
|
for (int i = 0; i < txtOptions.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
txtOptions[i].Interactable();
|
|
|
|
|
|
txtOptions[i].UnSelect();
|
|
|
|
|
|
txtOptions[i].SetNormalColor();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public bool Check()
|
|
|
|
|
|
{
|
|
|
|
|
|
//<2F>ж<EFBFBD><D0B6><EFBFBD>
|
|
|
|
|
|
TxtOption[] yourSelect = txtOptions.ToList().FindAll(e => e.isSelect == true).ToArray();
|
|
|
|
|
|
bool isTrue = AreArraysEqual(yourSelect, answers);
|
|
|
|
|
|
for (int i = 0; i < answers.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
answers[i].SetRightColor();
|
|
|
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < yourSelect.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!answers.Contains(yourSelect[i]))
|
|
|
|
|
|
{
|
|
|
|
|
|
yourSelect[i].SetFalseColor();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
for (int i = 0; i < txtOptions.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
txtOptions[i].UnInteractable();
|
|
|
|
|
|
}
|
|
|
|
|
|
return isTrue;
|
|
|
|
|
|
}
|
|
|
|
|
|
bool AreArraysEqual(TxtOption[] array1, TxtOption[] array2)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (array1 == null && array2 == null) return true; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊnull<6C><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>true
|
|
|
|
|
|
if (array1 == null || array2 == null) return false; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>Ϊnull<6C><6C><EFBFBD><EFBFBD><EFBFBD><EFBFBD>false
|
|
|
|
|
|
if (array1.Length != array2.Length) return false; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȳ<EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>false
|
|
|
|
|
|
return array1.SequenceEqual(array2); // ʹ<><CAB9>SequenceEqual<61>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ȫ<EFBFBD><C8AB>ͬ
|
|
|
|
|
|
}
|
2025-09-25 17:30:19 +08:00
|
|
|
|
public string GetYourAnswer()
|
|
|
|
|
|
{
|
|
|
|
|
|
TxtOption[] yourSelect = txtOptions.ToList().FindAll(e => e.isSelect == true).ToArray();
|
|
|
|
|
|
string str = "";
|
|
|
|
|
|
for (int i = 0; i < yourSelect.Length; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
str += yourSelect[i].name;
|
|
|
|
|
|
}
|
|
|
|
|
|
if(string.IsNullOrEmpty(str))
|
|
|
|
|
|
{
|
|
|
|
|
|
return "<22><>";
|
|
|
|
|
|
}
|
|
|
|
|
|
return str;
|
|
|
|
|
|
}
|
2025-09-08 14:51:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|