2026-03-24 11:39:01 +08:00

153 lines
5.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using UnityEngine.UI;
using ZXKFramework;
namespace YiLiao.XinFeiTingZhen
{
public class ImgSelectQuestionPanel : UIBase
{
#region
//public override string GroupName => "ImgSelectQuestionPanel";
//public override string Name => "ImgSelectQuestionPanel";
//public Action nextAction;
//public Action<bool> subAction;
//ImgSelectManager[] imgSelectManagers;
//Button nextBtn;
//Button subBtn;
//int id;
//public override void Init(IUIManager uictrl)
//{
// base.Init(uictrl);
// imgSelectManagers = GetComponentsInChildren<ImgSelectManager>(true);
// nextBtn = transform.FindFirst<Button>("Next");
// nextBtn.onClick.AddListener(Next);
// subBtn = transform.FindFirst<Button>("Submit");
// subBtn.onClick.AddListener(Submit);
//}
//private void Submit()
//{
// Game.Instance.sound.StopBGM();
// if (imgSelectManagers[id].Check())
// {
// subAction?.Invoke(true);
// }
// else
// {
// subAction?.Invoke(false);
// if (MVC.GetModel<Main.GameModel>().modeType == ModeType.ShiXun)
// {
// ChatUI2.Instance.SendAI("系统消息:用户的答案为“" + imgSelectManagers[id].GetYourAnswer() + "”请对用户的答案做解析并介绍本选择题步骤的意义。字数控制在120字内",null);
// }
// }
// subBtn.gameObject.SetActive(false);
// nextBtn.gameObject.SetActive(true);
//}
//private void Next()
//{
// ChatUI2.Instance.CloseChatTxt();
// SetActive(false);
// subBtn.gameObject.SetActive(true);
// nextBtn.gameObject.SetActive(false);
// nextAction?.Invoke();
//}
//public void ShowImgQuestion(int id)
//{
// SetActive(true);
// subBtn.gameObject.SetActive(true);
// nextBtn.gameObject.SetActive(false);
// this.id = id;
// for (int i = 0; i < imgSelectManagers.Length; i++)
// {
// if (i == id)
// {
// imgSelectManagers[i].gameObject.SetActive(true);
// imgSelectManagers[i].Init();
// }
// else
// {
// imgSelectManagers[i].gameObject.SetActive(false);
// }
// }
//}
#endregion
public override string GroupName => "ImgSelectQuestionPanel";
public override string Name => "ImgSelectQuestionPanel";
public Action nextAction;
public Action<bool> subAction;
ImgSelectManager[] imgSelectManagers;
Button nextBtn;
Button subBtn;
Button resetBtn;
int id;
public override void Init(IUIManager uictrl)
{
base.Init(uictrl);
imgSelectManagers = GetComponentsInChildren<ImgSelectManager>(true);
nextBtn = transform.FindFirst<Button>("Next");
nextBtn.onClick.AddListener(Next);
subBtn = transform.FindFirst<Button>("Submit");
subBtn.onClick.AddListener(Submit);
resetBtn = transform.FindFirst<Button>("Reset");
resetBtn.onClick.AddListener(Reset);
}
private void Submit()
{
Game.Instance.sound.StopBGM();
if (imgSelectManagers[id].Check())
{
Game.Instance.eventManager.Raise(new PlayTrueOrFalseEvent() { isTrue = true });
subAction?.Invoke(true);
}
else
{
Game.Instance.eventManager.Raise(new PlayTrueOrFalseEvent() { isTrue = false });
subAction?.Invoke(false);
}
subBtn.interactable = false;
resetBtn.interactable = false;
nextBtn.gameObject.SetActive(true);
}
private void Next()
{
SetActive(false);
subBtn.interactable = true;
resetBtn.interactable = true;
nextAction?.Invoke();
}
private void Reset()
{
for (int i = 0; i < imgSelectManagers.Length; i++)
{
if (i == id)
{
imgSelectManagers[i].gameObject.SetActive(true);
imgSelectManagers[i].Init();
}
else
{
imgSelectManagers[i].gameObject.SetActive(false);
}
}
}
public void ShowImgQuestion(int id)
{
SetActive(true);
nextBtn.gameObject.SetActive(false);
subBtn.interactable = true;
resetBtn.interactable = true;
this.id = id;
for (int i = 0; i < imgSelectManagers.Length; i++)
{
if (i == id)
{
imgSelectManagers[i].gameObject.SetActive(true);
imgSelectManagers[i].Init();
}
else
{
imgSelectManagers[i].gameObject.SetActive(false);
}
}
}
}
}