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 DragQuestionPanel : UIBase
|
|
|
|
|
{
|
|
|
|
|
public override string GroupName => "DragQuestionPanel";
|
|
|
|
|
public override string Name => "DragQuestionPanel";
|
|
|
|
|
|
|
|
|
|
public Action nextAction;
|
|
|
|
|
public Action<bool,int> subAction;
|
|
|
|
|
DragManager[] drags;
|
|
|
|
|
Button nextBtn;
|
|
|
|
|
Button subBtn;
|
|
|
|
|
Button resetBtn;
|
|
|
|
|
int id;
|
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
if (drags[id].CheckAllDrag())
|
|
|
|
|
{
|
|
|
|
|
subAction?.Invoke(true, id);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
subAction?.Invoke(false, id);
|
|
|
|
|
}
|
|
|
|
|
drags[id].DisPlayResult();
|
|
|
|
|
subBtn.interactable = false;
|
|
|
|
|
resetBtn.interactable= false;
|
|
|
|
|
nextBtn.gameObject.SetActive(true);
|
|
|
|
|
}
|
|
|
|
|
public override void Hide()
|
|
|
|
|
{
|
|
|
|
|
base.Hide();
|
|
|
|
|
subBtn.interactable = true;
|
|
|
|
|
resetBtn.interactable = true;
|
|
|
|
|
nextBtn.gameObject.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
private void Next()
|
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
SetActive(true);
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|