81 lines
2.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 LineQuestionPanel : UIBase
{
public override string GroupName => "LineQuestionPanel";
public override string Name => "LineQuestionPanel";
public Action nextAction;
public Action<bool> subAction;
PointLineManager[] lineManagers;
Button nextBtn;
Button subBtn;
Button resetBtn;
int id;
public override void Init(IUIManager uictrl)
{
base.Init(uictrl);
lineManagers = GetComponentsInChildren<PointLineManager>(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 Reset()
{
for (int i = 0; i < lineManagers.Length; i++)
{
lineManagers[i].ClearLine();
}
}
private void Submit()
{
lineManagers[id].UnselectPoints();//ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
lineManagers[id].ButtonOnEnable();//<2F><><EFBFBD>ð<EFBFBD>ť
if (lineManagers[id].JudgeLine())
{
subAction?.Invoke(true);
}
else
{
subAction?.Invoke(false);
}
subBtn.interactable = false;
resetBtn.interactable = false;
nextBtn.gameObject.SetActive(true);
}
private void Next()
{
subBtn.interactable = true;
resetBtn.interactable = true;
nextBtn.gameObject.SetActive(false);
SetActive(false);
nextAction?.Invoke();
}
public void ShowLineQuestion(int id)
{
SetActive(true);
this.id = id;
for (int i = 0; i < lineManagers.Length; i++)
{
if (i == id)
{
lineManagers[i].gameObject.SetActive(true);
lineManagers[i].UnselectPoints();//ȡ<><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
lineManagers[i].ButtonOnEnable();//<2F><><EFBFBD>ð<EFBFBD>ť
}
else
{
lineManagers[i].gameObject.SetActive(false);
}
}
}
}
}