76 lines
2.6 KiB
C#
76 lines
2.6 KiB
C#
using System;
|
|
using UnityEngine.UI;
|
|
using ZXKFramework;
|
|
namespace DongWuYiXue.DaoNiaoShu
|
|
{
|
|
public class TxtSelectQuestionPanel : UIBase
|
|
{
|
|
public override string GroupName => "TxtSelectQuestionPanel";
|
|
public override string Name => "TxtSelectQuestionPanel";
|
|
|
|
public Action nextAction;
|
|
public Action<bool> subAction;
|
|
TxtSelectManager[] txtSelectManagers;
|
|
Button nextBtn;
|
|
Button subBtn;
|
|
int id;
|
|
string stepName;
|
|
public override void Init(IUIManager uictrl)
|
|
{
|
|
base.Init(uictrl);
|
|
txtSelectManagers = GetComponentsInChildren<TxtSelectManager>(true);
|
|
nextBtn = transform.FindFirst<Button>("Next");
|
|
nextBtn.onClick.AddListener(Next);
|
|
subBtn = transform.FindFirst<Button>("Submit");
|
|
subBtn.onClick.AddListener(Submit);
|
|
}
|
|
private void Submit()
|
|
{
|
|
if (txtSelectManagers[id].Check())
|
|
{
|
|
subAction?.Invoke(true);
|
|
Game.Instance.eventManager.Raise(new PlayTrueOrFalseEvent() { isTrue = true });
|
|
}
|
|
else
|
|
{
|
|
Game.Instance.eventManager.Raise(new PlayTrueOrFalseEvent() { isTrue = false });
|
|
if (MVC.GetModel<Main.GameModel>().modeType == ModeType.ShiXun)
|
|
{
|
|
ChatUI.Instance.SendAI("用户位于:" + stepName + ",用户的作答为:" + txtSelectManagers[id].GetYourAnswer() + ",请对用户的作答进行解析,并介绍本步骤正确答案和意义,字数控制在100字以内。", null);
|
|
}
|
|
else
|
|
{
|
|
subAction?.Invoke(false);
|
|
}
|
|
}
|
|
subBtn.gameObject.SetActive(false);
|
|
nextBtn.gameObject.SetActive(true);
|
|
}
|
|
private void Next()
|
|
{
|
|
ChatUI.Instance.CloseChatTxt();
|
|
SetActive(false);
|
|
subBtn.gameObject.SetActive(true);
|
|
nextBtn.gameObject.SetActive(false);
|
|
nextAction?.Invoke();
|
|
}
|
|
public void ShowImgQuestion(int id, string stepName)
|
|
{
|
|
SetActive(true);
|
|
this.id = id;
|
|
this.stepName = stepName;
|
|
for (int i = 0; i < txtSelectManagers.Length; i++)
|
|
{
|
|
if (i == id)
|
|
{
|
|
txtSelectManagers[i].gameObject.SetActive(true);
|
|
txtSelectManagers[i].Init();
|
|
}
|
|
else
|
|
{
|
|
txtSelectManagers[i].gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |