149 lines
4.8 KiB
C#
149 lines
4.8 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using YiLiao.XinFeiTingZhen;
|
|
using ZXKFramework;
|
|
namespace YiLiao.XinFeiTingZhen
|
|
{
|
|
public class LineQuestionPanel : UIBase
|
|
{
|
|
#region 修改代码前逻辑 暂未删除
|
|
//public override string GroupName => "LineQuestionPanel";
|
|
//public override string Name => "LineQuestionPanel";
|
|
|
|
//public Action nextAction;
|
|
//public Action<bool> subAction;
|
|
//PointLineManager[] lineManagers;
|
|
//Button nextBtn;
|
|
//Button subBtn;
|
|
//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);
|
|
//}
|
|
//private void Submit()
|
|
//{
|
|
// lineManagers[id].UnselectPoints();//取消高亮
|
|
// lineManagers[id].ButtonOnEnable();//启用按钮
|
|
// if (lineManagers[id].JudgeLine())
|
|
// {
|
|
// subAction?.Invoke(true);
|
|
// }
|
|
// else
|
|
// {
|
|
// subAction?.Invoke(false);
|
|
// }
|
|
// subBtn.gameObject.SetActive(false);
|
|
// nextBtn.gameObject.SetActive(true);
|
|
//}
|
|
//private void Next()
|
|
//{
|
|
// SetActive(false);
|
|
// subBtn.gameObject.SetActive(true);
|
|
// nextBtn.gameObject.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();//取消高亮
|
|
// lineManagers[i].ButtonOnEnable();//启用按钮
|
|
// }
|
|
// else
|
|
// {
|
|
// lineManagers[i].gameObject.SetActive(false);
|
|
// }
|
|
// }
|
|
//}
|
|
#endregion
|
|
|
|
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();//取消高亮
|
|
lineManagers[id].ButtonOnEnable();//启用按钮
|
|
if (lineManagers[id].JudgeLine())
|
|
{
|
|
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()
|
|
{
|
|
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();//取消高亮
|
|
lineManagers[i].ButtonOnEnable();//启用按钮
|
|
}
|
|
else
|
|
{
|
|
lineManagers[i].gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |