using DataModel.Model;
using LitJson;
using System;
using System.Text;
using UnityEngine;
using UnityEngine.UI;
///
/// 指挥面板
///
public class CommandPanel : MonoBehaviour
{
public static CommandPanel Instance;
///
/// 开始当前科目
///
public bool startCurrentSubject = false;
///
/// 完成当前科目
///
public bool endCurrentSubject = false;
///
/// 步骤父物体
///
public Transform stepParent;
///
/// 科目父物体
///
public Transform subjectParent;
///
/// 开始科目按钮
///
public Button btn_Active;
///
/// 结束科目按钮
///
public Button btn_Completed;
///
/// 当前选中科目
///
public practicesubject currentPsubjects;
public practicesubject startPsubjects;
///
/// 当前选中科目步骤
///
public practicesubjectstep currentPstep;
///
/// 当前选择步骤按钮
///
private Button currentBtn;
private int clickCount = 0;
private practicesubjectstep[] steps;
private practicesubject[] subjects;
public FunctionSync_Active[] getOn;
public FunctionSync_Active[] getOff;
///
/// 科目启停回调
///
///
///
///
///
public void SetSubject(string practiceId, string praticeSubjectId, string subjectName, bool ison)
{
TipsManager.instance.ShowSubjectTip(subjectName, ison);
if (ison)
{
startCurrentSubject = true;
btn_Active.interactable = false;
ReceiveCommand.instance.InitStep(praticeSubjectId);
if (subjectName == "转载下车前准备")
{
SetThreshold.instance.DismantleWeiZhuangWang();
for (int i = 0; i < getOn.Length; i++)
{
getOn[i].DisShowObject();
}
for (int i = 0; i < getOff.Length; i++)
{
getOff[i].ShowObject();
}
}
}
else
{
btn_Completed.interactable = false;
}
}
///
/// 步骤启停回调
///
///
///
///
///
///
public void SetStep(string practiceId, string praticeSubjectId, string subjectName, string pratciesubjectstepId, bool ison)
{
practiceseat seat = LoadManage.Instance.myPracticeSeat.Find(a => a.SeatNo == "0");
if (seat != null)
{
CurrentStepObj currentStepObj = currentBtn.GetComponentInParent();
string spritename = currentBtn.GetComponent().sprite.name;
switch (spritename)
{
case "未开始":
currentBtn.transform.GetComponent().sprite = currentStepObj.sprites[1];
break;
case "进行中":
currentBtn.transform.GetComponent().sprite = currentStepObj.sprites[2];
currentBtn.interactable = false;
clickCount++;
currentStepObj.isCheckButton = true;
break;
default:
break;
}
}
if (ison) TipsManager.instance.ShowStepsTip(pratciesubjectstepId);
foreach (var item in LoadManage.Instance.psteps)
{
if (item.ID.Equals(pratciesubjectstepId))
{
ReceiveCommand.instance.ChangeState(item);
}
}
practicesubjectstep p = LoadManage.Instance.psteps.Find(a => a.ID == pratciesubjectstepId);
if (p.Name.Equals("安装伪装网"))
{
SetThreshold.instance.InstallWeiZhaungWang();
}
}
///
/// 启动二维软件
///
public void StartSoft()
{
SoftManage.Instance.StartSoft(currentPsubjects.Id, currentPsubjects.Name, SoftManage.Instance.softName, LoadManage.Instance.currentPracticeSeat.UserAccount, 0);
}
///
/// 获取数据
///
public void ChargeData()
{
Init();
}
///
/// 初始化
///
public void Init()
{
Instance = this;
GameManage.Instance.SetSubjectAction(SetSubject);
GameManage.Instance.SetStepAction(SetStep);
InitSubject();
if (subjectParent.childCount > 0)
{
subjectParent.GetChild(0).GetComponent