2023-12-10 12:28:20 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.Serialization;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
using ZGameFramework;
|
|
|
|
|
using ZXL.Excel;
|
|
|
|
|
|
|
|
|
|
namespace Script.UI
|
|
|
|
|
{
|
|
|
|
|
public class AnsweringPanel : PanelBase
|
|
|
|
|
{
|
|
|
|
|
// top
|
|
|
|
|
[SerializeField] private Text txt_ID;
|
|
|
|
|
[SerializeField] private Text txt_Progress;
|
|
|
|
|
|
|
|
|
|
private List<SingleChoice_QuestionBank_A_DataInfo> _aDataInfos = new List<SingleChoice_QuestionBank_A_DataInfo>();
|
|
|
|
|
private List<SingleChoice_QuestionBank_B_DataInfo> _bDataInfos = new List<SingleChoice_QuestionBank_B_DataInfo>();
|
|
|
|
|
private List<TureOrFalse_QuestionBank_C_DataInfo> _cDataInfos = new List<TureOrFalse_QuestionBank_C_DataInfo>();
|
|
|
|
|
private List<MultipleChoice_QuestionBank_D_DataInfo> _dDataInfos = new List<MultipleChoice_QuestionBank_D_DataInfo>();
|
|
|
|
|
|
|
|
|
|
// down
|
|
|
|
|
[SerializeField] private List<Right_QuestionItem> _rightQuestionItems = new List<Right_QuestionItem>();
|
|
|
|
|
|
|
|
|
|
[SerializeField] private Button btn_ConfirmSubmit;
|
|
|
|
|
|
|
|
|
|
private List<GameObject> textItemList = new List<GameObject>();
|
|
|
|
|
private List<GameObject> toggleItemList = new List<GameObject>();
|
|
|
|
|
|
|
|
|
|
public Color answeredColor; // 已答
|
|
|
|
|
public Color unansweredColor; // 未答
|
|
|
|
|
|
|
|
|
|
public override void Init()
|
|
|
|
|
{
|
|
|
|
|
base.Init();
|
|
|
|
|
|
|
|
|
|
btn_ConfirmSubmit.onClick.AddListener(ClickConfirmSubmit);
|
2023-12-26 23:25:22 +08:00
|
|
|
|
EventManager.Instance.Subscribe(QuestionSureEventArgs.EventId, QuestionSureEvent);
|
2023-12-10 12:28:20 +08:00
|
|
|
|
}
|
2023-12-26 23:25:22 +08:00
|
|
|
|
|
2023-12-10 12:28:20 +08:00
|
|
|
|
private void QuestionSureEvent(object sender, GameEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var args = e as QuestionSureEventArgs;
|
2023-12-26 11:21:59 +08:00
|
|
|
|
if (args.isTrue)
|
|
|
|
|
_toggles[args.index].transform.Find("Background").GetComponent<Image>().color = answeredColor;
|
|
|
|
|
else
|
|
|
|
|
_toggles[args.index].transform.Find("Background").GetComponent<Image>().color = unansweredColor;
|
2023-12-10 12:28:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Open()
|
|
|
|
|
{
|
|
|
|
|
base.Open();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void ResetPanelData()
|
|
|
|
|
{
|
|
|
|
|
base.ResetPanelData();
|
2023-12-26 23:25:22 +08:00
|
|
|
|
Debug.Log("重置抽题数据");
|
|
|
|
|
_aDataInfos.Clear();
|
|
|
|
|
_bDataInfos.Clear();
|
|
|
|
|
_cDataInfos.Clear();
|
|
|
|
|
_dDataInfos.Clear();
|
|
|
|
|
|
2023-12-10 12:28:20 +08:00
|
|
|
|
// 数据存入
|
|
|
|
|
_aDataInfos.Add(ExcelManager.Instance.GetRandomAInfo);
|
|
|
|
|
_bDataInfos.Add(ExcelManager.Instance.GetRandomBInfo);
|
|
|
|
|
_dDataInfos.Add(ExcelManager.Instance.GetRandomDInfo);
|
|
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
|
|
{
|
|
|
|
|
_cDataInfos.Add(ExcelManager.Instance.GetRandomCInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_rightQuestionItems[0].SetData(
|
|
|
|
|
0,
|
|
|
|
|
"单项选择题(每小题2分,共2小题)",
|
|
|
|
|
_aDataInfos[0].topic,
|
|
|
|
|
_aDataInfos[0].options,
|
|
|
|
|
_aDataInfos[0].answer,
|
|
|
|
|
ShowIndexQuestion,
|
|
|
|
|
ShowIndexQuestion
|
|
|
|
|
);
|
2023-12-26 23:25:22 +08:00
|
|
|
|
GlobalManager.Instance.AddCurrentAnswer(_aDataInfos[0].topic, _aDataInfos[0].options, _aDataInfos[0].answer);
|
2023-12-10 12:28:20 +08:00
|
|
|
|
|
|
|
|
|
_rightQuestionItems[1].SetData(
|
|
|
|
|
1,
|
|
|
|
|
"单项选择题(每小题2分,共2小题)",
|
|
|
|
|
_bDataInfos[0].topic,
|
|
|
|
|
_bDataInfos[0].options,
|
|
|
|
|
_bDataInfos[0].answer,
|
|
|
|
|
ShowIndexQuestion,
|
|
|
|
|
ShowIndexQuestion
|
|
|
|
|
);
|
2023-12-26 23:25:22 +08:00
|
|
|
|
GlobalManager.Instance.AddCurrentAnswer(_bDataInfos[0].topic, _bDataInfos[0].options, _bDataInfos[0].answer);
|
2023-12-10 12:28:20 +08:00
|
|
|
|
|
|
|
|
|
_rightQuestionItems[2].SetData(
|
|
|
|
|
2,
|
|
|
|
|
"单选判断题(每小题2分,共2小题)",
|
|
|
|
|
_cDataInfos[0].topic,
|
|
|
|
|
_cDataInfos[0].options,
|
|
|
|
|
_cDataInfos[0].answer,
|
|
|
|
|
ShowIndexQuestion,
|
|
|
|
|
ShowIndexQuestion
|
|
|
|
|
);
|
2023-12-26 23:25:22 +08:00
|
|
|
|
GlobalManager.Instance.AddCurrentAnswer(_cDataInfos[0].topic, _cDataInfos[0].options, _cDataInfos[0].answer);
|
2023-12-10 12:28:20 +08:00
|
|
|
|
|
|
|
|
|
_rightQuestionItems[3].SetData(
|
|
|
|
|
3,
|
|
|
|
|
"单选判断题(每小题2分,共2小题)",
|
|
|
|
|
_cDataInfos[1].topic,
|
|
|
|
|
_cDataInfos[1].options,
|
|
|
|
|
_cDataInfos[1].answer,
|
|
|
|
|
ShowIndexQuestion,
|
|
|
|
|
ShowIndexQuestion
|
|
|
|
|
);
|
2023-12-26 23:25:22 +08:00
|
|
|
|
GlobalManager.Instance.AddCurrentAnswer(_cDataInfos[1].topic, _cDataInfos[1].options, _cDataInfos[1].answer);
|
2023-12-10 12:28:20 +08:00
|
|
|
|
|
|
|
|
|
_rightQuestionItems[4].SetData(
|
|
|
|
|
4,
|
|
|
|
|
"多选选择题(每小题2分,共1小题)",
|
|
|
|
|
_dDataInfos[0].topic,
|
|
|
|
|
_dDataInfos[0].options,
|
|
|
|
|
_dDataInfos[0].answer,
|
|
|
|
|
ShowIndexQuestion,
|
|
|
|
|
ShowIndexQuestion
|
|
|
|
|
);
|
2023-12-26 23:25:22 +08:00
|
|
|
|
GlobalManager.Instance.AddCurrentAnswer(_dDataInfos[0].topic, _dDataInfos[0].options, _dDataInfos[0].answer);
|
2023-12-10 12:28:20 +08:00
|
|
|
|
|
|
|
|
|
//
|
2023-12-26 11:21:59 +08:00
|
|
|
|
txt_ID.text = GlobalManager.Instance.CurrentInfo.id;
|
2023-12-10 12:28:20 +08:00
|
|
|
|
|
|
|
|
|
SetLeftStart();
|
|
|
|
|
ShowIndexQuestion(0);
|
|
|
|
|
|
|
|
|
|
foreach (var rightQuestionItem in _rightQuestionItems)
|
|
|
|
|
{
|
|
|
|
|
rightQuestionItem.Hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_rightQuestionItems[0].Show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Dispose()
|
|
|
|
|
{
|
|
|
|
|
base.Dispose();
|
2023-12-26 23:25:22 +08:00
|
|
|
|
EventManager.Instance.Unsubscribe(QuestionSureEventArgs.EventId, QuestionSureEvent);
|
2023-12-10 12:28:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Down Left
|
|
|
|
|
|
|
|
|
|
[SerializeField] private List<AnsweringToggleHelper> _toggles = new List<AnsweringToggleHelper>();
|
|
|
|
|
|
|
|
|
|
void SetLeftStart()
|
|
|
|
|
{
|
|
|
|
|
foreach (var toggle in _toggles)
|
|
|
|
|
{
|
|
|
|
|
toggle.SetAction(ShowIndexQuestion);
|
|
|
|
|
toggle.transform.GetChild(0).GetComponent<Image>().color = unansweredColor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_toggles[0].toggle.isOn = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SetLeftToggle(int index)
|
|
|
|
|
{
|
|
|
|
|
_toggles[index].toggle.isOn = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ClickConfirmSubmit()
|
|
|
|
|
{
|
|
|
|
|
var openPanel = UIManager.Instance.OpenPanel(PanelType.Tips);
|
|
|
|
|
var tipsPanel = openPanel as TipsPanel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Down Right
|
|
|
|
|
|
|
|
|
|
private void ShowIndexQuestion(int index)
|
|
|
|
|
{
|
|
|
|
|
SetLeftToggle(index);
|
|
|
|
|
txt_Progress.text = $"{index + 1}/5";
|
|
|
|
|
foreach (var rightQuestionItem in _rightQuestionItems)
|
|
|
|
|
{
|
|
|
|
|
rightQuestionItem.Hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_rightQuestionItems[index].Show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Top
|
|
|
|
|
|
|
|
|
|
[SerializeField] private CountDownItem _countDownItem;
|
|
|
|
|
|
|
|
|
|
public void Pause()
|
|
|
|
|
{
|
|
|
|
|
SaveData();
|
|
|
|
|
_countDownItem.Pause();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Resume()
|
|
|
|
|
{
|
|
|
|
|
_countDownItem.Resume();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Stop()
|
|
|
|
|
{
|
|
|
|
|
_countDownItem.StopCountDown();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public void SaveData()
|
|
|
|
|
{
|
|
|
|
|
int score = 0;
|
|
|
|
|
int trueCount = 0;
|
|
|
|
|
int falseCount = 0;
|
|
|
|
|
int nullCount = 0;
|
|
|
|
|
foreach (var rightQuestionItem in _rightQuestionItems)
|
|
|
|
|
{
|
|
|
|
|
var resultType = rightQuestionItem.GetResult();
|
|
|
|
|
switch (resultType)
|
|
|
|
|
{
|
|
|
|
|
case ResultType.未答:
|
|
|
|
|
++nullCount;
|
|
|
|
|
break;
|
|
|
|
|
case ResultType.正确:
|
|
|
|
|
score += 2;
|
|
|
|
|
++trueCount;
|
|
|
|
|
break;
|
|
|
|
|
case ResultType.错误:
|
|
|
|
|
++falseCount;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
throw new ArgumentOutOfRangeException();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var count = (trueCount / 5f) * 100;
|
|
|
|
|
|
|
|
|
|
Debug.Log($"{score}-{trueCount}-{falseCount}-{nullCount}-{count}%");
|
|
|
|
|
|
2023-12-26 11:21:59 +08:00
|
|
|
|
// GlobalManager.Instance.summaryInfo.score = score;
|
|
|
|
|
// GlobalManager.Instance.summaryInfo.trueCount = trueCount;
|
|
|
|
|
// GlobalManager.Instance.summaryInfo.falseCount = falseCount;
|
|
|
|
|
// GlobalManager.Instance.summaryInfo.nullCount = nullCount;
|
|
|
|
|
// GlobalManager.Instance.summaryInfo.accuracy = $"{count}%";
|
2023-12-26 23:25:22 +08:00
|
|
|
|
GlobalManager.Instance.SetCurrentScoreAndOther(score.ToString(), trueCount.ToString(), falseCount.ToString(), nullCount.ToString(), $"{count}%");
|
2023-12-10 12:28:20 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|