fix:修复答题逻辑
parent
2a7e39ee60
commit
7b1337fb7c
File diff suppressed because it is too large
Load Diff
|
@ -36,9 +36,9 @@ namespace ZC
|
||||||
private void MinTipsUI_Callback()
|
private void MinTipsUI_Callback()
|
||||||
{
|
{
|
||||||
Global.UIManager.CloseLast();
|
Global.UIManager.CloseLast();
|
||||||
var bigTipsUI = (BigTipsUI)Global.UIManager.ShowOnlyUI(UIType.BigTipsUI);
|
var bigTipsUI = (BigTipsUI)Global.UIManager.ShowUI(UIType.BigTipsUI);
|
||||||
bigTipsUI.SetData("移动到护士身边进行常规血液检查");
|
bigTipsUI.SetData("移动到护士身边进行常规血液检查");
|
||||||
var minTipsUI = (MinTipsUI)Global.UIManager.ShowOnlyUI(UIType.MinTipsUI);
|
var minTipsUI = (MinTipsUI)Global.UIManager.ShowUI(UIType.MinTipsUI);
|
||||||
minTipsUI.SetData("知识点讲解1", "常规血液与尿液分析知识点讲解——设备认知之后的1",
|
minTipsUI.SetData("知识点讲解1", "常规血液与尿液分析知识点讲解——设备认知之后的1",
|
||||||
() => { Global.UIManager.HideUI(UIType.MinTipsUI); });
|
() => { Global.UIManager.HideUI(UIType.MinTipsUI); });
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ namespace ZC
|
||||||
triggerEvent.Dispose();
|
triggerEvent.Dispose();
|
||||||
|
|
||||||
// 播放抽血动画
|
// 播放抽血动画
|
||||||
var minTipsUI = (MinTipsUI)Global.UIManager.ShowOnlyUI(UIType.MinTipsUI);
|
var minTipsUI = (MinTipsUI)Global.UIManager.ShowUI(UIType.MinTipsUI);
|
||||||
minTipsUI.SetData("知识点讲解2", "常规血液与尿液分析知识点讲解——设备认知之后的2 ----------- 播放抽血动画", () =>
|
minTipsUI.SetData("知识点讲解2", "常规血液与尿液分析知识点讲解——设备认知之后的2 ----------- 播放抽血动画", () =>
|
||||||
{
|
{
|
||||||
Global.UIManager.HideUI(UIType.MinTipsUI);
|
Global.UIManager.HideUI(UIType.MinTipsUI);
|
||||||
|
@ -70,8 +70,9 @@ namespace ZC
|
||||||
var bigTipsUI = (BigTipsUI)Global.UIManager.ShowUI(UIType.BigTipsUI);
|
var bigTipsUI = (BigTipsUI)Global.UIManager.ShowUI(UIType.BigTipsUI);
|
||||||
bigTipsUI.SetData("根据箭头指引让老人去进行尿液取样");
|
bigTipsUI.SetData("根据箭头指引让老人去进行尿液取样");
|
||||||
|
|
||||||
var gameObject = binding.GetValue("尿液取样点");
|
GameObject go_NiaoYe;
|
||||||
triggerEvent = gameObject.GetOrAddComponent<TriggerEvent>();
|
go_NiaoYe = binding.GetValue("尿液取样点");
|
||||||
|
triggerEvent = go_NiaoYe.GetOrAddComponent<TriggerEvent>();
|
||||||
triggerEvent.SetData(PlayerMoveToPoint1);
|
triggerEvent.SetData(PlayerMoveToPoint1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,13 +82,13 @@ namespace ZC
|
||||||
async UniTask RunAsync()
|
async UniTask RunAsync()
|
||||||
{
|
{
|
||||||
Global.UIManager.HideUI(UIType.BigTipsUI);
|
Global.UIManager.HideUI(UIType.BigTipsUI);
|
||||||
triggerEvent.Dispose();
|
await UniTask.Delay(3000);
|
||||||
|
|
||||||
var urineSamplingUI = (UrineSamplingUI)Global.UIManager.ShowUI(UIType.UrineSamplingUI);
|
var urineSamplingUI = (UrineSamplingUI)Global.UIManager.ShowUI(UIType.UrineSamplingUI);
|
||||||
urineSamplingUI.SetData(UrineSamplingUI_Callback);
|
urineSamplingUI.SetData(UrineSamplingUI_Callback);
|
||||||
await UniTask.Delay(3000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
triggerEvent.Dispose();
|
||||||
RunAsync().Forget();
|
RunAsync().Forget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using Cysharp.Threading.Tasks;
|
using Cysharp.Threading.Tasks;
|
||||||
using Unity.Loader;
|
using Unity.Loader;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace ZC
|
namespace ZC
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
@ -70,9 +71,42 @@ namespace ZC
|
||||||
btn_Last.onClick.AddListener(ClickLastButton);
|
btn_Last.onClick.AddListener(ClickLastButton);
|
||||||
btn_Submit.onClick.AddListener(ClickSubmitButton);
|
btn_Submit.onClick.AddListener(ClickSubmitButton);
|
||||||
btn_Next.onClick.AddListener(ClickNextButton);
|
btn_Next.onClick.AddListener(ClickNextButton);
|
||||||
|
btn_TryAgain.onClick.AddListener(ClickTryAgainButton);
|
||||||
|
btn_Finish.onClick.AddListener(ClickFinishButton);
|
||||||
|
|
||||||
|
tog_Option0.onValueChanged.AddListener(Option0_onValueChanged);
|
||||||
|
tog_Option1.onValueChanged.AddListener(Option1_onValueChanged);
|
||||||
|
tog_Option2.onValueChanged.AddListener(Option2_onValueChanged);
|
||||||
|
tog_Option3.onValueChanged.AddListener(Option3_onValueChanged);
|
||||||
|
|
||||||
// 读取题库
|
// 读取题库
|
||||||
_bankData = new QuestionBankData();
|
_bankData = ResourcesLocalComponent.Instance.LoadAssetSync<QuestionBankData>(AssetConst
|
||||||
|
.Assets_DemoGame_GameRes_Config_QuestionBank_asset);
|
||||||
|
ResetAnswer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Option0_onValueChanged(bool arg0)
|
||||||
|
{
|
||||||
|
if (arg0)
|
||||||
|
currentChooseStr[currentIndex] = "A";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Option1_onValueChanged(bool arg0)
|
||||||
|
{
|
||||||
|
if (arg0)
|
||||||
|
currentChooseStr[currentIndex] = "B";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Option2_onValueChanged(bool arg0)
|
||||||
|
{
|
||||||
|
if (arg0)
|
||||||
|
currentChooseStr[currentIndex] = "C";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Option3_onValueChanged(bool arg0)
|
||||||
|
{
|
||||||
|
if (arg0)
|
||||||
|
currentChooseStr[currentIndex] = "D";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
|
@ -89,15 +123,31 @@ namespace ZC
|
||||||
isSubmit = false;
|
isSubmit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CheckIsShowJX()
|
||||||
|
{
|
||||||
|
if (!txt_TrueOption.gameObject.activeSelf)
|
||||||
|
{
|
||||||
|
txt_TrueOption.gameObject.SetActive(true);
|
||||||
|
txt_JXContent.gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (currentIndex >= _bankData.AnswerDatas.Count - 1)
|
||||||
|
return;
|
||||||
|
currentIndex++;
|
||||||
|
SetUIContent(_bankData.AnswerDatas[currentIndex]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ClickNextButton()
|
private void ClickNextButton()
|
||||||
{
|
{
|
||||||
currentIndex++;
|
CheckIsShowJX();
|
||||||
SetUIContent(_bankData.AnswerDatas[currentIndex]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClickSubmitButton()
|
private void ClickSubmitButton()
|
||||||
{
|
{
|
||||||
isSubmit = true;
|
isSubmit = true;
|
||||||
|
ShowResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ClickLastButton()
|
private void ClickLastButton()
|
||||||
|
@ -106,16 +156,13 @@ namespace ZC
|
||||||
SetUIContent(_bankData.AnswerDatas[currentIndex]);
|
SetUIContent(_bankData.AnswerDatas[currentIndex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 当前选择结果
|
||||||
|
private string[] currentChooseStr;
|
||||||
|
|
||||||
public void SetQuestionBankData(QuestionBankData bankData)
|
public void SetQuestionBankData(QuestionBankData bankData)
|
||||||
{
|
{
|
||||||
this._bankData = bankData;
|
this._bankData = bankData;
|
||||||
InitAnswer();
|
ResetAnswer();
|
||||||
}
|
|
||||||
|
|
||||||
private void InitAnswer()
|
|
||||||
{
|
|
||||||
currentIndex = 0;
|
|
||||||
SetUIContent(_bankData.AnswerDatas[currentIndex]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetUIContent(AnswerData data)
|
private void SetUIContent(AnswerData data)
|
||||||
|
@ -126,7 +173,7 @@ namespace ZC
|
||||||
txt_Label1.text = data.options[1].content;
|
txt_Label1.text = data.options[1].content;
|
||||||
txt_Label2.text = data.options[2].content;
|
txt_Label2.text = data.options[2].content;
|
||||||
txt_Label3.text = data.options[3].content;
|
txt_Label3.text = data.options[3].content;
|
||||||
txt_TrueOption.text = data.trueOption;
|
txt_TrueOption.text = $"正确答案:{data.trueOption}";
|
||||||
txt_JXContent.text = data.analyze;
|
txt_JXContent.text = data.analyze;
|
||||||
txt_TrueOption.gameObject.SetActive(false);
|
txt_TrueOption.gameObject.SetActive(false);
|
||||||
txt_JXContent.gameObject.SetActive(false);
|
txt_JXContent.gameObject.SetActive(false);
|
||||||
|
@ -136,29 +183,70 @@ namespace ZC
|
||||||
tog_Option2.isOn = false;
|
tog_Option2.isOn = false;
|
||||||
tog_Option3.isOn = false;
|
tog_Option3.isOn = false;
|
||||||
|
|
||||||
if (currentIndex >= _bankData.AnswerDatas.Count - 1) // 最后一题
|
// if (currentIndex >= _bankData.AnswerDatas.Count - 1) // 最后一题
|
||||||
{
|
// {
|
||||||
btn_Next.gameObject.SetActive(false);
|
// btn_Next.gameObject.SetActive(false);
|
||||||
// 提交按钮显示
|
// // 提交按钮显示
|
||||||
}
|
// }
|
||||||
else if (currentIndex <= 0) // 第一题
|
// else if (currentIndex <= 0) // 第一题
|
||||||
{
|
// {
|
||||||
btn_Last.gameObject.SetActive(false);
|
// btn_Last.gameObject.SetActive(false);
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
btn_Last.gameObject.SetActive(true);
|
// // btn_Last.gameObject.SetActive(true);
|
||||||
btn_Next.gameObject.SetActive(true);
|
// btn_Next.gameObject.SetActive(true);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResetAnswer()
|
void ResetAnswer()
|
||||||
{
|
{
|
||||||
|
panel_Answer.gameObject.SetActive(true);
|
||||||
|
panel_Result.gameObject.SetActive(false);
|
||||||
|
currentChooseStr = new string[_bankData.AnswerDatas.Count];
|
||||||
|
|
||||||
|
currentIndex = 0;
|
||||||
|
SetUIContent(_bankData.AnswerDatas[currentIndex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetData(Action callback)
|
public void SetData(Action callback)
|
||||||
{
|
{
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Result
|
||||||
|
|
||||||
|
void ShowResult()
|
||||||
|
{
|
||||||
|
panel_Answer.gameObject.SetActive(false);
|
||||||
|
panel_Result.gameObject.SetActive(true);
|
||||||
|
|
||||||
|
var answerDatas = _bankData.AnswerDatas;
|
||||||
|
int trueCount = 0;
|
||||||
|
int falseCount = 0;
|
||||||
|
for (var i = 0; i < currentChooseStr.Length; i++)
|
||||||
|
{
|
||||||
|
if (answerDatas[i].trueOption == currentChooseStr[i])
|
||||||
|
trueCount++;
|
||||||
|
else
|
||||||
|
falseCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
txt_TrueCount.text = trueCount.ToString();
|
||||||
|
txt_FalseCount.text = falseCount.ToString();
|
||||||
|
txt_ScoreCount.text = $"{trueCount}分";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ClickFinishButton()
|
||||||
|
{
|
||||||
|
callback?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ClickTryAgainButton()
|
||||||
|
{
|
||||||
|
ResetAnswer();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue