102 lines
3.4 KiB
C#
Raw Normal View History

2025-09-08 14:51:28 +08:00
using System;
using UnityEngine.UI;
using ZXKFramework;
2025-09-08 17:37:12 +08:00
namespace DongWuYiXue.DaoNiaoShu
2025-09-08 14:51:28 +08:00
{
public class ImgSelectQuestionPanel : UIBase
{
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;
2025-09-28 15:59:02 +08:00
string stepName;
2025-09-08 14:51:28 +08:00
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())
{
subAction?.Invoke(true);
2025-09-28 15:59:02 +08:00
Game.Instance.eventManager.Raise(new PlayTrueOrFalseEvent() { isTrue = true });
2025-09-08 14:51:28 +08:00
}
else
{
2025-09-29 11:43:07 +08:00
subAction?.Invoke(false);
2025-09-28 15:59:02 +08:00
Game.Instance.eventManager.Raise(new PlayTrueOrFalseEvent() { isTrue = false });
if (MVC.GetModel<Main.GameModel>().modeType == ModeType.ShiXun)
{
ChatUI.Instance.SendAI("<22>û<EFBFBD>λ<EFBFBD>ڣ<EFBFBD>" + stepName + "<22><><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>" + imgSelectManagers[id].GetYourAnswer() + "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><D0BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܱ<EFBFBD><DCB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD>𰸺<EFBFBD><F0B0B8BA><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>100<30><30><EFBFBD><EFBFBD><EFBFBD>ڡ<EFBFBD>", null);
}
else
{
subAction?.Invoke(false);
}
2025-09-08 14:51:28 +08:00
}
subBtn.interactable = false;
resetBtn.interactable = false;
nextBtn.gameObject.SetActive(true);
}
private void Next()
{
2025-09-28 15:59:02 +08:00
ChatUI.Instance.CloseChatTxt();
2025-09-08 14:51:28 +08:00
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);
}
}
}
2025-09-28 15:59:02 +08:00
public void ShowImgQuestion(int id,string stepName)
2025-09-08 14:51:28 +08:00
{
SetActive(true);
nextBtn.gameObject.SetActive(false);
subBtn.interactable = true;
resetBtn.interactable = true;
this.id = id;
2025-09-28 15:59:02 +08:00
this.stepName = stepName;
2025-09-08 14:51:28 +08:00
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);
}
}
}
}
}