91 lines
3.0 KiB
C#
91 lines
3.0 KiB
C#
using System;
|
|
using UnityEngine.UI;
|
|
using ZXKFramework;
|
|
namespace DongWuYiXue.DaoNiaoShu
|
|
{
|
|
public class DragQuestionPanel : UIBase
|
|
{
|
|
public override string GroupName => "DragQuestionPanel";
|
|
public override string Name => "DragQuestionPanel";
|
|
|
|
public Action nextAction;
|
|
public Action<bool> subAction;
|
|
DragManager[] drags;
|
|
Button nextBtn;
|
|
Button subBtn;
|
|
Button resetBtn;
|
|
int id;
|
|
string stepName;
|
|
public override void Init(IUIManager uictrl)
|
|
{
|
|
base.Init(uictrl);
|
|
drags = GetComponentsInChildren<DragManager>(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 (drags[id].CheckAllDrag())
|
|
{
|
|
subAction?.Invoke(true);
|
|
nextBtn.gameObject.SetActive(true);
|
|
Game.Instance.eventManager.Raise(new PlayTrueOrFalseEvent() { isTrue = true });
|
|
}
|
|
else
|
|
{
|
|
nextBtn.gameObject.SetActive(true);
|
|
Game.Instance.eventManager.Raise(new PlayTrueOrFalseEvent() { isTrue = false });
|
|
if (MVC.GetModel<Main.GameModel>().modeType == ModeType.ShiXun)
|
|
{
|
|
ChatUI.Instance.SendAI(stepName + ",用户的答案为" + drags[id].GetYourAnswer() + ",请对用户的答案做解析,并介绍本步骤的答案和意义,字数控制在120字内。", null);
|
|
}
|
|
else
|
|
{
|
|
subAction?.Invoke(false);
|
|
}
|
|
}
|
|
drags[id].DisPlayResult();
|
|
subBtn.interactable = false;
|
|
resetBtn.interactable = false;
|
|
}
|
|
private void Next()
|
|
{
|
|
ChatUI.Instance.CloseChatTxt();
|
|
SetActive(false);
|
|
subBtn.interactable = true;
|
|
resetBtn.interactable = true;
|
|
nextBtn.gameObject.SetActive(false);
|
|
nextAction?.Invoke();
|
|
}
|
|
private void Reset()
|
|
{
|
|
drags[id].Init();
|
|
}
|
|
public void ShowDragQuestion(int id, string stepName)
|
|
{
|
|
SetActive(true);
|
|
this.stepName = stepName;
|
|
subBtn.interactable = true;
|
|
resetBtn.interactable = true;
|
|
nextBtn.gameObject.SetActive(false);
|
|
this.id = id;
|
|
for (int i = 0; i < drags.Length; i++)
|
|
{
|
|
if (i == id)
|
|
{
|
|
drags[i].gameObject.SetActive(true);
|
|
drags[i].Init();
|
|
}
|
|
else
|
|
{
|
|
drags[i].gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |